GLK: ADVSYS: Fix variable range checks

This commit is contained in:
Paul Gilbert 2019-06-15 15:47:32 -07:00
parent b6542b78fc
commit 1b6ac1a67c

View File

@ -250,12 +250,16 @@ int Game::getActionLocation(int action) const {
}
int Game::getVariable(int variableNum) {
assert(variableNum < _variableCount);
if (variableNum < 1 || variableNum > _variableCount)
error("Invalid ariable number %d", variableNum);
return READ_LE_UINT16(_variableTable + variableNum * 2);
}
void Game::setVariable(int variableNum, int value) {
assert(variableNum < _variableCount);
if (variableNum < 1 || variableNum > _variableCount)
error("Invalid ariable number %d", variableNum);
WRITE_LE_UINT16(_variableTable + variableNum * 2, value);
}