ASYLUM: Fix loading of saved games

- Do not add more actors/objects/actions when loading data (the correct scene was loaded and contains the data already)
 - Do not reset the script queue and empty the script array before loading the script list
This commit is contained in:
Littleboy 2011-08-05 05:19:19 -04:00 committed by Eugene Sandulenko
parent 8032becd15
commit 03cd0ddf56
No known key found for this signature in database
GPG key ID: 014D387312D34F08
4 changed files with 11 additions and 23 deletions

View file

@ -269,12 +269,12 @@ void ScriptManager::saveQueue(Common::Serializer &s) {
_queue.saveLoadWithSerializer(s);
}
void ScriptManager::reset() {
// Reset script queue
resetQueue();
// Remove all scripts
_scripts.clear();
void ScriptManager::reset(uint32 count) {
// Create a set of empty scripts
for (uint32 i = 0; i < count; i++) {
Script script;
_scripts.push_back(script);
}
_done = false;
_exit = false;

View file

@ -139,7 +139,7 @@ public:
/**
* Resets the queue and local variables
*/
void reset();
void reset(uint32 count = 0);
/**
* Initialize the script element at actionIndex to

View file

@ -379,23 +379,15 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
//////////////////////////////////////////////////////////////////////////
// Objects
for (uint32 i = 0; i < numObjects; i++) {
if (s.isLoading())
objects.push_back(new Object(_vm));
for (uint32 i = 0; i < numObjects; i++)
objects[i]->saveLoadWithSerializer(s);
}
s.skip((OBJECTS_MAX_COUNT - numObjects) * OBJECTS_SIZE);
//////////////////////////////////////////////////////////////////////////
// Actors
for (uint32 i = 0; i < numActors; i++) {
if (s.isLoading())
actors.push_back(new Actor(_vm, i));
for (uint32 i = 0; i < numActors; i++)
actors[i]->saveLoadWithSerializer(s);
}
s.skip((ACTORS_MAX_COUNT - numActors) * ACTORS_SIZE);
@ -417,12 +409,8 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
//////////////////////////////////////////////////////////////////////////
// Read actions
for (uint32 i = 0; i < numActions; i++) {
if (s.isLoading())
actions.push_back(new ActionArea());
for (uint32 i = 0; i < numActions; i++)
actions[i]->saveLoadWithSerializer(s);
}
s.skip((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE);

View file

@ -287,7 +287,7 @@ bool Savegame::loadData(Common::String filename) {
read(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
read(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
getScript()->reset();
getScript()->reset(getWorld()->numScripts);
if (getWorld()->numScripts)
read(file, getScript(), 7096, (uint32)getWorld()->numScripts, "Action Lists");