HE games store and restore locked FlObjects between rooms.

Fixes input issue in thinker1.

svn-id: r19072
This commit is contained in:
Travis Howell 2005-10-14 02:13:33 +00:00
parent a3d0fcea54
commit 7af9ece552
5 changed files with 48 additions and 3 deletions

View File

@ -507,7 +507,8 @@ void ScummEngine::clearRoomObjects() {
_objs[i].obj_nr = 0;
}
} else {
// FIXME: Locking/FlObjects stuff?
storeFlObject(-1);
for (i = 0; i < _numLocalObjects; i++) {
if (_objs[i].obj_nr < 1) // Optimise codepath
continue;
@ -521,12 +522,41 @@ void ScummEngine::clearRoomObjects() {
res.nukeResource(rtFlObject, _objs[i].fl_object_index);
_objs[i].obj_nr = 0;
_objs[i].fl_object_index = 0;
} else if (_heversion >= 70) {
storeFlObject(i);
_objs[i].obj_nr = 0;
_objs[i].fl_object_index = 0;
}
}
}
}
}
void ScummEngine::storeFlObject(int slot) {
if (slot == -1) {
_numStoredFlObjects = 0;
} else {
memcpy(&_storedFlObjects[_numStoredFlObjects], &_objs[slot], sizeof(_objs[slot]));
_numStoredFlObjects++;
if (_numStoredFlObjects > 100)
error("Too many flobjects saved on room transition.");
}
}
void ScummEngine::restoreFlObjects() {
if (!_numStoredFlObjects)
return;
int i, slot;
for (i = 0; i < _numStoredFlObjects; i++) {
slot = findLocalObjectSlot();
memcpy(&_objs[slot], &_storedFlObjects[i], sizeof(_objs[slot]));
}
_numStoredFlObjects = 0;
}
void ScummEngine::loadRoomObjects() {
int i, j;
ObjectData *od;
@ -1675,6 +1705,12 @@ void ScummEngine::loadFlObject(uint object, uint room) {
if (whereIsObject(object) != WIO_NOT_FOUND)
return;
int i;
for (i = 0; i < _numStoredFlObjects; i++) {
if (_storedFlObjects[i].obj_nr == object)
return;
}
// Locate the object in the room resource
findObjectInRoom(&foir, foImageHeader | foCodeHeader, object, room);

View File

@ -1251,8 +1251,10 @@ void ScummEngine::allocateArrays() {
_roomVars = (int32 *)calloc(_numRoomVariables, sizeof(int32));
_scummVars = (int32 *)calloc(_numVariables, sizeof(int32));
_bitVars = (byte *)calloc(_numBitVariables >> 3, 1);
if (_heversion >= 60)
if (_heversion >= 60) {
_arraySlot = (byte *)calloc(_numArray, 1);
_storedFlObjects = (ObjectData *)calloc(100, sizeof(ObjectData));
}
allocResTypeData(rtCostume, (_features & GF_NEW_COSTUMES) ? MKID('AKOS') : MKID('COST'),
_numCostumes, "costume", 1);

View File

@ -127,6 +127,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {
if (_currentRoom == 0) {
_ENCD_offs = _EXCD_offs = 0;
_numObjectsInRoom = 0;
restoreFlObjects();
return;
}
@ -136,7 +137,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {
initBGBuffers(_roomHeight);
loadRoomObjects();
restoreFlObjects();
if (VAR_ROOM_WIDTH != 0xFF && VAR_ROOM_HEIGHT != 0xFF) {
VAR(VAR_ROOM_WIDTH) = _roomWidth;

View File

@ -946,6 +946,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
_musicEngine = NULL;
_verbs = NULL;
_objs = NULL;
_storedFlObjects = NULL;
_debugFlags = 0;
_sound = NULL;
memset(&vm, 0, sizeof(vm));
@ -970,6 +971,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
_numRoomVariables = 0;
_numLocalObjects = 0;
_numGlobalObjects = 0;
_numStoredFlObjects = 0;
_numArray = 0;
_numVerbs = 0;
_numFlObject = 0;

View File

@ -376,6 +376,7 @@ public:
VerbSlot *_verbs;
ObjectData *_objs;
ObjectData *_storedFlObjects;
ScummDebugger *_debugger;
// Core variables
@ -512,6 +513,7 @@ protected:
int _numNewNames, _numGlobalScripts;
int _numRoomVariables;
int _numPalettes, _numSprites, _numTalkies, _numUnk;
int _numStoredFlObjects;
int _HEHeapSize;
public:
int _numLocalScripts, _numImages, _numRooms, _numScripts, _numSounds; // Used by HE games
@ -732,6 +734,8 @@ protected:
virtual void loadRoomSubBlocks();
virtual void initRoomSubBlocks();
void clearRoomObjects();
void storeFlObject(int slot);
void restoreFlObjects();
virtual void loadRoomObjects();
virtual void readArrayFromIndexFile();