From 8e89f7d060ca5fac1efc7c244df91b678f7e2c9d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 19 Jan 2004 20:23:27 +0000 Subject: moved the sam&max inventory hack into o6_setOwner svn-id: r12520 --- scumm/object.cpp | 19 ------------------- scumm/script_v6.cpp | 29 +++++++++++++++++++++++++++++ scumm/scumm.h | 1 - 3 files changed, 29 insertions(+), 20 deletions(-) (limited to 'scumm') diff --git a/scumm/object.cpp b/scumm/object.cpp index 56e4b49eaf..e5ad18080e 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -1188,23 +1188,6 @@ int ScummEngine::getInventorySlot() { return -1; } -void ScummEngine::SamInventoryHack(int obj) { - // FIXME: Sam and Max hack - int base = 6; - - while (base < 80) { - int value = readArray(178, 0, base); - if (value == obj) - return; - if (value == 0) { - _scummVars[179]++; - writeArray(178, 0, base, obj); - return; - } - base++; - } -} - void ScummEngine::setOwnerOf(int obj, int owner) { ScriptSlot *ss; if (owner == 0) { @@ -1217,8 +1200,6 @@ void ScummEngine::setOwnerOf(int obj, int owner) { return; } } - if ((owner == 2) && (_gameId == GID_SAMNMAX)) - SamInventoryHack(obj); putOwner(obj, owner); runInventoryScript(0); diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 545b5a2921..6ca3af6d35 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -925,6 +925,35 @@ void ScummEngine_v6::o6_setOwner() { int owner = pop(); int obj = pop(); + if ((owner == 2) && (_gameId == GID_SAMNMAX)) { + // TODO / FIXME: This hack was added a long time ago, in revision 1.28 + // of object.cpp in the old CVS module (see also here: + // http://cvs.sourceforge.net/viewcvs.py/scummvm/scummvm-old/object.cpp?r1=1.27&r2=1.28 + // Commited by Endy with message: + // "Sam and Max inventory hack. Makes it work, but is nasty ;)" + // + // Sadly, it's not quite clear what exactly the hack fixes. In a quick + // test I didn't find any place where it is being used, but of course + // that means nothing. + // + // There aren't many places that invoke setOwner at all (in Sam and Max). + // I did a quick search of the script dumps I have here; in those I found + // seven calls to setOwner, and only one with owner == 2. + + warning("Inside Sam and Max inventory hack! (obj %d)", obj); + for (int base = 6; base < 80; base++) { + int value = readArray(178, 0, base); + if (value == obj) + break; + if (value == 0) { + _scummVars[179]++; + writeArray(178, 0, base, obj); + break; + } + base++; + } + } + setOwnerOf(obj, owner); } diff --git a/scumm/scumm.h b/scumm/scumm.h index c6685d0fa9..15207c3d2f 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -662,7 +662,6 @@ public: /* Should be in Object class */ byte OF_OWNER_ROOM; int getInventorySlot(); - void SamInventoryHack(int obj); // FIXME: Sam and Max hack int findInventory(int owner, int index); int getInventoryCount(int owner); -- cgit v1.2.3