aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Špalek2009-10-04 22:11:46 +0000
committerRobert Špalek2009-10-04 22:11:46 +0000
commiteb56dfa965718163535df46ecbcfa7a94dbcff4b (patch)
tree168f880ee5f8adb4df9ca7133b4513961cea9827
parent6063d5fbe9c183a106ddeca27992b26b8a6a38d5 (diff)
downloadscummvm-rg350-eb56dfa965718163535df46ecbcfa7a94dbcff4b.tar.gz
scummvm-rg350-eb56dfa965718163535df46ecbcfa7a94dbcff4b.tar.bz2
scummvm-rg350-eb56dfa965718163535df46ecbcfa7a94dbcff4b.zip
Fixed two bugs concerning loading:
1. a room need to be reloaded by force when the loaded game is in the same room as the game before the load 2. objects from the last room and their animations must be deallocated before I change the room number svn-id: r44638
-rw-r--r--engines/draci/game.cpp42
-rw-r--r--engines/draci/game.h4
-rw-r--r--engines/draci/saveload.cpp13
3 files changed, 37 insertions, 22 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 8600b0fd65..1b51bd9142 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -144,11 +144,13 @@ void Game::start() {
while (!shouldQuit()) {
debugC(1, kDraciGeneralDebugLevel, "Game::start()");
+ const bool force_reload = shouldExitLoop() > 1;
+
// Whenever the top-level loop is entered, it should not finish unless
// the exit is triggered by a script
_shouldExitLoop = false;
- enterNewRoom();
+ enterNewRoom(force_reload);
loop();
}
}
@@ -214,7 +216,8 @@ void Game::init() {
_vm->_script->run(dragon->_program, dragon->_init);
// Make sure we enter the right room in start().
- _previousRoom = _currentRoom._roomNum = kNoEscRoom;
+ setRoomNum(kNoEscRoom);
+ rememberRoomNumAsPrevious();
scheduleEnteringRoomUsingGate(_info._startRoom, 0);
}
@@ -1254,8 +1257,21 @@ void Game::loadOverlays() {
_vm->_screen->getSurface()->markDirty();
}
-void Game::enterNewRoom() {
- if (_newRoom == getRoomNum()) {
+void Game::deleteObjectAnimations() {
+ for (uint i = 0; i < _info._numObjects; ++i) {
+ GameObject *obj = &_objects[i];
+
+ if (i != 0 && (obj->_location == getPreviousRoomNum())) {
+ for (uint j = 0; j < obj->_anims.size(); ++j) {
+ _vm->_anims->deleteAnimation(obj->_anims[j]);
+ }
+ obj->_anims.clear();
+ }
+ }
+}
+
+void Game::enterNewRoom(bool force_reload) {
+ if (_newRoom == getRoomNum() && !force_reload) {
return;
}
debugC(1, kDraciLogicDebugLevel, "Entering room %d using gate %d", _newRoom, _newGate);
@@ -1281,18 +1297,8 @@ void Game::enterNewRoom() {
}
// Remember the previous room for returning back from the map.
- _previousRoom = getRoomNum();
-
- for (uint i = 0; i < _info._numObjects; ++i) {
- GameObject *obj = &_objects[i];
-
- if (i != 0 && (obj->_location == _previousRoom)) {
- for (uint j = 0; j < obj->_anims.size(); ++j) {
- _vm->_anims->deleteAnimation(obj->_anims[j]);
- }
- obj->_anims.clear();
- }
- }
+ rememberRoomNumAsPrevious();
+ deleteObjectAnimations();
// Set the current room to the new value
_currentRoom._roomNum = _newRoom;
@@ -1407,6 +1413,10 @@ int Game::getPreviousRoomNum() const {
return _previousRoom;
}
+void Game::rememberRoomNumAsPrevious() {
+ _previousRoom = getRoomNum();
+}
+
void Game::scheduleEnteringRoomUsingGate(int room, int gate) {
_newRoom = room;
_newGate = gate;
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 6e17c199fd..6e2f6f9f61 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -269,6 +269,7 @@ public:
uint getNumObjects() const;
GameObject *getObject(uint objNum);
int getObjectWithAnimation(int animID) const;
+ void deleteObjectAnimations();
int getVariable(int varNum) const;
void setVariable(int varNum, int value);
@@ -278,6 +279,7 @@ public:
int getRoomNum() const;
void setRoomNum(int num);
int getPreviousRoomNum() const;
+ void rememberRoomNumAsPrevious();
void scheduleEnteringRoomUsingGate(int room, int gate);
double getPers0() const;
@@ -343,7 +345,7 @@ public:
private:
void deleteAnimationsAfterIndex(int lastAnimIndex);
- void enterNewRoom();
+ void enterNewRoom(bool force_reload);
void loadRoom(int roomNum);
void runGateProgram(int gate);
diff --git a/engines/draci/saveload.cpp b/engines/draci/saveload.cpp
index cb70000cca..f74deb5c14 100644
--- a/engines/draci/saveload.cpp
+++ b/engines/draci/saveload.cpp
@@ -136,21 +136,24 @@ Common::Error loadSavegameData(int saveGameIdx, DraciEngine *vm) {
readSavegameHeader(f, header);
if (header.thumbnail) delete header.thumbnail;
+ // Pre-processing
+ vm->_game->rememberRoomNumAsPrevious();
+ vm->_game->deleteObjectAnimations();
+
// Synchronise the remaining data of the savegame
Common::Serializer s(f, NULL);
- int oldRoomNum = vm->_game->getRoomNum();
vm->_game->DoSync(s);
-
delete f;
- // Post processing
- vm->_engineStartTime = vm->_system->getMillis() / 1000 - header.playtime;
+ // Post-processing
vm->_game->scheduleEnteringRoomUsingGate(vm->_game->getRoomNum(), 0);
- vm->_game->setRoomNum(oldRoomNum);
+ vm->_game->setRoomNum(vm->_game->getPreviousRoomNum());
vm->_game->setExitLoop(2); // 2 > true means immediate exit for the loop
vm->_game->inventoryReload();
+ vm->_engineStartTime = vm->_system->getMillis() / 1000 - header.playtime;
+
return Common::kNoError;
}