Merge branch 'fixconditionsets' into 'master'

Conditionset is UINT16, not UINT8

See merge request KartKrew/Kart!1302
This commit is contained in:
toaster 2023-06-28 11:47:59 +00:00
commit 3b169c71dc
3 changed files with 14 additions and 9 deletions

View file

@ -2393,7 +2393,7 @@ void readunlockable(MYFILE *f, INT32 num)
Z_Free(s); Z_Free(s);
} }
static void readcondition(UINT8 set, UINT32 id, char *word2) static void readcondition(UINT16 set, UINT32 id, char *word2)
{ {
INT32 i; INT32 i;
char *params[5]; // condition, requirement, extra info, extra info, stringvar char *params[5]; // condition, requirement, extra info, extra info, stringvar
@ -2860,13 +2860,13 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
M_AddRawCondition(set, (UINT8)id, ty, re, x1, x2, stringvar); M_AddRawCondition(set, (UINT8)id, ty, re, x1, x2, stringvar);
} }
void readconditionset(MYFILE *f, UINT8 setnum) void readconditionset(MYFILE *f, UINT16 setnum)
{ {
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
char *word = s; char *word = s;
char *word2; char *word2;
char *tmp; char *tmp;
UINT8 id; UINT16 id;
UINT8 previd = 0; UINT8 previd = 0;
M_ClearConditionSet(setnum); M_ClearConditionSet(setnum);
@ -2903,21 +2903,26 @@ void readconditionset(MYFILE *f, UINT8 setnum)
if (fastncmp(word, "CONDITION", 9)) if (fastncmp(word, "CONDITION", 9))
{ {
id = (UINT8)atoi(word + 9); id = atoi(word + 9);
if (id == 0) if (id == 0)
{ {
deh_warning("Condition set %d: unknown word '%s'", setnum+1, word); deh_warning("Condition set %d: unknown word '%s'", setnum+1, word);
continue; continue;
} }
else if (previd > id) 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+1); deh_warning("Condition set %d: conditions are out of order, ignoring this line", setnum+1);
continue; continue;
} }
previd = id; if (id > UINT8_MAX)
{
deh_warning("Condition set %d: too many Condition# types, ignoring this line", setnum+1);
continue;
}
previd = (UINT8)id;
readcondition(setnum, id, word2); readcondition(setnum, (UINT8)id, word2);
} }
else else
deh_warning("Condition set %d: unknown word '%s'", setnum, word); deh_warning("Condition set %d: unknown word '%s'", setnum, word);

View file

@ -62,7 +62,7 @@ skincolornum_t get_skincolor(const char *word);
void readwipes(MYFILE *f); void readwipes(MYFILE *f);
void readmaincfg(MYFILE *f, boolean mainfile); void readmaincfg(MYFILE *f, boolean mainfile);
void readconditionset(MYFILE *f, UINT8 setnum); void readconditionset(MYFILE *f, UINT16 setnum);
void readunlockable(MYFILE *f, INT32 num); void readunlockable(MYFILE *f, INT32 num);
void reademblemdata(MYFILE *f, INT32 num); void reademblemdata(MYFILE *f, INT32 num);
void readsound(MYFILE *f, INT32 num); void readsound(MYFILE *f, INT32 num);

View file

@ -453,7 +453,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-1)); readconditionset(f, (UINT16)(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);