From bb494292c65add5fe6c47db01161889a4641bd8c Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Thu, 8 Aug 2013 23:47:58 -0400 Subject: [PATCH 1/2] - Fixed P_CheckMapData allowed non-map lump names to pass resulting in a crash when actually trying to load the map. --- src/c_cmds.cpp | 29 +++++++++++++++++++---------- src/g_level.cpp | 17 +++++++++++++---- src/p_setup.cpp | 20 ++++++++++++++++++-- 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 5bde4c5060..cdf615ef49 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -51,6 +51,7 @@ #include "i_system.h" +#include "doomerrors.h" #include "doomstat.h" #include "gstrings.h" #include "s_sound.h" @@ -343,22 +344,30 @@ CCMD (changemap) if (argv.argc() > 1) { - if (!P_CheckMapData(argv[1])) + try { - Printf ("No map %s\n", argv[1]); - } - else - { - if (argv.argc() > 2) + if (!P_CheckMapData(argv[1])) { - Net_WriteByte (DEM_CHANGEMAP2); - Net_WriteByte (atoi(argv[2])); + Printf ("No map %s\n", argv[1]); } else { - Net_WriteByte (DEM_CHANGEMAP); + if (argv.argc() > 2) + { + Net_WriteByte (DEM_CHANGEMAP2); + Net_WriteByte (atoi(argv[2])); + } + else + { + Net_WriteByte (DEM_CHANGEMAP); + } + Net_WriteString (argv[1]); } - Net_WriteString (argv[1]); + } + catch(CRecoverableError &error) + { + if (error.GetMessage()) + Printf("%s", error.GetMessage()); } } else diff --git a/src/g_level.cpp b/src/g_level.cpp index a452d55767..7e56d8843d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -40,6 +40,7 @@ #include "s_sound.h" #include "d_event.h" #include "m_random.h" +#include "doomerrors.h" #include "doomstat.h" #include "wi_stuff.h" #include "w_wad.h" @@ -170,13 +171,21 @@ CCMD (map) } if (argv.argc() > 1) { - if (!P_CheckMapData(argv[1])) + try { - Printf ("No map %s\n", argv[1]); + if (!P_CheckMapData(argv[1])) + { + Printf ("No map %s\n", argv[1]); + } + else + { + G_DeferedInitNew (argv[1]); + } } - else + catch(CRecoverableError &error) { - G_DeferedInitNew (argv[1]); + if (error.GetMessage()) + Printf("%s", error.GetMessage()); } } else diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 0f6917f8df..2535641a59 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -329,7 +329,15 @@ MapData *P_OpenMapData(const char * mapname) // Since levels must be stored in WADs they can't really have full // names and for any valid level lump this always returns the short name. const char * lumpname = Wads.GetLumpFullName(lump_name + i); - index = GetMapIndex(mapname, index, lumpname, i != 1 || Wads.LumpLength(lump_name + i) == 0); + try + { + index = GetMapIndex(mapname, index, lumpname, true); + } + catch(...) + { + delete map; + throw; + } if (index == ML_BEHAVIOR) map->HasBehavior = true; // The next lump is not part of this map anymore @@ -461,7 +469,15 @@ MapData *P_OpenMapData(const char * mapname) if (i>0) { - index = GetMapIndex(maplabel, index, lumpname, true); + try + { + index = GetMapIndex(maplabel, index, lumpname, true); + } + catch(...) + { + delete map; + throw; + } if (index == ML_BEHAVIOR) map->HasBehavior = true; // The next lump is not part of this map anymore From 7e76fb0078aaee16d4a1821de84e3098e0cb8645 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Fri, 9 Aug 2013 00:25:29 -0400 Subject: [PATCH 2/2] - Fixed: Disable ifitem jumping if a link isn't specified since an invalid value can cause a crash. --- src/p_conversation.cpp | 2 +- src/p_usdf.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index d567f98666..350c464789 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1152,7 +1152,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang break; } } - if (jump) + if (jump && CurNode->ItemCheckNode > 0) { int root = pc->player->ConversationNPC->ConversationRoot; CurNode = StrifeDialogues[root + CurNode->ItemCheckNode - 1]; diff --git a/src/p_usdf.cpp b/src/p_usdf.cpp index dc287384d1..95c8f5dc04 100644 --- a/src/p_usdf.cpp +++ b/src/p_usdf.cpp @@ -288,6 +288,7 @@ class USDFParser : public UDMFParserBase //node->ItemCheckCount[0] = node->ItemCheckCount[1] = node->ItemCheckCount[2] = -1; node->ThisNodeNum = StrifeDialogues.Push(node); + node->ItemCheckNode = -1; FString SpeakerName; FString Dialogue;