SCUMM: Fix array overflow writing var when no current script is set

This situation is triggered normally when _currentScript is 0xFF,
but it could potentially also happen if _currentScript is some
other number >= NUM_SCRIPT_SLOT, so the check is a bit more
conservative than it might appear to need to be.
This commit is contained in:
Colin Snover 2017-11-29 18:42:30 -06:00
parent 2b5605362a
commit 4d3f05ae79

View file

@ -651,7 +651,7 @@ void ScummEngine::writeVar(uint var, int value) {
_scummVars[var] = value;
if ((_varwatch == (int)var) || (_varwatch == 0)) {
if ((_varwatch == (int)var || _varwatch == 0) && _currentScript < NUM_SCRIPT_SLOT) {
if (vm.slot[_currentScript].number < 100)
debug(1, "vars[%d] = %d (via script-%d)", var, value, vm.slot[_currentScript].number);
else