[Scummvm-cvs-logs] SF.net SVN: scummvm:[44638] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Mon Oct 5 00:11:46 CEST 2009
Revision: 44638
http://scummvm.svn.sourceforge.net/scummvm/?rev=44638&view=rev
Author: spalek
Date: 2009-10-04 22:11:46 +0000 (Sun, 04 Oct 2009)
Log Message:
-----------
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
Modified Paths:
--------------
scummvm/trunk/engines/draci/game.cpp
scummvm/trunk/engines/draci/game.h
scummvm/trunk/engines/draci/saveload.cpp
Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp 2009-10-04 21:57:31 UTC (rev 44637)
+++ scummvm/trunk/engines/draci/game.cpp 2009-10-04 22:11:46 UTC (rev 44638)
@@ -144,11 +144,13 @@
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 @@
_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 @@
_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,19 +1297,9 @@
}
// Remember the previous room for returning back from the map.
- _previousRoom = getRoomNum();
+ rememberRoomNumAsPrevious();
+ deleteObjectAnimations();
- 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();
- }
- }
-
// Set the current room to the new value
_currentRoom._roomNum = _newRoom;
@@ -1407,6 +1413,10 @@
return _previousRoom;
}
+void Game::rememberRoomNumAsPrevious() {
+ _previousRoom = getRoomNum();
+}
+
void Game::scheduleEnteringRoomUsingGate(int room, int gate) {
_newRoom = room;
_newGate = gate;
Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h 2009-10-04 21:57:31 UTC (rev 44637)
+++ scummvm/trunk/engines/draci/game.h 2009-10-04 22:11:46 UTC (rev 44638)
@@ -269,6 +269,7 @@
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 @@
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 @@
private:
void deleteAnimationsAfterIndex(int lastAnimIndex);
- void enterNewRoom();
+ void enterNewRoom(bool force_reload);
void loadRoom(int roomNum);
void runGateProgram(int gate);
Modified: scummvm/trunk/engines/draci/saveload.cpp
===================================================================
--- scummvm/trunk/engines/draci/saveload.cpp 2009-10-04 21:57:31 UTC (rev 44637)
+++ scummvm/trunk/engines/draci/saveload.cpp 2009-10-04 22:11:46 UTC (rev 44638)
@@ -136,21 +136,24 @@
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;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list