Increase unlockable/conditionset limits

- MAXCONDITIONSETS is UINT8_MAX
- MAXUNLOCKABLES is (MAXCONDITIONSETS-MAXEXTRAEMBLEMS)
Haven't come to a decision yet on whether Extra Emblems should just be made with the Unlockable struct or maintain their distinct status, this commit kicks that can down the road
This commit is contained in:
toaster 2022-12-03 11:40:58 +00:00
parent 9df1f1d34c
commit 6671e181b0
5 changed files with 27 additions and 27 deletions

View file

@ -165,7 +165,7 @@ void clear_conditionsets(void)
{ {
UINT8 i; UINT8 i;
for (i = 0; i < MAXCONDITIONSETS; ++i) for (i = 0; i < MAXCONDITIONSETS; ++i)
M_ClearConditionSet(i+1); M_ClearConditionSet(i);
} }
void clear_levels(void) void clear_levels(void)
@ -2415,7 +2415,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
if (!params[0]) if (!params[0])
{ {
deh_warning("condition line is empty for condition ID %d", id); deh_warning("condition line is empty for condition ID %d", id+1);
return; return;
} }
@ -2435,7 +2435,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
if (x1 < 0 || x1 >= PWRLV_NUMTYPES) if (x1 < 0 || x1 >= PWRLV_NUMTYPES)
{ {
deh_warning("Power level type %d out of range (0 - %d) for condition ID %d", x1, PWRLV_NUMTYPES-1, id); deh_warning("Power level type %d out of range (0 - %d) for condition ID %d", x1, PWRLV_NUMTYPES-1, id+1);
return; return;
} }
} }
@ -2459,7 +2459,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
if (re >= nummapheaders) if (re >= nummapheaders)
{ {
deh_warning("Invalid level %s for condition ID %d", params[1], id); deh_warning("Invalid level %s for condition ID %d", params[1], id+1);
return; return;
} }
} }
@ -2472,7 +2472,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
if (x1 >= nummapheaders) if (x1 >= nummapheaders)
{ {
deh_warning("Invalid level %s for condition ID %d", params[1], id); deh_warning("Invalid level %s for condition ID %d", params[1], id+1);
return; return;
} }
} }
@ -2485,7 +2485,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
// constrained by 32 bits // constrained by 32 bits
if (re < 0 || re > 31) if (re < 0 || re > 31)
{ {
deh_warning("Trigger ID %d out of range (0 - 31) for condition ID %d", re, id); deh_warning("Trigger ID %d out of range (0 - 31) for condition ID %d", re, id+1);
return; return;
} }
} }
@ -2503,7 +2503,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
if (re <= 0 || re > MAXEMBLEMS) if (re <= 0 || re > MAXEMBLEMS)
{ {
deh_warning("Emblem %d out of range (1 - %d) for condition ID %d", re, MAXEMBLEMS, id); deh_warning("Emblem %d out of range (1 - %d) for condition ID %d", re, MAXEMBLEMS, id+1);
return; return;
} }
} }
@ -2515,7 +2515,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
if (re <= 0 || re > MAXEXTRAEMBLEMS) if (re <= 0 || re > MAXEXTRAEMBLEMS)
{ {
deh_warning("Extra emblem %d out of range (1 - %d) for condition ID %d", re, MAXEXTRAEMBLEMS, id); deh_warning("Extra emblem %d out of range (1 - %d) for condition ID %d", re, MAXEXTRAEMBLEMS, id+1);
return; return;
} }
} }
@ -2527,13 +2527,13 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
if (re <= 0 || re > MAXCONDITIONSETS) if (re <= 0 || re > MAXCONDITIONSETS)
{ {
deh_warning("Condition set %d out of range (1 - %d) for condition ID %d", re, MAXCONDITIONSETS, id); deh_warning("Condition set %d out of range (1 - %d) for condition ID %d", re, MAXCONDITIONSETS, id+1);
return; return;
} }
} }
else else
{ {
deh_warning("Invalid condition name %s for condition ID %d", params[0], id); deh_warning("Invalid condition name %s for condition ID %d", params[0], id+1);
return; return;
} }
@ -2586,13 +2586,13 @@ void readconditionset(MYFILE *f, UINT8 setnum)
id = (UINT8)atoi(word + 9); id = (UINT8)atoi(word + 9);
if (id == 0) if (id == 0)
{ {
deh_warning("Condition set %d: unknown word '%s'", setnum, word); deh_warning("Condition set %d: unknown word '%s'", setnum+1, word);
continue; continue;
} }
else if (previd > id) else if (previd > id)
{ {
// out of order conditions can cause problems, so enforce proper order // out of order conditions can cause problems, so enforce proper order
deh_warning("Condition set %d: conditions are out of order, ignoring this line", setnum); deh_warning("Condition set %d: conditions are out of order, ignoring this line", setnum+1);
continue; continue;
} }
previd = id; previd = id;

