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:
parent
8d9b84b98e
commit
d1eb2636f4
3 changed files with 32 additions and 23 deletions
|
@ -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()
|
void Scumm::loadRoomObjects()
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -432,24 +461,6 @@ void Scumm::loadRoomObjects()
|
||||||
else
|
else
|
||||||
_numObjectsInRoom = READ_LE_UINT16(&(roomhdr->old.numObjects));
|
_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)
|
if (_numObjectsInRoom == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -544,11 +555,6 @@ void Scumm::loadRoomObjectsSmall()
|
||||||
if (_numObjectsInRoom > _numLocalObjects)
|
if (_numObjectsInRoom > _numLocalObjects)
|
||||||
error("More than %d objects in room %d", _numLocalObjects, _roomResource);
|
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;
|
searchptr = room;
|
||||||
for (i = 0; i < _numObjectsInRoom; i++) {
|
for (i = 0; i < _numObjectsInRoom; i++) {
|
||||||
od = &_objs[findLocalObjectSlot()];
|
od = &_objs[findLocalObjectSlot()];
|
||||||
|
|
|
@ -532,6 +532,7 @@ public:
|
||||||
bool isResourceInUse(int type, int i);
|
bool isResourceInUse(int type, int i);
|
||||||
bool isResourceLoaded(int type, int index);
|
bool isResourceLoaded(int type, int index);
|
||||||
void initRoomSubBlocks();
|
void initRoomSubBlocks();
|
||||||
|
void clearRoomObjects();
|
||||||
void loadRoomObjects();
|
void loadRoomObjects();
|
||||||
void loadRoomObjectsSmall();
|
void loadRoomObjectsSmall();
|
||||||
void readArrayFromIndexFile();
|
void readArrayFromIndexFile();
|
||||||
|
|
|
@ -652,6 +652,8 @@ void Scumm::startScene(int room, Actor * a, int objectNr)
|
||||||
if (room != 0)
|
if (room != 0)
|
||||||
ensureResourceLoaded(rtRoom, room);
|
ensureResourceLoaded(rtRoom, room);
|
||||||
|
|
||||||
|
clearRoomObjects();
|
||||||
|
|
||||||
if (_currentRoom == 0) {
|
if (_currentRoom == 0) {
|
||||||
_ENCD_offs = _EXCD_offs = 0;
|
_ENCD_offs = _EXCD_offs = 0;
|
||||||
_numObjectsInRoom = 0;
|
_numObjectsInRoom = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue