From 6d59fb3e9f3b9341f51bd78097ee07a52430ad86 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 10 Mar 2012 00:38:38 +0000 Subject: [PATCH] - Fixed: If the dialogues are freed while a dialogue menu is open, we need to close that menu, or it will crash because the dialogue node it refers to no longer exists. SVN r3418 (trunk) --- src/p_conversation.cpp | 46 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index dabb5f59a5..089ef45238 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -216,27 +216,6 @@ void P_LoadStrifeConversations (MapData *map, const char *mapname) } } -//============================================================================ -// -// P_FreeStrifeConversations -// -//============================================================================ - -void P_FreeStrifeConversations () -{ - FStrifeDialogueNode *node; - - while (StrifeDialogues.Pop (node)) - { - delete node; - } - - DialogueRoots.Clear(); - ClassRoots.Clear(); - - PrevNode = NULL; -} - //============================================================================ // // LoadScriptFile @@ -1065,6 +1044,31 @@ IMPLEMENT_ABSTRACT_CLASS(DConversationMenu) int DConversationMenu::mSelection; // needs to be preserved if the same dialogue is restarted +//============================================================================ +// +// P_FreeStrifeConversations +// +//============================================================================ + +void P_FreeStrifeConversations () +{ + FStrifeDialogueNode *node; + + while (StrifeDialogues.Pop (node)) + { + delete node; + } + + DialogueRoots.Clear(); + ClassRoots.Clear(); + + PrevNode = NULL; + if (DMenu::CurrentMenu != NULL && DMenu::CurrentMenu->IsKindOf(RUNTIME_CLASS(DConversationMenu))) + { + DMenu::CurrentMenu->Close(); + } +} + //============================================================================ // // P_StartConversation