From f5a46bd70fd6403188236c793ecbfa025c6a75e4 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sun, 9 Feb 2020 16:11:52 -0300 Subject: [PATCH 1/3] Don't add a TOL_ twice. --- src/dehacked.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 45f00b8cf..1c4be1d03 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -585,17 +585,26 @@ static void readfreeslots(MYFILE *f) continue; // Copy in the spr2 name and increment free_spr2. if (free_spr2 < NUMPLAYERSPRITES) { - CONS_Printf("Sprite SPR2_%s allocated.\n",word); strncpy(spr2names[free_spr2],word,4); spr2defaults[free_spr2] = 0; spr2names[free_spr2++][4] = 0; } else - CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); + deh_warning("Ran out of free SPR2 slots!\n"); } else if (fastcmp(type, "TOL")) { - if (lastcustomtol > 31) - CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); + // Search if we already have a typeoflevel by that name... + for (i = 0; i < numtolinfo; i++) + if (fastcmp(word, TYPEOFLEVEL[i].name)) + break; + + // We found it? Then don't allocate another one. + if (i < numtolinfo) + continue; + + // We don't, so freeslot it. + if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + deh_warning("Ran out of free typeoflevel slots!\n"); else { G_AddTOL((1< 31) - CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); - else - { - UINT32 newtol = (1<= numtolinfo) { + if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); + else { + UINT32 newtol = (1< Date: Wed, 12 Feb 2020 13:41:30 -0300 Subject: [PATCH 2/3] Add MAXTOL --- src/dehacked.c | 56 +++++++++++--------------------------------------- src/doomstat.h | 9 ++++---- src/g_game.c | 42 +++++++++++++++++++++++++++++++------ 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 958eaad32..79d0b46dd 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -594,21 +594,21 @@ static void readfreeslots(MYFILE *f) else if (fastcmp(type, "TOL")) { // Search if we already have a typeoflevel by that name... - for (i = 0; i < numtolinfo; i++) + for (i = 0; TYPEOFLEVEL[i].name; i++) if (fastcmp(word, TYPEOFLEVEL[i].name)) break; // We found it? Then don't allocate another one. - if (i < numtolinfo) + if (TYPEOFLEVEL[i].name) continue; // We don't, so freeslot it. - if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. deh_warning("Ran out of free typeoflevel slots!\n"); else { - G_AddTOL((1<= numtolinfo) { - if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + if (TYPEOFLEVEL[i].name == NULL) { + if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); else { - UINT32 newtol = (1< Date: Wed, 12 Feb 2020 13:59:08 -0300 Subject: [PATCH 3/3] Cast Moment --- src/dehacked.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 79d0b46dd..4d1147276 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -603,7 +603,7 @@ static void readfreeslots(MYFILE *f) continue; // We don't, so freeslot it. - if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. + if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. deh_warning("Ran out of free typeoflevel slots!\n"); else { @@ -10454,7 +10454,7 @@ static inline int lib_freeslot(lua_State *L) // We don't, so allocate a new one. if (TYPEOFLEVEL[i].name == NULL) { - if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. + if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); else { CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word);