Limits checking

This commit is contained in:
Jaime Passos 2019-12-18 18:59:47 -03:00
parent 74d69f3731
commit eadb3dec9e
1 changed files with 15 additions and 3 deletions

View File

@ -594,8 +594,13 @@ static void readfreeslots(MYFILE *f)
}
else if (fastcmp(type, "TOL"))
{
G_AddTOL(lastcustomtol, word);
lastcustomtol <<= 1;
if (lastcustomtol > 31)
CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n");
else
{
G_AddTOL((1<<lastcustomtol), word);
lastcustomtol++;
}
}
else
deh_warning("Freeslots: unknown enum class '%s' for '%s_%s'", type, type, word);
@ -1103,7 +1108,7 @@ static void readsprite2(MYFILE *f, INT32 num)
}
INT32 numtolinfo = NUMBASETOL;
UINT32 lastcustomtol = (TOL_XMAS << 1);
UINT32 lastcustomtol = 13;
tolinfo_t TYPEOFLEVEL[NUMMAXTOL] = {
{"SOLO",TOL_SP},
@ -1288,6 +1293,13 @@ static void readgametype(MYFILE *f, char *gtname)
if (word2lwr)
Z_Free(word2lwr);
// Ran out of gametype slots
if (gametypecount == NUMGAMETYPEFREESLOTS)
{
CONS_Alert(CONS_WARNING, "Ran out of free gametype slots!\n");
return;
}
// Add the new gametype
newgtidx = G_AddGametype(newgtrules);
G_AddGametypeTOL(newgtidx, newgttol);