diff options
author | Max Horn | 2002-12-27 19:48:30 +0000 |
---|---|---|
committer | Max Horn | 2002-12-27 19:48:30 +0000 |
commit | 788fd1e7189132619d0f8fc03b5a4de8149f08af (patch) | |
tree | 3c5bb7d59837d31be1b4ac3a6764385cc2bb0550 /scumm/object.cpp | |
parent | c1d0e6800c683396d602827063ab645d664ac5ad (diff) | |
download | scummvm-rg350-788fd1e7189132619d0f8fc03b5a4de8149f08af.tar.gz scummvm-rg350-788fd1e7189132619d0f8fc03b5a4de8149f08af.tar.bz2 scummvm-rg350-788fd1e7189132619d0f8fc03b5a4de8149f08af.zip |
like rtRoom, rtRoomScripts should never expire while the room they belong too is loaded; this fixes the crash when picking up the fishing rod
svn-id: r6208
Diffstat (limited to 'scumm/object.cpp')
-rw-r--r-- | scumm/object.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp index 26d13c8d80..bf2676f6cc 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -826,7 +826,7 @@ void Scumm::addObjectToInventory(uint obj, uint room) { int i, slot; uint32 size; - byte *obcdptr, *ptr; + byte *ptr, *dst; FindObjectInRoom foir; debug(1, "Adding object %d from room %d into inventory", obj, room); @@ -836,24 +836,23 @@ void Scumm::addObjectToInventory(uint obj, uint room) i = getObjectIndex(obj); ptr = getResourceAddress(rtFlObject, _objs[i].fl_object_index) + 8; size = READ_BE_UINT32_UNALIGNED(ptr + 4); - slot = getInventorySlot(); - _inventory[slot] = obj; - createResource(rtInventory, slot, size); - ptr = getResourceAddress(rtFlObject, _objs[i].fl_object_index) + 8; - memcpy(getResourceAddress(rtInventory, slot), ptr, size); } else { findObjectInRoom(&foir, foCodeHeader, obj, room); if (_features & GF_SMALL_HEADER) size = READ_LE_UINT32(foir.obcd); else size = READ_BE_UINT32_UNALIGNED(foir.obcd + 4); - slot = getInventorySlot(); - _inventory[slot] = obj; - createResource(rtInventory, slot, size); - obcdptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obcd; - memcpy(getResourceAddress(rtInventory, slot), obcdptr, size); + ptr = foir.obcd; } + slot = getInventorySlot(); + _inventory[slot] = obj; + createResource(rtInventory, slot, size); + + dst = getResourceAddress(rtInventory, slot); + assert(dst); + memcpy(dst, ptr, size); + CHECK_HEAP } |