From ecffd0bea653e04a5a2deb648c70eee546371336 Mon Sep 17 00:00:00 2001 From: FishyClockwork Date: Fri, 14 Oct 2016 11:55:50 +0200 Subject: [PATCH] Done the code changes. This time only nulls I've added are nullptrs --- src/namedef.h | 1 + src/p_conversation.cpp | 25 +++++++++++++++++++++---- src/p_conversation.h | 1 + src/p_usdf.cpp | 6 +++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/namedef.h b/src/namedef.h index 36953e385..eab87c503 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -584,6 +584,7 @@ xx(Dialog) xx(Ifitem) xx(Choice) xx(Link) +xx(Goodbye) // Special menus xx(Mainmenu) diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index a697223e7..31fa25030 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -556,6 +556,7 @@ FStrifeDialogueNode::~FStrifeDialogueNode () { if (SpeakerName != NULL) delete[] SpeakerName; if (Dialogue != NULL) delete[] Dialogue; + if (Goodbye != nullptr) delete[] Goodbye; FStrifeDialogueReply *tokill = Children; while (tokill != NULL) { @@ -743,10 +744,26 @@ public: ++i; V_FreeBrokenLines (ReplyLines); } - char goodbye[25]; - mysnprintf(goodbye, countof(goodbye), "TXT_RANDOMGOODBYE_%d", 1+(pr_randomspeech() % NUM_RANDOM_GOODBYES)); - const char *goodbyestr = GStrings[goodbye]; - if (goodbyestr == NULL) goodbyestr = "Bye."; + const char *goodbyestr = CurNode->Goodbye; + if (goodbyestr == nullptr) + { + char goodbye[25]; + mysnprintf(goodbye, countof(goodbye), "TXT_RANDOMGOODBYE_%d", 1 + (pr_randomspeech() % NUM_RANDOM_GOODBYES)); + goodbyestr = GStrings[goodbye]; + if (goodbyestr == nullptr) goodbyestr = "Bye."; + } + else if (strncmp(goodbyestr, "RANDOM_", 7) == 0) + { + FString byetext; + + byetext.Format("TXT_%s_%02d", goodbyestr, 1 + (pr_randomspeech() % NUM_RANDOM_LINES)); + goodbyestr = GStrings[byetext]; + if (goodbyestr == nullptr) goodbyestr = "Bye."; + } + else if (goodbyestr[0] == '$') + { + goodbyestr = GStrings(goodbyestr + 1); + } mResponses.Push(mResponseLines.Size()); mResponseLines.Push(FString(goodbyestr)); diff --git a/src/p_conversation.h b/src/p_conversation.h index d6ba65d78..5b068fb04 100644 --- a/src/p_conversation.h +++ b/src/p_conversation.h @@ -30,6 +30,7 @@ struct FStrifeDialogueNode FSoundID SpeakerVoice; FTextureID Backdrop; char *Dialogue; + char *Goodbye = nullptr; // must init to null for binary scripts to work as intended FStrifeDialogueReply *Children; }; diff --git a/src/p_usdf.cpp b/src/p_usdf.cpp index 13a02b964..dccec7c21 100644 --- a/src/p_usdf.cpp +++ b/src/p_usdf.cpp @@ -286,6 +286,7 @@ class USDFParser : public UDMFParserBase FString SpeakerName; FString Dialogue; + FString Goodbye; while (!sc.CheckToken('}')) { @@ -331,7 +332,9 @@ class USDFParser : public UDMFParserBase node->ItemCheckNode = CheckInt(key); break; - + case NAME_Goodbye: + Goodbye = CheckString(key); + break; } } else @@ -354,6 +357,7 @@ class USDFParser : public UDMFParserBase } node->SpeakerName = ncopystring(SpeakerName); node->Dialogue = ncopystring(Dialogue); + node->Goodbye = ncopystring(Goodbye); return true; }