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:
parent
8032becd15
commit
03cd0ddf56
4 changed files with 11 additions and 23 deletions
|
@ -269,12 +269,12 @@ void ScriptManager::saveQueue(Common::Serializer &s) {
|
||||||
_queue.saveLoadWithSerializer(s);
|
_queue.saveLoadWithSerializer(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptManager::reset() {
|
void ScriptManager::reset(uint32 count) {
|
||||||
// Reset script queue
|
// Create a set of empty scripts
|
||||||
resetQueue();
|
for (uint32 i = 0; i < count; i++) {
|
||||||
|
Script script;
|
||||||
// Remove all scripts
|
_scripts.push_back(script);
|
||||||
_scripts.clear();
|
}
|
||||||
|
|
||||||
_done = false;
|
_done = false;
|
||||||
_exit = false;
|
_exit = false;
|
||||||
|
|
|
@ -139,7 +139,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Resets the queue and local variables
|
* Resets the queue and local variables
|
||||||
*/
|
*/
|
||||||
void reset();
|
void reset(uint32 count = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the script element at actionIndex to
|
* Initialize the script element at actionIndex to
|
||||||
|
|
|
@ -379,23 +379,15 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Objects
|
// Objects
|
||||||
for (uint32 i = 0; i < numObjects; i++) {
|
for (uint32 i = 0; i < numObjects; i++)
|
||||||
if (s.isLoading())
|
|
||||||
objects.push_back(new Object(_vm));
|
|
||||||
|
|
||||||
objects[i]->saveLoadWithSerializer(s);
|
objects[i]->saveLoadWithSerializer(s);
|
||||||
}
|
|
||||||
|
|
||||||
s.skip((OBJECTS_MAX_COUNT - numObjects) * OBJECTS_SIZE);
|
s.skip((OBJECTS_MAX_COUNT - numObjects) * OBJECTS_SIZE);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Actors
|
// Actors
|
||||||
for (uint32 i = 0; i < numActors; i++) {
|
for (uint32 i = 0; i < numActors; i++)
|
||||||
if (s.isLoading())
|
|
||||||
actors.push_back(new Actor(_vm, i));
|
|
||||||
|
|
||||||
actors[i]->saveLoadWithSerializer(s);
|
actors[i]->saveLoadWithSerializer(s);
|
||||||
}
|
|
||||||
|
|
||||||
s.skip((ACTORS_MAX_COUNT - numActors) * ACTORS_SIZE);
|
s.skip((ACTORS_MAX_COUNT - numActors) * ACTORS_SIZE);
|
||||||
|
|
||||||
|
@ -417,12 +409,8 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Read actions
|
// Read actions
|
||||||
for (uint32 i = 0; i < numActions; i++) {
|
for (uint32 i = 0; i < numActions; i++)
|
||||||
if (s.isLoading())
|
|
||||||
actions.push_back(new ActionArea());
|
|
||||||
|
|
||||||
actions[i]->saveLoadWithSerializer(s);
|
actions[i]->saveLoadWithSerializer(s);
|
||||||
}
|
|
||||||
|
|
||||||
s.skip((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE);
|
s.skip((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE);
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ bool Savegame::loadData(Common::String filename) {
|
||||||
read(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
|
read(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
|
||||||
read(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
|
read(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
|
||||||
|
|
||||||
getScript()->reset();
|
getScript()->reset(getWorld()->numScripts);
|
||||||
|
|
||||||
if (getWorld()->numScripts)
|
if (getWorld()->numScripts)
|
||||||
read(file, getScript(), 7096, (uint32)getWorld()->numScripts, "Action Lists");
|
read(file, getScript(), 7096, (uint32)getWorld()->numScripts, "Action Lists");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue