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
This commit is contained in:
Max Horn 2002-12-27 19:48:30 +00:00
parent c1d0e6800c
commit 788fd1e718
3 changed files with 14 additions and 13 deletions

View File

@ -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
}

View File

@ -1381,6 +1381,8 @@ bool Scumm::isResourceInUse(int type, int i)
switch (type) {
case rtRoom:
return _roomResource == (byte)i;
case rtRoomScripts:
return _roomResource == (byte)i;
case rtScript:
return isScriptInUse(i);
case rtCostume:

View File

@ -1423,10 +1423,10 @@ void Scumm_v8::o6_kernelSetFunctions()
case 34: // queryQuit
warning("o6_kernelSetFunctions: queryQuit()");
break;
case 108:
case 108: // buildPaletteShadow
setupShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6]);
break;
case 109:
case 109: // setPaletteShadow
setupShadowPalette(0, args[1], args[2], args[3], args[4], args[5]);
break;
case 115: // getWalkBoxAt