Patch 671031: Fix for MI1 intro crash + others (move new object

clearing code into a more generic function, and call it earlier)

svn-id: r6548
This commit is contained in:
James Brown 2003-01-26 10:57:01 +00:00
parent 8d9b84b98e
commit d1eb2636f4
3 changed files with 32 additions and 23 deletions

View file

@ -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()];

View file

@ -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();

View file

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