diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp index 9847ae2ae15..987b91ca598 100644 --- a/engines/gob/hotspots.cpp +++ b/engines/gob/hotspots.cpp @@ -93,10 +93,14 @@ uint8 Hotspots::Hotspot::getCursor() const { return (flags & 0xF000) >> 12; } -uint8 Hotspots::Hotspot::getState() const { +uint8 Hotspots::Hotspot::getState(uint16 id) { return (id & 0xF000) >> 12; } +uint8 Hotspots::Hotspot::getState() const { + return getState(id); +} + bool Hotspots::Hotspot::isEnd() const { return (left == 0xFFFF); } @@ -202,11 +206,11 @@ void Hotspots::remove(uint16 id) { } } -void Hotspots::removeState(uint16 state) { +void Hotspots::removeState(uint8 state) { for (int i = 0; i < kHotspotCount; i++) { Hotspot &spot = _hotspots[i]; - if ((spot.id & 0xF000) == state) + if (spot.getState() == state) spot.clear(); } } @@ -1449,7 +1453,7 @@ void Hotspots::evaluate() { if (VAR(16) != 0) break; - if ((id & 0xF000) == 0x8000) + if (Hotspot::getState(id) == 0x8) WRITE_VAR(16, array[id & 0xFFF]); else WRITE_VAR(16, id & 0xFFF); @@ -1532,7 +1536,7 @@ void Hotspots::evaluate() { _vm->_inter->storeMouse(); - if ((id & 0xF000) == 0x8000) + if (Hotspot::getState(id) == 0x8) WRITE_VAR(16, array[id & 0xFFF]); else WRITE_VAR(16, id & 0xFFF); @@ -1624,7 +1628,7 @@ void Hotspots::evaluate() { _vm->_inter->storeMouse(); if (VAR(16) == 0) { - if ((id & 0xF000) == 0x8000) + if (Hotspot::getState(id) == 0x8) WRITE_VAR(16, array[id & 0xFFF]); else WRITE_VAR(16, id & 0xFFF); diff --git a/engines/gob/hotspots.h b/engines/gob/hotspots.h index 6d37b4e4a5e..e05e37b296f 100644 --- a/engines/gob/hotspots.h +++ b/engines/gob/hotspots.h @@ -64,7 +64,7 @@ public: uint16 funcEnter, uint16 funcLeave, uint16 funcPos); void remove(uint16 id); - void removeState(uint16 state); + void removeState(uint8 state); /** Push the current hotspots onto the stack. * @@ -116,6 +116,8 @@ private: bool isIn(uint16 x, uint16 y) const; /** Does the specified button trigger the hotspot? */ bool buttonMatch(MouseButtons button) const; + + static uint8 getState(uint16 id); }; struct StackEntry { diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index d71a321db72..e82448c12cd 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1215,9 +1215,9 @@ bool Inter_v2::o2_freeCollision(OpFuncParams ¶ms) { int16 id = _vm->_game->_script->readValExpr(); if (id == -2) - _vm->_game->_hotspots->removeState(0xD000); + _vm->_game->_hotspots->removeState(0xD); else if (id == -1) - _vm->_game->_hotspots->removeState(0xE000); + _vm->_game->_hotspots->removeState(0xE); else _vm->_game->_hotspots->remove(0xE000 + id); diff --git a/engines/gob/inter_v6.cpp b/engines/gob/inter_v6.cpp index 3c71b3cd91e..15e2cc94812 100644 --- a/engines/gob/inter_v6.cpp +++ b/engines/gob/inter_v6.cpp @@ -369,11 +369,11 @@ bool Inter_v6::o6_freeCollision(OpFuncParams ¶ms) { _vm->_game->_hotspots->push(2); break; case 3: - _vm->_game->_hotspots->removeState(0xD000); - _vm->_game->_hotspots->removeState(0x4000); + _vm->_game->_hotspots->removeState(0xD); + _vm->_game->_hotspots->removeState(0x4); break; case 4: - _vm->_game->_hotspots->removeState(0xE000); + _vm->_game->_hotspots->removeState(0xE); break; default: _vm->_game->_hotspots->remove(0xE000 + id);