From e67aaba0c3da89778faff5d5822cbf6dfba811dd Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 1 Mar 2004 16:07:16 +0000 Subject: Got rid of the Sam & Max inventory hack. This fixes at least one aspect of bug #907113. See also bug #493153 for the origins of the hack. It would be very nice if we could get this fix into 0.6.0 as well, because bug #907113 crashes ScummVM for reasons which escape me. But someone will have to verify that the fix is correct first. Pretty please...? svn-id: r13124 --- scumm/object.cpp | 11 +++++++++-- scumm/script_v6.cpp | 30 ------------------------------ 2 files changed, 9 insertions(+), 32 deletions(-) (limited to 'scumm') diff --git a/scumm/object.cpp b/scumm/object.cpp index 9a8d2561cf..979236a365 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -1191,19 +1191,26 @@ int ScummEngine::getInventorySlot() { void ScummEngine::setOwnerOf(int obj, int owner) { ScriptSlot *ss; + + // In Sam & Max this is necessary, or you won't get your stuff back + // from the Lost and Found tent after riding the Cone of Tragedy. But + // it probably applies to all V6+ games. See bugs #493153 and #907113. + + int arg = (_version >= 6) ? obj : 0; + if (owner == 0) { clearOwnerOf(obj); ss = &vm.slot[_currentScript]; if (ss->where == WIO_INVENTORY && _inventory[ss->number] == obj) { putOwner(obj, 0); - runInventoryScript(0); + runInventoryScript(arg); stopObjectCode(); return; } } putOwner(obj, owner); - runInventoryScript(0); + runInventoryScript(arg); } int ScummEngine::getObjX(int obj) { diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 2d8b64aabb..a14fac6603 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -1020,36 +1020,6 @@ void ScummEngine_v6::o6_setState() { 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); } -- cgit v1.2.3