diff options
author | Walter van Niftrik | 2016-03-19 14:40:39 +0100 |
---|---|---|
committer | Walter van Niftrik | 2016-06-06 20:35:49 +0200 |
commit | 3102ff4a1951ca0a3ca6446f8b5bc67849fe3d73 (patch) | |
tree | d3eb194479b61321167418f2aad3e683d37bf32c /engines/adl | |
parent | 4ce697e2c38dd96eee13a793402d2946f89d856b (diff) | |
download | scummvm-rg350-3102ff4a1951ca0a3ca6446f8b5bc67849fe3d73.tar.gz scummvm-rg350-3102ff4a1951ca0a3ca6446f8b5bc67849fe3d73.tar.bz2 scummvm-rg350-3102ff4a1951ca0a3ca6446f8b5bc67849fe3d73.zip |
ADL: Clean up handling of room value 0xfc
Diffstat (limited to 'engines/adl')
-rw-r--r-- | engines/adl/adl.cpp | 14 | ||||
-rw-r--r-- | engines/adl/adl.h | 1 | ||||
-rw-r--r-- | engines/adl/adl_v2.cpp | 50 | ||||
-rw-r--r-- | engines/adl/adl_v2.h | 2 |
4 files changed, 24 insertions, 43 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index 9bd22f89c3..1f4ebcd4bb 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -347,6 +347,10 @@ bool AdlEngine::matchesCurrentPic(byte pic) const { return pic == getCurRoom().curPicture; } +byte AdlEngine::roomArg(byte room) const { + return room; +} + void AdlEngine::clearScreen() const { _display->setMode(DISPLAY_MODE_MIXED); _display->clear(0x00); @@ -857,7 +861,7 @@ void AdlEngine::getInput(uint &verb, uint &noun) { typedef Common::Functor1Mem<ScriptEnv &, int, AdlEngine> OpcodeV1; int AdlEngine::o1_isItemInRoom(ScriptEnv &e) { - if (getItem(e.arg(1)).room == e.arg(2)) + if (getItem(e.arg(1)).room == roomArg(e.arg(2))) return 2; return -1; } @@ -980,9 +984,11 @@ int AdlEngine::o1_quit(ScriptEnv &e) { } int AdlEngine::o1_placeItem(ScriptEnv &e) { - getItem(e.arg(1)).room = e.arg(2); - getItem(e.arg(1)).position.x = e.arg(3); - getItem(e.arg(1)).position.y = e.arg(4); + Item &item = getItem(e.arg(1)); + + item.room = roomArg(e.arg(2)); + item.position.x = e.arg(3); + item.position.y = e.arg(4); return 4; } diff --git a/engines/adl/adl.h b/engines/adl/adl.h index ea6a51c68a..595386cb29 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -176,6 +176,7 @@ protected: virtual void setupOpcodeTables(); virtual bool matchesCurrentPic(byte pic) const; + virtual byte roomArg(byte room) const; // Opcodes int o1_isItemInRoom(ScriptEnv &e); diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 3383a6307a..1a07d0e9ab 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -48,7 +48,7 @@ void AdlEngine_v2::setupOpcodeTables() { OpcodeUnImpl(); Opcode(o2_isFirstTime); Opcode(o2_isRandomGT); - Opcode(o2_isItemInRoom); + Opcode(o1_isItemInRoom); // 0x04 Opcode(o2_isNounNotInRoom); Opcode(o1_isMovesGT); @@ -104,6 +104,12 @@ bool AdlEngine_v2::matchesCurrentPic(byte pic) const { return pic == getCurRoom().curPicture || pic == IDI_ANY; } +byte AdlEngine_v2::roomArg(byte room) const { + if (room == IDI_CUR_ROOM) + return _state.room; + return room; +} + int AdlEngine_v2::o2_isFirstTime(ScriptEnv &e) { bool oldFlag = getCurRoom().isFirstTime; @@ -124,28 +130,11 @@ int AdlEngine_v2::o2_isRandomGT(ScriptEnv &e) { return -1; } -int AdlEngine_v2::o2_isItemInRoom(ScriptEnv &e) { - byte room = e.arg(2); - - if (room == IDI_CUR_ROOM) - room = _state.room; - - if (getItem(e.arg(1)).room == room) - return 2; - - return -1; -} - int AdlEngine_v2::o2_isNounNotInRoom(ScriptEnv &e) { Common::Array<Item>::const_iterator item; - byte room = e.arg(1); - - if (room == IDI_CUR_ROOM) - room = _state.room; - for (item = _state.items.begin(); item != _state.items.end(); ++item) - if (item->noun == e.getNoun() && (item->room == room)) + if (item->noun == e.getNoun() && (item->room == roomArg(e.arg(1)))) return -1; return 1; @@ -161,10 +150,7 @@ int AdlEngine_v2::o2_isCarryingSomething(ScriptEnv &e) { } int AdlEngine_v2::o2_moveItem(ScriptEnv &e) { - byte room = e.arg(2); - - if (room == IDI_CUR_ROOM) - room = _state.room; + byte room = roomArg(e.arg(2)); Item &item = getItem(e.arg(1)); @@ -177,15 +163,8 @@ int AdlEngine_v2::o2_moveItem(ScriptEnv &e) { } int AdlEngine_v2::o2_moveAllItems(ScriptEnv &e) { - byte room1 = e.arg(1); - - if (room1 == IDI_CUR_ROOM) - room1 = _state.room; - - byte room2 = e.arg(2); - - if (room2 == IDI_CUR_ROOM) - room2 = _state.room; + byte room1 = roomArg(e.arg(1)); + byte room2 = roomArg(e.arg(2)); Common::Array<Item>::iterator item; @@ -200,14 +179,9 @@ int AdlEngine_v2::o2_moveAllItems(ScriptEnv &e) { } int AdlEngine_v2::o2_placeItem(ScriptEnv &e) { - byte room = e.arg(2); - - if (room == IDI_CUR_ROOM) - room = _state.room; - Item &item = getItem(e.arg(1)); - item.room = room; + item.room = roomArg(e.arg(2)); item.position.x = e.arg(3); item.position.y = e.arg(4); item.state = IDI_ITEM_NOT_MOVED; diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index d6c18e19c3..e21c43c107 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -46,10 +46,10 @@ protected: virtual void setupOpcodeTables(); bool matchesCurrentPic(byte pic) const; + byte roomArg(byte room) const; int o2_isFirstTime(ScriptEnv &e); int o2_isRandomGT(ScriptEnv &e); - int o2_isItemInRoom(ScriptEnv &e); int o2_isNounNotInRoom(ScriptEnv &e); int o2_isCarryingSomething(ScriptEnv &e); int o2_moveAllItems(ScriptEnv &e); |