From 5fd87351a8468a2fe11737e9a75414d132169347 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 13 Jun 2016 22:52:20 +0100 Subject: [PATCH 1/4] Place precision of 4 on sprname string in the I_Error messages, so that you just get "PLAY" instead of "PLAYC2C8" or "PLAYA0" etc This is so custom character creators won't get confused by having two different frames shown in the same message anymore, bleh --- src/r_things.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index eaab53613..898be69af 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -280,7 +280,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, { case 0xff: // no rotations were found for that frame at all - I_Error("R_AddSingleSpriteDef: No patches found for %s frame %c", sprname, R_Frame2Char(frame)); + I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); break; case 0: @@ -293,7 +293,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, // we test the patch lump, or the id lump whatever // if it was not loaded the two are LUMPERROR if (sprtemp[frame].lumppat[rotation] == LUMPERROR) - I_Error("R_AddSingleSpriteDef: Sprite %s frame %c is missing rotations", + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", sprname, R_Frame2Char(frame)); break; } From 2b985bda857fabcd07710265cafdd68e9dabfd50 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 28 Jul 2016 14:57:19 +0100 Subject: [PATCH 2/4] Make sure we detect if start >= numlines so we can deal with that properly for some apparent reason the compiler didn't like the while loop condition edit on its own (it complained about inline failures for P_MobjReadyToTrigger for some reason), so I had to add that extra bit above the while loop... and it was happy again, huh --- src/p_spec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0bd530279..e11235d81 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1188,7 +1188,10 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start) { start++; - while (lines[start].special != special) + if (start >= (INT32)numlines) + return -1; + + while (start < (INT32)numlines && lines[start].special != special) start++; if (start >= (INT32)numlines) From 4c4f124611a98c66b929403aaaad0eb1a8f63018 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 28 Jul 2016 16:07:26 +0100 Subject: [PATCH 3/4] Detect if -warp's parm is actually a valid map name (MAPxx or plain number), and print an "invalid map name" message if not --- src/d_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 14a8a06e1..b61ec4143 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1060,10 +1060,11 @@ void D_SRB2Main(void) if (M_CheckParm("-warp") && M_IsNextParm()) { const char *word = M_GetNextParm(); - if (fastncmp(word, "MAP", 3)) + char ch; // use this with sscanf to catch non-digits with + if (fastncmp(word, "MAP", 3)) // MAPxx name pstartmap = M_MapNumber(word[3], word[4]); - else - pstartmap = atoi(word); + else if (sscanf(word, "%d%c", &pstartmap, &ch) != 1) // a plain number + I_Error("Cannot warp to map %s (invalid map name)\n", word); // Don't check if lump exists just yet because the wads haven't been loaded! // Just do a basic range check here. if (pstartmap < 1 || pstartmap > NUMMAPS) From 02d3382408adaa81bc68af99c5699747f345014b Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sun, 7 Aug 2016 12:17:31 -0500 Subject: [PATCH 4/4] Leave a note to anyone foolish enough to try to fix this --- src/p_spec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index e11235d81..30b08ebb1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1188,6 +1188,8 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start) { start++; + // This redundant check stops the compiler from complaining about function expansion + // elsewhere for some reason and everything is awful if (start >= (INT32)numlines) return -1;