[Scummvm-git-logs] scummvm master -> 5f46bbff728025aedc7d4d6c83b23c3a59912e96

waltervn walter at vanniftrik-it.nl
Fri Dec 16 18:31:38 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5f46bbff72 ADL: Add item region checks


Commit: 5f46bbff728025aedc7d4d6c83b23c3a59912e96
    https://github.com/scummvm/scummvm/commit/5f46bbff728025aedc7d4d6c83b23c3a59912e96
Author: Walter van Niftrik (walter at scummvm.org)
Date: 2016-12-16T18:27:24+01:00

Commit Message:
ADL: Add item region checks

Changed paths:
    engines/adl/adl.cpp
    engines/adl/adl_v2.cpp
    engines/adl/adl_v2.h
    engines/adl/adl_v4.cpp
    engines/adl/adl_v4.h


diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 0d96cb6..e3cd929 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 b34d4c9..46bd6aa 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 8f36b5c..fe0c781 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 6dfee80..8b72923 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 8516e40..1bc7664 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);





More information about the Scummvm-git-logs mailing list