More state-related encapsulation

svn-id: r42144
This commit is contained in:
Sven Hesse 2009-07-05 19:56:40 +00:00
parent a7ab6c5e92
commit aeb020602a
4 changed files with 18 additions and 12 deletions

View File

@ -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);

View File

@ -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 {

View File

@ -1215,9 +1215,9 @@ bool Inter_v2::o2_freeCollision(OpFuncParams &params) {
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);

View File

@ -369,11 +369,11 @@ bool Inter_v6::o6_freeCollision(OpFuncParams &params) {
_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);