View file

@ -479,7 +479,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
ignorelines(f); ignorelines(f);
} }
else if (i > 0 && i <= MAXCONDITIONSETS) else if (i > 0 && i <= MAXCONDITIONSETS)
readconditionset(f, (UINT8)i); readconditionset(f, (UINT8)(i-1));
else else
{ {
deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS); deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS);

View file

@ -7017,7 +7017,7 @@ boolean M_ChallengesInputs(INT32 ch)
challengesmenu.extradata = M_ChallengeGridExtraData(); challengesmenu.extradata = M_ChallengeGridExtraData();
challengesmenu.unlockanim = 0; challengesmenu.unlockanim = 0;
if (challengesmenu.currentunlock != MAXUNLOCKABLES) if (challengesmenu.currentunlock < MAXUNLOCKABLES)
{ {
for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++) for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++)
{ {

View file

@ -191,7 +191,7 @@ quickcheckagain:
// Space out empty entries to pepper into unlock list // Space out empty entries to pepper into unlock list
for (i = 0; i < gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT; i++) for (i = 0; i < gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT; i++)
{ {
if (gamedata->challengegrid[i] != MAXUNLOCKABLES) if (gamedata->challengegrid[i] < MAXUNLOCKABLES)
{ {
continue; continue;
} }
@ -215,7 +215,7 @@ quickcheckagain:
// Fill the remaining spots with random ordinary unlocks (and empties). // Fill the remaining spots with random ordinary unlocks (and empties).
for (i = 0; i < gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT; i++) for (i = 0; i < gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT; i++)
{ {
if (gamedata->challengegrid[i] != MAXUNLOCKABLES) if (gamedata->challengegrid[i] < MAXUNLOCKABLES)
{ {
continue; continue;
} }
@ -405,12 +405,12 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
I_Assert(set && set <= MAXCONDITIONSETS); I_Assert(set && set <= MAXCONDITIONSETS);
wnum = conditionSets[set - 1].numconditions; wnum = conditionSets[set].numconditions;
num = ++conditionSets[set - 1].numconditions; num = ++conditionSets[set].numconditions;
conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0); conditionSets[set].condition = Z_Realloc(conditionSets[set].condition, sizeof(condition_t)*num, PU_STATIC, 0);
cond = conditionSets[set - 1].condition; cond = conditionSets[set].condition;
cond[wnum].id = id; cond[wnum].id = id;
cond[wnum].type = c; cond[wnum].type = c;
@ -421,13 +421,13 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
void M_ClearConditionSet(UINT8 set) void M_ClearConditionSet(UINT8 set)
{ {
if (conditionSets[set - 1].numconditions) if (conditionSets[set].numconditions)
{ {
Z_Free(conditionSets[set - 1].condition); Z_Free(conditionSets[set].condition);
conditionSets[set - 1].condition = NULL; conditionSets[set].condition = NULL;
conditionSets[set - 1].numconditions = 0; conditionSets[set].numconditions = 0;
} }
gamedata->achieved[set - 1] = false; gamedata->achieved[set] = false;
} }
// Clear ALL secrets. // Clear ALL secrets.

View file

@ -123,10 +123,10 @@ typedef struct
// If you have more secrets than these variables allow in your game, // If you have more secrets than these variables allow in your game,
// you seriously need to get a life. // you seriously need to get a life.
#define MAXCONDITIONSETS 128 #define MAXCONDITIONSETS UINT8_MAX
#define MAXEMBLEMS 512 #define MAXEMBLEMS 512
#define MAXEXTRAEMBLEMS 16 #define MAXEXTRAEMBLEMS 16
#define MAXUNLOCKABLES 32 #define MAXUNLOCKABLES (MAXCONDITIONSETS-MAXEXTRAEMBLEMS)
#define CHALLENGEGRIDHEIGHT 5 #define CHALLENGEGRIDHEIGHT 5