diff --git a/scumm/object.cpp b/scumm/object.cpp index 488fe70efc5..2192a81c13e 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -410,6 +410,35 @@ void Scumm::drawObject(int obj, int arg) } } +void Scumm::clearRoomObjects() +{ + int i; + + if (_features & GF_SMALL_HEADER) { + for (i = 0; i < _numLocalObjects; i++) { + _objs[i].obj_nr = 0; + } + } else { + // FIXME: Locking/FlObjects stuff? + for (i = 0; i < _numLocalObjects; i++) { + if (_objs[i].obj_nr < 1) // Optimise codepath + continue; + + // Nuke all non-flObjects (flObjects are nuked in script.cpp) + if (_objs[i].fl_object_index == 0) { + _objs[i].obj_nr = 0; + } else { + // Nuke all unlocked flObjects + if (!(res.flags[rtFlObject][_objs[i].fl_object_index] & RF_LOCK)) { + nukeResource(rtFlObject, _objs[i].fl_object_index); + _objs[i].obj_nr = 0; + _objs[i].fl_object_index = 0; + } + } + } + } +} + void Scumm::loadRoomObjects() { int i, j; @@ -432,24 +461,6 @@ void Scumm::loadRoomObjects() else _numObjectsInRoom = READ_LE_UINT16(&(roomhdr->old.numObjects)); - // Clear out old room objects (FIXME: Locking/FlObjects stuff?) - for (i = 0; i < _numLocalObjects; i++) { - if (_objs[i].obj_nr < 1) // Optimise codepath - continue; - - // Nuke all non-flObjects (flObjects are nuked in script.cpp) - if (_objs[i].fl_object_index == 0) { - _objs[i].obj_nr = 0; - } else { - // Nuke all unlocked flObjects - if (!(res.flags[rtFlObject][_objs[i].fl_object_index] & RF_LOCK)) { - nukeResource(rtFlObject, _objs[i].fl_object_index); - _objs[i].obj_nr = 0; - _objs[i].fl_object_index = 0; - } - } - } - if (_numObjectsInRoom == 0) return; @@ -544,11 +555,6 @@ void Scumm::loadRoomObjectsSmall() if (_numObjectsInRoom > _numLocalObjects) error("More than %d objects in room %d", _numLocalObjects, _roomResource); - // Clear out old room objects - for (i = 0; i < _numLocalObjects; i++) { - _objs[i].obj_nr = 0; - } - searchptr = room; for (i = 0; i < _numObjectsInRoom; i++) { od = &_objs[findLocalObjectSlot()]; diff --git a/scumm/scumm.h b/scumm/scumm.h index 46cebc6979a..6bc52c4c612 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -532,6 +532,7 @@ public: bool isResourceInUse(int type, int i); bool isResourceLoaded(int type, int index); void initRoomSubBlocks(); + void clearRoomObjects(); void loadRoomObjects(); void loadRoomObjectsSmall(); void readArrayFromIndexFile(); diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 44e80f7c34d..eb15759aec4 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -652,6 +652,8 @@ void Scumm::startScene(int room, Actor * a, int objectNr) if (room != 0) ensureResourceLoaded(rtRoom, room); + clearRoomObjects(); + if (_currentRoom == 0) { _ENCD_offs = _EXCD_offs = 0; _numObjectsInRoom = 0;