From 7afd2a11dbac5098b672fa7f43f6f1d49df205f7 Mon Sep 17 00:00:00 2001 From: James Brown Date: Wed, 3 Apr 2002 16:20:17 +0000 Subject: Fix removal of objects in Zak/Indy3/Loom svn-id: r3852 --- object.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/object.cpp b/object.cpp index 3f291cf8f1..ae25a4ef53 100644 --- a/object.cpp +++ b/object.cpp @@ -25,31 +25,41 @@ bool Scumm::getClass(int obj, int cls) { checkRange(_numGlobalObjects-1, 0, obj, "Object %d out of range in getClass"); - - + cls &= 0x7F; checkRange(32,1,cls,"Class %d out of range in getClass"); + if (_features && GF_SMALL_HEADER) { byte *oldClass = (byte*)&_classData[obj]; if (cls == 32) // CLASS_TOUCHABLE cls = 23; return (oldClass[cls/8] & bit_table[cls&0x07]) != 0; - } else { - cls &= 0x7F; + } else { return (_classData[obj] & (1<<(cls-1))) != 0; } } void Scumm::putClass(int obj, int cls, bool set) { checkRange(_numGlobalObjects-1, 0, obj, "Object %d out of range in putClass"); - cls &= 0x7F; checkRange(32,1,cls,"Class %d out of range in getClass"); - if (set) - _classData[obj] |= (1<<(cls-1)); - else - _classData[obj] &= ~(1<<(cls-1)); + if (_features && GF_SMALL_HEADER) { + byte *oldClass = (byte*)&_classData[obj]; + if (cls == 32) // CLASS_TOUCHABLE + cls = 23; + + if (set) + oldClass[cls/8] |= bit_table[cls&0x07]; + else + oldClass[cls/8] &= bit_table[cls&0x07]^0xff; + + } else { + if (set) + _classData[obj] |= (1<<(cls-1)); + else + _classData[obj] &= ~(1<<(cls-1)); + } } int Scumm::getOwner(int obj) { @@ -782,6 +792,10 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint } fo->roomptr = roomptr = getResourceAddress(rtRoom, room); + if (!roomptr) { // FIXME: ZAK256 AIRPORT WORKAROUND (buying book from devotee) + warning("findObjectInRoom: failed getting roomptr to %d", room); + return; + } roomhdr = (RoomHeader*)findResourceData(MKID('RMHD'), roomptr); if(_features & GF_AFTER_V7) -- cgit v1.2.3