Fixed initialization of Strife dialogs internal structures

Explicit assignment to members, no more memset() on non-PoD types
https://mantis.zdoom.org/view.php?id=317
This commit is contained in:
alexey.lysiuk 2017-02-21 22:36:20 +02:00
parent bb6e667f33
commit bdd20d3887
3 changed files with 13 additions and 28 deletions

View file

@ -568,16 +568,6 @@ FStrifeDialogueNode::~FStrifeDialogueNode ()
} }
} }
//============================================================================
//
// FStrifeDialogueReply :: ~FStrifeDialogueReply
//
//============================================================================
FStrifeDialogueReply::~FStrifeDialogueReply ()
{
}
//============================================================================ //============================================================================
// //
// FindNode // FindNode

View file

@ -20,19 +20,19 @@ struct FStrifeDialogueItemCheck
struct FStrifeDialogueNode struct FStrifeDialogueNode
{ {
~FStrifeDialogueNode (); ~FStrifeDialogueNode ();
PClassActor *DropType; PClassActor *DropType = nullptr;
TArray<FStrifeDialogueItemCheck> ItemCheck; TArray<FStrifeDialogueItemCheck> ItemCheck;
int ThisNodeNum; // location of this node in StrifeDialogues int ThisNodeNum = 0; // location of this node in StrifeDialogues
int ItemCheckNode; // index into StrifeDialogues int ItemCheckNode = 0; // index into StrifeDialogues
PClassActor *SpeakerType; PClassActor *SpeakerType = nullptr;
FString SpeakerName; FString SpeakerName;
FSoundID SpeakerVoice; FSoundID SpeakerVoice;
FString Backdrop; FString Backdrop;
FString Dialogue; FString Dialogue;
FString Goodbye; // must init to null for binary scripts to work as intended FString Goodbye; // must init to null for binary scripts to work as intended
FStrifeDialogueReply *Children; FStrifeDialogueReply *Children = nullptr;
FName MenuClassName; FName MenuClassName;
FString UserData; FString UserData;
}; };
@ -40,13 +40,11 @@ struct FStrifeDialogueNode
// FStrifeDialogueReply holds responses the player can give to the NPC // FStrifeDialogueReply holds responses the player can give to the NPC
struct FStrifeDialogueReply struct FStrifeDialogueReply
{ {
~FStrifeDialogueReply (); FStrifeDialogueReply *Next = nullptr;
PClassActor *GiveType = nullptr;
FStrifeDialogueReply *Next; int ActionSpecial = 0;
PClassActor *GiveType; int Args[5] = {};
int ActionSpecial; int PrintAmount = 0;
int Args[5];
int PrintAmount;
TArray<FStrifeDialogueItemCheck> ItemCheck; TArray<FStrifeDialogueItemCheck> ItemCheck;
TArray<FStrifeDialogueItemCheck> ItemCheckRequire; TArray<FStrifeDialogueItemCheck> ItemCheckRequire;
TArray<FStrifeDialogueItemCheck> ItemCheckExclude; TArray<FStrifeDialogueItemCheck> ItemCheckExclude;
@ -54,9 +52,9 @@ struct FStrifeDialogueReply
FString QuickYes; FString QuickYes;
FString QuickNo; FString QuickNo;
FString LogString; FString LogString;
int NextNode; // index into StrifeDialogues int NextNode = 0; // index into StrifeDialogues
int LogNumber; int LogNumber = 0;
bool NeedsGold; bool NeedsGold = false;
}; };
extern TArray<FStrifeDialogueNode *> StrifeDialogues; extern TArray<FStrifeDialogueNode *> StrifeDialogues;

View file

@ -121,7 +121,6 @@ class USDFParser : public UDMFParserBase
bool ParseChoice(FStrifeDialogueReply **&replyptr) bool ParseChoice(FStrifeDialogueReply **&replyptr)
{ {
FStrifeDialogueReply *reply = new FStrifeDialogueReply; FStrifeDialogueReply *reply = new FStrifeDialogueReply;
memset(reply, 0, sizeof(*reply));
reply->Next = *replyptr; reply->Next = *replyptr;
*replyptr = reply; *replyptr = reply;
@ -293,8 +292,6 @@ class USDFParser : public UDMFParserBase
{ {
FStrifeDialogueNode *node = new FStrifeDialogueNode; FStrifeDialogueNode *node = new FStrifeDialogueNode;
FStrifeDialogueReply **replyptr = &node->Children; FStrifeDialogueReply **replyptr = &node->Children;
memset(node, 0, sizeof(*node));
//node->ItemCheckCount[0] = node->ItemCheckCount[1] = node->ItemCheckCount[2] = -1;
node->ThisNodeNum = StrifeDialogues.Push(node); node->ThisNodeNum = StrifeDialogues.Push(node);
node->ItemCheckNode = -1; node->ItemCheckNode = -1;