Bounds check for properties; it is not violated in normal game
This commit is contained in:
parent
f496bff945
commit
98b21323a6
1 changed files with 27 additions and 0 deletions
27
saveresume.c
27
saveresume.c
|
@ -184,6 +184,33 @@ bool is_valid(struct game_t valgame)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Check that properties of objects aren't beyond expected */
|
||||
for (int obj = 0; obj <= NOBJECTS; obj++) {
|
||||
if (game.prop[obj] < STATE_NOTFOUND || game.prop[obj] > 1) {
|
||||
switch (obj) {
|
||||
case RUG:
|
||||
case DRAGON:
|
||||
case BIRD:
|
||||
case BOTTLE:
|
||||
case PLANT:
|
||||
case PLANT2:
|
||||
case TROLL:
|
||||
case URN:
|
||||
case EGGS:
|
||||
case VASE:
|
||||
case CHAIN:
|
||||
if (game.prop[obj] == 2) // There are multiple different states, but it's convenient to clump them together
|
||||
continue;
|
||||
case BEAR:
|
||||
if (game.prop[BEAR] == CONTENTED_BEAR || game.prop[BEAR] == BEAR_DEAD)
|
||||
continue;
|
||||
default:
|
||||
printf("%i", obj);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue