aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWalter van Niftrik2016-12-16 18:27:24 +0100
committerWalter van Niftrik2016-12-16 18:27:24 +0100
commit5f46bbff728025aedc7d4d6c83b23c3a59912e96 (patch)
treeca7721f8b06586cad1daa70cf4f1bf449fdde6d7 /engines
parent1f801bee433624e8bde214264a2d0c2359be4c13 (diff)
downloadscummvm-rg350-5f46bbff728025aedc7d4d6c83b23c3a59912e96.tar.gz
scummvm-rg350-5f46bbff728025aedc7d4d6c83b23c3a59912e96.tar.bz2
scummvm-rg350-5f46bbff728025aedc7d4d6c83b23c3a59912e96.zip
ADL: Add item region checks
Diffstat (limited to 'engines')
-rw-r--r--engines/adl/adl.cpp43
-rw-r--r--engines/adl/adl_v2.cpp68
-rw-r--r--engines/adl/adl_v2.h1
-rw-r--r--engines/adl/adl_v4.cpp52
-rw-r--r--engines/adl/adl_v4.h3
5 files changed, 55 insertions, 112 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 0d96cb67af..e3cd929b6d 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -510,26 +510,25 @@ void AdlEngine::takeItem(byte noun) {
Common::List<Item>::iterator item;
for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun != noun || item->room != _state.room)
- continue;
-
- if (item->state == IDI_ITEM_DOESNT_MOVE) {
- printMessage(_messageIds.itemDoesntMove);
- return;
- }
-
- if (item->state == IDI_ITEM_DROPPED) {
- item->room = IDI_ANY;
- return;
- }
+ if (item->noun == noun && item->room == _state.room && item->region == _state.region) {
+ if (item->state == IDI_ITEM_DOESNT_MOVE) {
+ printMessage(_messageIds.itemDoesntMove);
+ return;
+ }
- Common::Array<byte>::const_iterator pic;
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture) {
+ if (item->state == IDI_ITEM_DROPPED) {
item->room = IDI_ANY;
- item->state = IDI_ITEM_DROPPED;
return;
}
+
+ Common::Array<byte>::const_iterator pic;
+ for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
+ if (*pic == getCurRoom().curPicture) {
+ item->room = IDI_ANY;
+ item->state = IDI_ITEM_DROPPED;
+ return;
+ }
+ }
}
}
@@ -540,12 +539,12 @@ void AdlEngine::dropItem(byte noun) {
Common::List<Item>::iterator item;
for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun != noun || item->room != IDI_ANY)
- continue;
-
- item->room = _state.room;
- item->state = IDI_ITEM_DROPPED;
- return;
+ if (item->noun == noun && item->room == IDI_ANY) {
+ item->room = _state.room;
+ item->region = _state.region;
+ item->state = IDI_ITEM_DROPPED;
+ return;
+ }
}
printMessage(_messageIds.dontUnderstand);
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp
index b34d4c9a06..46bd6aa4d3 100644
--- a/engines/adl/adl_v2.cpp
+++ b/engines/adl/adl_v2.cpp
@@ -286,32 +286,34 @@ void AdlEngine_v2::showRoom() {
_linesPrinted = 0;
}
+// TODO: Merge this into AdlEngine?
void AdlEngine_v2::takeItem(byte noun) {
Common::List<Item>::iterator item;
for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun != noun || item->room != _state.room)
- continue;
-
- if (item->state == IDI_ITEM_DOESNT_MOVE) {
- printMessage(_messageIds.itemDoesntMove);
- return;
- }
-
- if (item->state == IDI_ITEM_DROPPED) {
- item->room = IDI_ANY;
- _itemRemoved = true;
- return;
- }
+ if (item->noun == noun && item->room == _state.room && item->region == _state.region) {
+ if (item->state == IDI_ITEM_DOESNT_MOVE) {
+ printMessage(_messageIds.itemDoesntMove);
+ return;
+ }
- Common::Array<byte>::const_iterator pic;
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture || *pic == IDI_ANY) {
+ if (item->state == IDI_ITEM_DROPPED) {
item->room = IDI_ANY;
_itemRemoved = true;
- item->state = IDI_ITEM_DROPPED;
return;
}
+
+ Common::Array<byte>::const_iterator pic;
+ for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
+ if (*pic == getCurRoom().curPicture || *pic == IDI_ANY) {
+ if (!isInventoryFull()) {
+ item->room = IDI_ANY;
+ _itemRemoved = true;
+ item->state = IDI_ITEM_DROPPED;
+ }
+ return;
+ }
+ }
}
}
@@ -323,24 +325,20 @@ void AdlEngine_v2::drawItems() {
for (item = _state.items.begin(); item != _state.items.end(); ++item) {
// Skip items not in this room
- if (item->room != _state.room)
- continue;
-
- if (item->isOnScreen)
- continue;
-
- if (item->state == IDI_ITEM_DROPPED) {
- // Draw dropped item if in normal view
- if (getCurRoom().picture == getCurRoom().curPicture)
- drawItem(*item, _itemOffsets[_itemsOnScreen++]);
- } else {
- // Draw fixed item if current view is in the pic list
- Common::Array<byte>::const_iterator pic;
-
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == _state.curPicture || *pic == IDI_ANY) {
- drawItem(*item, item->position);
- break;
+ if (item->region == _state.region && item->room == _state.room && !item->isOnScreen) {
+ if (item->state == IDI_ITEM_DROPPED) {
+ // Draw dropped item if in normal view
+ if (getCurRoom().picture == getCurRoom().curPicture)
+ drawItem(*item, _itemOffsets[_itemsOnScreen++]);
+ } else {
+ // Draw fixed item if current view is in the pic list
+ Common::Array<byte>::const_iterator pic;
+
+ for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
+ if (*pic == _state.curPicture || *pic == IDI_ANY) {
+ drawItem(*item, item->position);
+ break;
+ }
}
}
}
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h
index 8f36b5cdb8..fe0c781f44 100644
--- a/engines/adl/adl_v2.h
+++ b/engines/adl/adl_v2.h
@@ -58,6 +58,7 @@ protected:
void loadMessages(Common::ReadStream &stream, byte count);
void loadPictures(Common::ReadStream &stream);
void loadItemPictures(Common::ReadStream &stream, byte count);
+ virtual bool isInventoryFull() { return false; }
void checkTextOverflow(char c);
diff --git a/engines/adl/adl_v4.cpp b/engines/adl/adl_v4.cpp
index 6dfee8084a..8b72923e8b 100644
--- a/engines/adl/adl_v4.cpp
+++ b/engines/adl/adl_v4.cpp
@@ -266,58 +266,6 @@ void AdlEngine_v4::switchRegion(byte region) {
_picOnScreen = _roomOnScreen = 0;
}
-// TODO: Merge this into v2?
-void AdlEngine_v4::takeItem(byte noun) {
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun != noun || item->room != _state.room || item->region != _state.region)
- continue;
-
- if (item->state == IDI_ITEM_DOESNT_MOVE) {
- printMessage(_messageIds.itemDoesntMove);
- return;
- }
-
- if (item->state == IDI_ITEM_DROPPED) {
- item->room = IDI_ANY;
- _itemRemoved = true;
- return;
- }
-
- Common::Array<byte>::const_iterator pic;
- for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) {
- if (*pic == getCurRoom().curPicture || *pic == IDI_ANY) {
- if (!isInventoryFull()) {
- item->room = IDI_ANY;
- _itemRemoved = true;
- item->state = IDI_ITEM_DROPPED;
- }
- return;
- }
- }
- }
-
- printMessage(_messageIds.itemNotHere);
-}
-
-// TODO: Merge this into v2?
-void AdlEngine_v4::dropItem(byte noun) {
- Common::List<Item>::iterator item;
-
- for (item = _state.items.begin(); item != _state.items.end(); ++item) {
- if (item->noun != noun || item->room != IDI_ANY)
- continue;
-
- item->room = _state.room;
- item->region = _state.region;
- item->state = IDI_ITEM_DROPPED;
- return;
- }
-
- printMessage(_messageIds.dontUnderstand);
-}
-
int AdlEngine_v4::o4_isItemInRoom(ScriptEnv &e) {
OP_DEBUG_2("\t&& GET_ITEM_ROOM(%s) == %s", itemStr(e.arg(1)).c_str(), itemRoomStr(e.arg(2)).c_str());
diff --git a/engines/adl/adl_v4.h b/engines/adl/adl_v4.h
index 8516e40bd2..1bc7664d58 100644
--- a/engines/adl/adl_v4.h
+++ b/engines/adl/adl_v4.h
@@ -68,9 +68,6 @@ protected:
void backupVars();
void restoreVars();
void switchRegion(byte region);
- virtual bool isInventoryFull() { return false; }
- virtual void takeItem(byte noun);
- virtual void dropItem(byte noun);
int o4_isItemInRoom(ScriptEnv &e);
int o4_isVarGT(ScriptEnv &e);