diff options
author | Max Horn | 2004-02-17 17:43:27 +0000 |
---|---|---|
committer | Max Horn | 2004-02-17 17:43:27 +0000 |
commit | eefbe23801f2aa8cd5d184a0cd644c8509264b5a (patch) | |
tree | 657e380a2a803e68f2181ea634a62b71aa459b79 /scumm/saveload.cpp | |
parent | 2940a98cd31e5402a5a14589402332b8221f65c1 (diff) | |
download | scummvm-rg350-eefbe23801f2aa8cd5d184a0cd644c8509264b5a.tar.gz scummvm-rg350-eefbe23801f2aa8cd5d184a0cd644c8509264b5a.tar.bz2 scummvm-rg350-eefbe23801f2aa8cd5d184a0cd644c8509264b5a.zip |
delete certain unused non-perma resources when loading
svn-id: r12923
Diffstat (limited to 'scumm/saveload.cpp')
-rw-r--r-- | scumm/saveload.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 58adfa8289..e9b08f7827 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -183,7 +183,7 @@ bool ScummEngine::loadState(int slot, bool compat, SaveFileManager *mgr) { // scumm vars. We now know the proper locations. To be able to properly use // old save games, we update the old (bad) variables to the new (correct) // ones. - if (hdr.ver < 28 && _version == 8) { + if (hdr.ver < VER(28) && _version == 8) { _scummVars[VAR_CAMERA_MIN_X] = _scummVars[101]; _scummVars[VAR_CAMERA_MAX_X] = _scummVars[102]; _scummVars[VAR_CAMERA_MIN_Y] = _scummVars[103]; @@ -657,6 +657,18 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { // Save all resource. int type, idx; + + if (s->isLoading()) { + // When loading, start by deleting old non-permanent resources (an + // exception is made for buffer/temp resources, they are going to be + // deleted later on anyway). + for (type = rtFirst; type <= rtLast; type++) { + if (res.mode[type] != 1 && type != rtTemp && type != rtBuffer) + for (idx = 1; idx < res.num[type]; idx++) + nukeResource(type, idx); + } + } + if (savegameVersion >= VER(26)) { // New, more robust resource save/load system. This stores the type // and index of each resource. Thus if we increase e.g. the maximum @@ -689,10 +701,9 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { // with index 0, and breaks whenever we change the limit on a given // resource type. for (type = rtFirst; type <= rtLast; type++) - if (res.mode[type] != 1) + if (res.mode[type] != 1 && type != rtTemp && type != rtBuffer) for (idx = 1; idx < res.num[type]; idx++) - if (type != rtTemp && type != rtBuffer) - saveLoadResource(s, type, idx); + saveLoadResource(s, type, idx); } s->saveLoadArrayOf(_objectOwnerTable, _numGlobalObjects, sizeof(_objectOwnerTable[0]), sleByte); |