aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/saveload.cpp
diff options
context:
space:
mode:
authorMax Horn2011-05-13 14:02:53 +0200
committerMax Horn2011-05-13 14:02:53 +0200
commit649f8e0a84804a9d1272ba16b146ea2b9da501fe (patch)
tree4e257a06140c69abb043d5c9a2eb3d23e5ff9e1b /engines/scumm/saveload.cpp
parentaaf2c0e6ebe373afd06cbf8ebca334710a4ed15d (diff)
downloadscummvm-rg350-649f8e0a84804a9d1272ba16b146ea2b9da501fe.tar.gz
scummvm-rg350-649f8e0a84804a9d1272ba16b146ea2b9da501fe.tar.bz2
scummvm-rg350-649f8e0a84804a9d1272ba16b146ea2b9da501fe.zip
SCUMM: Rename ResTypes->ResType, introduce ResId typedef, change code to use both
Diffstat (limited to 'engines/scumm/saveload.cpp')
-rw-r--r--engines/scumm/saveload.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 996e8685bb..f37ca36c6f 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -311,7 +311,6 @@ static bool loadSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &h
bool ScummEngine::loadState(int slot, bool compat) {
Common::String filename;
Common::SeekableReadStream *in;
- int i, j;
SaveGameHeader hdr;
int sb, sh;
@@ -426,10 +425,10 @@ bool ScummEngine::loadState(int slot, bool compat) {
memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
// Nuke all resources
- for (i = rtFirst; i <= rtLast; i++)
- if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound || !compat))
- for (j = 0; j < _res->_types[i]._num; j++) {
- _res->nukeResource(i, j);
+ for (ResType type = rtFirst; type <= rtLast; type = ResType(type + 1))
+ if (type != rtTemp && type != rtBuffer && (type != rtSound || _saveSound || !compat))
+ for (ResId idx = 0; idx < _res->_types[type]._num; idx++) {
+ _res->nukeResource(type, idx);
}
resetScummVars();
@@ -517,8 +516,8 @@ bool ScummEngine::loadState(int slot, bool compat) {
// loading such an old save game, try to upgrade the old to new format.
if (hdr.ver < VER(22)) {
// Convert all rtScaleTable resources to matching scale items
- for (i = 1; i < _res->_types[rtScaleTable]._num; i++) {
- convertScaleTableToScaleSlot(i);
+ for (ResId idx = 1; idx < _res->_types[rtScaleTable]._num; idx++) {
+ convertScaleTableToScaleSlot(idx);
}
}
@@ -1116,7 +1115,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
MKEND()
};
- int i, j;
+ int i;
int var120Backup;
int var98Backup;
uint8 md5Backup[16];
@@ -1134,9 +1133,9 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// MD5 Operations: Backup on load, compare, and reset.
if (s->isLoading()) {
char md5str1[32+1], md5str2[32+1];
- for (j = 0; j < 16; j++) {
- sprintf(md5str1 + j*2, "%02x", (int)_gameMD5[j]);
- sprintf(md5str2 + j*2, "%02x", (int)md5Backup[j]);
+ for (i = 0; i < 16; i++) {
+ sprintf(md5str1 + i*2, "%02x", (int)_gameMD5[i]);
+ sprintf(md5str2 + i*2, "%02x", (int)md5Backup[i]);
}
debug(2, "Save version: %d", s->getVersion());
@@ -1236,13 +1235,14 @@ void ScummEngine::saveOrLoad(Serializer *s) {
//
// Save/load resources
//
- int type, idx;
+ ResType type;
+ ResId idx;
if (s->getVersion() >= 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
// number of script resources, savegames won't break.
if (s->isSaving()) {
- for (type = rtFirst; type <= rtLast; type++) {
+ for (type = rtFirst; type <= rtLast; type = ResType(type + 1)) {
if (_res->_types[type]._mode != kStaticResTypeMode && type != rtTemp && type != rtBuffer) {
s->saveUint16(type); // Save the res type...
for (idx = 0; idx < _res->_types[type]._num; idx++) {
@@ -1257,9 +1257,9 @@ void ScummEngine::saveOrLoad(Serializer *s) {
}
s->saveUint16(0xFFFF); // End marker
} else {
- while ((type = s->loadUint16()) != 0xFFFF) {
+ while ((type = (ResType)s->loadUint16()) != 0xFFFF) {
while ((idx = s->loadUint16()) != 0xFFFF) {
- assert(0 <= idx && idx < _res->_types[type]._num);
+ assert(idx < _res->_types[type]._num);
loadResource(s, type, idx);
}
}
@@ -1268,7 +1268,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// Old, fragile resource save/load system. Doesn't save resources
// with index 0, and breaks whenever we change the limit on a given
// resource type.
- for (type = rtFirst; type <= rtLast; type++)
+ for (type = rtFirst; type <= rtLast; type = ResType(type + 1))
if (_res->_types[type]._mode != kStaticResTypeMode && type != rtTemp && type != rtBuffer) {
// For V1-V5 games, there used to be no object name resources.
// At some point this changed. But since old savegames rely on
@@ -1387,18 +1387,18 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// Save/load a list of the locked objects
//
if (s->isSaving()) {
- for (i = rtFirst; i <= rtLast; i++)
- for (j = 1; j < _res->_types[i]._num; j++) {
- if (_res->isLocked(i, j)) {
- s->saveByte(i);
- s->saveUint16(j);
+ for (type = rtFirst; type <= rtLast; type = ResType(type + 1))
+ for (idx = 1; idx < _res->_types[type]._num; idx++) {
+ if (_res->isLocked(type, idx)) {
+ s->saveByte(type);
+ s->saveUint16(idx);
}
}
s->saveByte(0xFF);
} else {
- while ((i = s->loadByte()) != 0xFF) {
- j = s->loadUint16();
- _res->lock(i, j);
+ while ((type = (ResType)s->loadByte()) != 0xFF) {
+ idx = s->loadUint16();
+ _res->lock(type, idx);
}
}
@@ -1633,7 +1633,7 @@ void ScummEngine_v100he::saveOrLoad(Serializer *s) {
}
#endif
-void ScummEngine::loadResourceOLD(Serializer *ser, int type, int idx) {
+void ScummEngine::loadResourceOLD(Serializer *ser, ResType type, ResId idx) {
uint32 size;
if (type == rtSound && ser->getVersion() >= VER(23)) {
@@ -1662,7 +1662,7 @@ void ScummEngine::loadResourceOLD(Serializer *ser, int type, int idx) {
}
}
-void ScummEngine::saveResource(Serializer *ser, int type, int idx) {
+void ScummEngine::saveResource(Serializer *ser, ResType type, ResId idx) {
assert(_res->_types[type]._resources[idx]._address);
if (_res->_types[type]._mode == kDynamicResTypeMode) {
@@ -1681,7 +1681,7 @@ void ScummEngine::saveResource(Serializer *ser, int type, int idx) {
}
}
-void ScummEngine::loadResource(Serializer *ser, int type, int idx) {
+void ScummEngine::loadResource(Serializer *ser, ResType type, ResId idx) {
if (_game.heversion >= 60 && ser->getVersion() <= VER(65) &&
((type == rtSound && idx == 1) || (type == rtSpoolBuffer))) {
uint32 size = ser->loadUint32();