From 6671e181b07c4175ef5139bbc48399c23d4d4ff3 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 3 Dec 2022 11:40:58 +0000 Subject: [PATCH] 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 --- src/deh_soc.c | 24 ++++++++++++------------ src/dehacked.c | 2 +- src/k_menufunc.c | 2 +- src/m_cond.c | 22 +++++++++++----------- src/m_cond.h | 4 ++-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index 5c01f5d43..e5a5ca41b 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -165,7 +165,7 @@ void clear_conditionsets(void) { UINT8 i; for (i = 0; i < MAXCONDITIONSETS; ++i) - M_ClearConditionSet(i+1); + M_ClearConditionSet(i); } void clear_levels(void) @@ -2415,7 +2415,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) 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; } @@ -2435,7 +2435,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) 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; } } @@ -2459,7 +2459,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) 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; } } @@ -2472,7 +2472,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) 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; } } @@ -2485,7 +2485,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) // constrained by 32 bits 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; } } @@ -2503,7 +2503,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) 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; } } @@ -2515,7 +2515,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) 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; } } @@ -2527,13 +2527,13 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) 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; } } 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; } @@ -2586,13 +2586,13 @@ void readconditionset(MYFILE *f, UINT8 setnum) id = (UINT8)atoi(word + 9); 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; } else if (previd > id) { // 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; } previd = id; diff --git a/src/dehacked.c b/src/dehacked.c index 1e400a1fa..cc8ecc58e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -479,7 +479,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) ignorelines(f); } else if (i > 0 && i <= MAXCONDITIONSETS) - readconditionset(f, (UINT8)i); + readconditionset(f, (UINT8)(i-1)); else { deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 013d00dcc..194c4cc1e 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -7017,7 +7017,7 @@ boolean M_ChallengesInputs(INT32 ch) challengesmenu.extradata = M_ChallengeGridExtraData(); challengesmenu.unlockanim = 0; - if (challengesmenu.currentunlock != MAXUNLOCKABLES) + if (challengesmenu.currentunlock < MAXUNLOCKABLES) { for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++) { diff --git a/src/m_cond.c b/src/m_cond.c index 8b4c8e5e6..c05a6a169 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -191,7 +191,7 @@ quickcheckagain: // Space out empty entries to pepper into unlock list for (i = 0; i < gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT; i++) { - if (gamedata->challengegrid[i] != MAXUNLOCKABLES) + if (gamedata->challengegrid[i] < MAXUNLOCKABLES) { continue; } @@ -215,7 +215,7 @@ quickcheckagain: // Fill the remaining spots with random ordinary unlocks (and empties). for (i = 0; i < gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT; i++) { - if (gamedata->challengegrid[i] != MAXUNLOCKABLES) + if (gamedata->challengegrid[i] < MAXUNLOCKABLES) { continue; } @@ -405,12 +405,12 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1 I_Assert(set && set <= MAXCONDITIONSETS); - wnum = conditionSets[set - 1].numconditions; - num = ++conditionSets[set - 1].numconditions; + wnum = conditionSets[set].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].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) { - if (conditionSets[set - 1].numconditions) + if (conditionSets[set].numconditions) { - Z_Free(conditionSets[set - 1].condition); - conditionSets[set - 1].condition = NULL; - conditionSets[set - 1].numconditions = 0; + Z_Free(conditionSets[set].condition); + conditionSets[set].condition = NULL; + conditionSets[set].numconditions = 0; } - gamedata->achieved[set - 1] = false; + gamedata->achieved[set] = false; } // Clear ALL secrets. diff --git a/src/m_cond.h b/src/m_cond.h index 2d701ec56..fec228f10 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -123,10 +123,10 @@ typedef struct // If you have more secrets than these variables allow in your game, // you seriously need to get a life. -#define MAXCONDITIONSETS 128 +#define MAXCONDITIONSETS UINT8_MAX #define MAXEMBLEMS 512 #define MAXEXTRAEMBLEMS 16 -#define MAXUNLOCKABLES 32 +#define MAXUNLOCKABLES (MAXCONDITIONSETS-MAXEXTRAEMBLEMS) #define CHALLENGEGRIDHEIGHT 5