Verify sanity of location arrays
This commit is contained in:
parent
36f72f1902
commit
f0dc3d3b7c
1 changed files with 14 additions and 0 deletions
14
saveresume.c
14
saveresume.c
|
@ -144,7 +144,21 @@ bool is_valid(struct game_t valgame)
|
|||
valgame.oldloc < -1 || valgame.oldloc > NLOCATIONS) {
|
||||
return false;
|
||||
}
|
||||
/* Bounds check for location arrays
|
||||
*/
|
||||
for (int i = 0; i <= NDWARVES; i++) {
|
||||
if (valgame.dloc[i] < -1 || valgame.dloc[i] > NLOCATIONS ||
|
||||
valgame.odloc[i] < -1 || valgame.odloc[i] > NLOCATIONS) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i <= NOBJECTS; i++) {
|
||||
if (valgame.place[i] < -1 || valgame.place[i] > NLOCATIONS ||
|
||||
valgame.fixed[i] < -1 || valgame.fixed[i] > NLOCATIONS) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue