Provide helpful warning for too-large id counts for ConditionSet Condition# lines

This commit is contained in:
toaster 2023-06-28 12:17:41 +01:00
parent e2669dba0c
commit a933e7a084

View file

@ -2865,7 +2865,7 @@ void readconditionset(MYFILE *f, UINT16 setnum)
char *word = s;
char *word2;
char *tmp;
UINT8 id;
UINT16 id;
UINT8 previd = 0;
M_ClearConditionSet(setnum);
@ -2902,21 +2902,26 @@ void readconditionset(MYFILE *f, UINT16 setnum)
if (fastncmp(word, "CONDITION", 9))
{
id = (UINT8)atoi(word + 9);
id = atoi(word + 9);
if (id == 0)
{
deh_warning("Condition set %d: unknown word '%s'", setnum+1, word);
continue;
}
else if (previd > id)
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+1);
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
deh_warning("Condition set %d: unknown word '%s'", setnum, word);