aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-06-26 13:55:01 +0000
committerMax Horn2003-06-26 13:55:01 +0000
commitc1e08c27ce649d63358789843aac42c7c1a0d69e (patch)
tree37a0b7732daeade48ca0146f4bb32e48704b5498
parent8e0c6dfede866ef42a1d95666518c6051c72fa8e (diff)
downloadscummvm-rg350-c1e08c27ce649d63358789843aac42c7c1a0d69e.tar.gz
scummvm-rg350-c1e08c27ce649d63358789843aac42c7c1a0d69e.tar.bz2
scummvm-rg350-c1e08c27ce649d63358789843aac42c7c1a0d69e.zip
paranoia fix for getOBCDFromObject, in casegetResourceAddress returns 0
svn-id: r8653
-rw-r--r--scumm/object.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp
index b839b4f35b..1926589d38 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -927,6 +927,7 @@ uint32 Scumm::getOBCDOffs(int object) const {
byte *Scumm::getOBCDFromObject(int obj) {
int i;
+ byte *ptr;
if (_objectOwnerTable[obj] != OF_OWNER_ROOM) {
for (i = 0; i < _maxInventoryItems; i++) {
@@ -936,12 +937,15 @@ byte *Scumm::getOBCDFromObject(int obj) {
} else {
for (i = (_numLocalObjects-1); i > 0; --i) {
if (_objs[i].obj_nr == obj) {
- if (_objs[i].fl_object_index)
- return getResourceAddress(rtFlObject, _objs[i].fl_object_index) + 8;
- if (_version == 8)
- return getResourceAddress(rtRoomScripts, _roomResource) + _objs[i].OBCDoffset;
+ if (_objs[i].fl_object_index) {
+ assert(_objs[i].OBCDoffset == 8);
+ ptr = getResourceAddress(rtFlObject, _objs[i].fl_object_index);
+ } else if (_version == 8)
+ ptr = getResourceAddress(rtRoomScripts, _roomResource);
else
- return getResourceAddress(rtRoom, _roomResource) + _objs[i].OBCDoffset;
+ ptr = getResourceAddress(rtRoom, _roomResource);
+ assert(ptr);
+ return ptr + _objs[i].OBCDoffset;
}
}
}
@@ -1044,7 +1048,7 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint
error("findObjectInRoom foCheckAlreadyLoaded NYI for GF_OLD_BUNDLE (id = %d, room = %d)", id, room);
}
fo->obcd = obcdptr = getOBCDFromObject(id);
- assert((const byte *)obcdptr > (byte *)256);
+ assert(obcdptr);
fo->obim = obimptr = obcdptr + RES_SIZE(obcdptr);
fo->cdhd = (const CodeHeader *)findResourceData(MKID('CDHD'), obcdptr);
fo->imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obimptr);