diff options
-rw-r--r-- | engines/gob/save/saveload.h | 42 | ||||
-rw-r--r-- | engines/gob/save/saveload_playtoons.cpp | 28 | ||||
-rw-r--r-- | engines/gob/save/saveload_v2.cpp | 14 | ||||
-rw-r--r-- | engines/gob/save/saveload_v3.cpp | 28 | ||||
-rw-r--r-- | engines/gob/save/saveload_v4.cpp | 28 | ||||
-rw-r--r-- | engines/gob/save/saveload_v6.cpp | 28 |
6 files changed, 91 insertions, 77 deletions
diff --git a/engines/gob/save/saveload.h b/engines/gob/save/saveload.h index 4779de703c..8a7d493aed 100644 --- a/engines/gob/save/saveload.h +++ b/engines/gob/save/saveload.h @@ -77,6 +77,9 @@ public: static const uint32 kSlotCount = 15; static const uint32 kSlotNameLength = 40; + /** The index. kSlotCount * kSlotNameLength bytes. */ + static const uint32 kIndexSize = kSlotCount * kSlotNameLength; + SaveLoad_v2(GobEngine *vm, const char *targetName); virtual ~SaveLoad_v2(); @@ -111,8 +114,7 @@ protected: int getSlotRemainder(int32 offset) const; }; - /** The index. kSlotCount * kSlotNameLength bytes. */ - byte _index[600]; + byte _index[kIndexSize]; bool _hasIndex; File *_slotFile; @@ -139,6 +141,10 @@ public: static const uint32 kSlotCount = 30; static const uint32 kSlotNameLength = 40; + static const uint32 kPropsSize = 500; + /** Index. kSlotCount * kSlotNameLength bytes. */ + static const uint32 kIndexSize = kSlotCount * kSlotNameLength; + enum ScreenshotType { kScreenshotTypeGob3, //!< Goblins 3 type screenshot kScreenshotTypeLost //!< Lost in Time type screenshot @@ -193,9 +199,8 @@ protected: bool _firstSize; /** Global properties. */ - byte _props[500]; - /** Index. kSlotCount * kSlotNameLength bytes. */ - byte _index[1200]; + byte _props[kPropsSize]; + byte _index[kIndexSize]; bool _hasIndex; SaveReader *_reader; @@ -266,6 +271,10 @@ public: static const uint32 kSlotCount = 10; static const uint32 kSlotNameLength = 40; + static const uint32 kPropsSize = 500; + /** Index. kSlotCount * kSlotNameLength bytes + 800 bytes 0. */ + static const uint32 kIndexSize = (kSlotCount * kSlotNameLength) + 800; + SaveLoad_v4(GobEngine *vm, const char *targetName); virtual ~SaveLoad_v4(); @@ -311,9 +320,8 @@ protected: private: bool _firstSize; - byte _props[500]; - /** The index. kSlotCount * kSlotNameLength bytes + 800 bytes 0. */ - byte _index[1200]; + byte _props[kPropsSize]; + byte _index[kIndexSize]; bool _hasIndex; File *_slotFile; @@ -392,6 +400,10 @@ public: static const uint32 kSlotCount = 60; static const uint32 kSlotNameLength = 40; + static const uint32 kPropsSize = 500; + /** Index. kSlotCount * kSlotNameLength bytes. */ + static const uint32 kIndexSize = kSlotCount * kSlotNameLength; + SaveLoad_v6(GobEngine *vm, const char *targetName); virtual ~SaveLoad_v6(); @@ -426,9 +438,8 @@ protected: int getSlotRemainder(int32 offset) const; }; - byte _props[500]; - /** The index. 500 bytes properties + kSlotCount * kSlotNameLength bytes. */ - byte _index[2400]; + byte _props[kPropsSize]; + byte _index[kIndexSize]; File *_slotFile; @@ -454,6 +465,10 @@ public: static const uint32 kSlotCount = 60; static const uint32 kSlotNameLength = 40; + static const uint32 kPropsSize = 1642; + /** Index. kSlotCount * kSlotNameLength bytes. */ + static const uint32 kIndexSize = kSlotCount * kSlotNameLength; + SaveLoad_Playtoons(GobEngine *vm, const char *targetName); virtual ~SaveLoad_Playtoons(); @@ -488,9 +503,8 @@ protected: int getSlotRemainder(int32 offset) const; }; - byte _props[500]; - /** The index. 500 bytes properties + kSlotCount * kSlotNameLength bytes. */ - byte _index[2400]; + byte _props[kPropsSize]; + byte _index[kIndexSize]; File *_slotFile; diff --git a/engines/gob/save/saveload_playtoons.cpp b/engines/gob/save/saveload_playtoons.cpp index 6b1f291c78..f1140887de 100644 --- a/engines/gob/save/saveload_playtoons.cpp +++ b/engines/gob/save/saveload_playtoons.cpp @@ -48,7 +48,7 @@ int SaveLoad_Playtoons::GameHandler::File::getSlot(int32 offset) const { if (varSize == 0) return -1; - return ((offset - (1642 + 2400)) / varSize); + return ((offset - (kPropsSize + kIndexSize)) / varSize); } int SaveLoad_Playtoons::GameHandler::File::getSlotRemainder(int32 offset) const { @@ -57,13 +57,13 @@ int SaveLoad_Playtoons::GameHandler::File::getSlotRemainder(int32 offset) const if (varSize == 0) return -1; - return ((offset - (1642 + 2400)) % varSize); + return ((offset - (kPropsSize + kIndexSize)) % varSize); } SaveLoad_Playtoons::GameHandler::GameHandler(GobEngine *vm, const char *target) : SaveHandler(vm) { - memset(_props, 0, 1642); - memset(_index, 0, 2400); + memset(_props, 0, kPropsSize); + memset(_index, 0, kIndexSize); _slotFile = new File(vm, target); } @@ -78,7 +78,7 @@ int32 SaveLoad_Playtoons::GameHandler::getSize() { if (varSize == 0) return -1; - return _slotFile->tallyUpFiles(varSize, 1642 + 2400); + return _slotFile->tallyUpFiles(varSize, kPropsSize + kIndexSize); } bool SaveLoad_Playtoons::GameHandler::load(int16 dataVar, int32 size, int32 offset) { @@ -93,20 +93,20 @@ bool SaveLoad_Playtoons::GameHandler::load(int16 dataVar, int32 size, int32 offs size = varSize; } - if (offset < 1642) { + if (offset < kPropsSize) { // Properties - if ((offset + size) > 1642) { + if ((offset + size) > kPropsSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } _vm->_inter->_variables->copyFrom(dataVar, _props + offset, size); - } else if (offset < 1642 + 2400) { + } else if (offset < kPropsSize + kIndexSize) { // Save index - if (size != 2400) { + if (size != kIndexSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } @@ -180,26 +180,26 @@ bool SaveLoad_Playtoons::GameHandler::save(int16 dataVar, int32 size, int32 offs size = varSize; } - if (offset < 1642) { + if (offset < kPropsSize) { // Properties - if ((offset + size) > 1642) { + if ((offset + size) > kPropsSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } _vm->_inter->_variables->copyTo(dataVar, _props + offset, size); - } else if (offset < 1642 + 2400) { + } else if (offset < kPropsSize + kIndexSize) { // Save index - if (size != 2400) { + if (size != kIndexSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } // Just copy the index into our buffer - _vm->_inter->_variables->copyTo(dataVar, _index, 2400); + _vm->_inter->_variables->copyTo(dataVar, _index, kIndexSize); } else { // Save slot, whole variable block diff --git a/engines/gob/save/saveload_v2.cpp b/engines/gob/save/saveload_v2.cpp index da1135df21..8449345336 100644 --- a/engines/gob/save/saveload_v2.cpp +++ b/engines/gob/save/saveload_v2.cpp @@ -51,7 +51,7 @@ int SaveLoad_v2::GameHandler::File::getSlot(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 600) / varSize); + return ((offset - kIndexSize) / varSize); } int SaveLoad_v2::GameHandler::File::getSlotRemainder(int32 offset) const { @@ -60,12 +60,12 @@ int SaveLoad_v2::GameHandler::File::getSlotRemainder(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 600) % varSize); + return ((offset - kIndexSize) % varSize); } SaveLoad_v2::GameHandler::GameHandler(GobEngine *vm, const char *target) : SaveHandler(vm) { - memset(_index, 0, 600); + memset(_index, 0, kIndexSize); _hasIndex = false; _slotFile = new File(vm, target); @@ -81,7 +81,7 @@ int32 SaveLoad_v2::GameHandler::getSize() { if (varSize == 0) return -1; - return _slotFile->tallyUpFiles(varSize, 600); + return _slotFile->tallyUpFiles(varSize, kIndexSize); } bool SaveLoad_v2::GameHandler::load(int16 dataVar, int32 size, int32 offset) { @@ -99,7 +99,7 @@ bool SaveLoad_v2::GameHandler::load(int16 dataVar, int32 size, int32 offset) { if (offset == 0) { // Save index - if (size != 600) { + if (size != kIndexSize) { warning("Requested index has wrong size (%d)", size); return false; } @@ -184,13 +184,13 @@ bool SaveLoad_v2::GameHandler::save(int16 dataVar, int32 size, int32 offset) { if (offset == 0) { // Save index - if (size != 600) { + if (size != kIndexSize) { warning("Requested index has wrong size (%d)", size); return false; } // Just copy the index into our buffer - _vm->_inter->_variables->copyTo(dataVar, _index, 600); + _vm->_inter->_variables->copyTo(dataVar, _index, kIndexSize); _hasIndex = true; } else { diff --git a/engines/gob/save/saveload_v3.cpp b/engines/gob/save/saveload_v3.cpp index c24b13d27b..510ca622b8 100644 --- a/engines/gob/save/saveload_v3.cpp +++ b/engines/gob/save/saveload_v3.cpp @@ -57,7 +57,7 @@ int SaveLoad_v3::GameHandler::File::getSlot(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 1700) / varSize); + return ((offset - (kPropsSize + kIndexSize)) / varSize); } int SaveLoad_v3::GameHandler::File::getSlotRemainder(int32 offset) const { @@ -66,7 +66,7 @@ int SaveLoad_v3::GameHandler::File::getSlotRemainder(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 1700) % varSize); + return ((offset - (kPropsSize + kIndexSize)) % varSize); } @@ -78,8 +78,8 @@ SaveLoad_v3::GameHandler::GameHandler(GobEngine *vm, const char *target, _usesScreenshots = usesScreenshots; _firstSize = true; - memset(_props, 0, 500); - memset(_index, 0, 1200); + memset(_props, 0, kPropsSize); + memset(_index, 0, kIndexSize); _hasIndex = false; _writer = 0; @@ -104,7 +104,7 @@ int32 SaveLoad_v3::GameHandler::getSize() { if (varSize == 0) return -1; - return _slotFile->tallyUpFiles(varSize, 1700); + return _slotFile->tallyUpFiles(varSize, kPropsSize + kIndexSize); } bool SaveLoad_v3::GameHandler::load(int16 dataVar, int32 size, int32 offset) { @@ -119,22 +119,22 @@ bool SaveLoad_v3::GameHandler::load(int16 dataVar, int32 size, int32 offset) { size = varSize; } - if (offset < 500) { + if (offset < kPropsSize) { // Global properties, like joker usage debugC(3, kDebugSaveLoad, "Loading global properties"); - if ((size + offset) > 500) { + if ((size + offset) > kPropsSize) { warning("Wrong global properties list size (%d, %d)", size, offset); return false; } _vm->_inter->_variables->copyFrom(dataVar, _props + offset, size); - } else if (offset == 500) { + } else if (offset == kPropsSize) { // Save index - if (size != 1200) { + if (size != kIndexSize) { warning("Requested index has wrong size (%d)", size); return false; } @@ -193,28 +193,28 @@ bool SaveLoad_v3::GameHandler::save(int16 dataVar, int32 size, int32 offset) { size = varSize; } - if (offset < 500) { + if (offset < kPropsSize) { // Global properties, like joker usage debugC(3, kDebugSaveLoad, "Saving global properties"); - if ((size + offset) > 500) { + if ((size + offset) > kPropsSize) { warning("Wrong global properties list size (%d, %d)", size, offset); return false; } _vm->_inter->_variables->copyTo(dataVar, _props + offset, size); - } else if (offset == 500) { + } else if (offset == kPropsSize) { // Save index - if (size != 1200) { + if (size != kIndexSize) { warning("Requested index has wrong size (%d)", size); return false; } // Just copy the index into our buffer - _vm->_inter->_variables->copyTo(dataVar, _index, 1200); + _vm->_inter->_variables->copyTo(dataVar, _index, kIndexSize); _hasIndex = true; } else { diff --git a/engines/gob/save/saveload_v4.cpp b/engines/gob/save/saveload_v4.cpp index 16c87b9a64..66270161d3 100644 --- a/engines/gob/save/saveload_v4.cpp +++ b/engines/gob/save/saveload_v4.cpp @@ -63,7 +63,7 @@ int SaveLoad_v4::GameHandler::File::getSlot(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 1700) / varSize); + return ((offset - (kPropsSize + kIndexSize)) / varSize); } int SaveLoad_v4::GameHandler::File::getSlotRemainder(int32 offset) const { @@ -72,14 +72,14 @@ int SaveLoad_v4::GameHandler::File::getSlotRemainder(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 1700) % varSize); + return ((offset - (kPropsSize + kIndexSize)) % varSize); } SaveLoad_v4::GameHandler::GameHandler(GobEngine *vm, const char *target) : SaveHandler(vm) { _firstSize = true; - memset(_props, 0, 500); - memset(_index, 0, 1200); + memset(_props, 0, kPropsSize); + memset(_index, 0, kIndexSize); _hasIndex = false; _slotFile = new File(vm, target); @@ -112,7 +112,7 @@ int32 SaveLoad_v4::GameHandler::getSize() { if (varSize == 0) return -1; - return _slotFile->tallyUpFiles(varSize, 1700); + return _slotFile->tallyUpFiles(varSize, kPropsSize + kIndexSize); } bool SaveLoad_v4::GameHandler::load(int16 dataVar, int32 size, int32 offset) { @@ -127,22 +127,22 @@ bool SaveLoad_v4::GameHandler::load(int16 dataVar, int32 size, int32 offset) { size = varSize; } - if (offset < 500) { + if (offset < kPropsSize) { // Global properties debugC(3, kDebugSaveLoad, "Loading global properties"); - if ((size + offset) > 500) { + if ((size + offset) > kPropsSize) { warning("Wrong global properties list size (%d, %d)", size, offset); return false; } _vm->_inter->_variables->copyFrom(dataVar, _props + offset, size); - } else if (offset == 500) { + } else if (offset == kPropsSize) { // Save index - if (size != 1200) { + if (size != kIndexSize) { warning("Requested index has wrong size (%d)", size); return false; } @@ -202,28 +202,28 @@ bool SaveLoad_v4::GameHandler::save(int16 dataVar, int32 size, int32 offset) { size = varSize; } - if (offset < 500) { + if (offset < kPropsSize) { // Global properties debugC(3, kDebugSaveLoad, "Saving global properties"); - if ((size + offset) > 500) { + if ((size + offset) > kPropsSize) { warning("Wrong global properties list size (%d, %d)", size, offset); return false; } _vm->_inter->_variables->copyTo(dataVar, _props + offset, size); - } else if (offset == 500) { + } else if (offset == kPropsSize) { // Save index - if (size != 1200) { + if (size != kIndexSize) { warning("Requested index has wrong size (%d)", size); return false; } // Just copy the index into our buffer - _vm->_inter->_variables->copyTo(dataVar, _index, 1200); + _vm->_inter->_variables->copyTo(dataVar, _index, kIndexSize); _hasIndex = true; } else { diff --git a/engines/gob/save/saveload_v6.cpp b/engines/gob/save/saveload_v6.cpp index 45622bee73..297f23122c 100644 --- a/engines/gob/save/saveload_v6.cpp +++ b/engines/gob/save/saveload_v6.cpp @@ -50,7 +50,7 @@ int SaveLoad_v6::GameHandler::File::getSlot(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 2900) / varSize); + return ((offset - (kPropsSize + kIndexSize)) / varSize); } int SaveLoad_v6::GameHandler::File::getSlotRemainder(int32 offset) const { @@ -59,13 +59,13 @@ int SaveLoad_v6::GameHandler::File::getSlotRemainder(int32 offset) const { if (varSize == 0) return -1; - return ((offset - 2900) % varSize); + return ((offset - (kPropsSize + kIndexSize)) % varSize); } SaveLoad_v6::GameHandler::GameHandler(GobEngine *vm, const char *target) : SaveHandler(vm) { - memset(_props, 0, 500); - memset(_index, 0, 2400); + memset(_props, 0, kPropsSize); + memset(_index, 0, kIndexSize); _slotFile = new File(vm, target); } @@ -80,7 +80,7 @@ int32 SaveLoad_v6::GameHandler::getSize() { if (varSize == 0) return -1; - return _slotFile->tallyUpFiles(varSize, 2900); + return _slotFile->tallyUpFiles(varSize, kPropsSize + kIndexSize); } bool SaveLoad_v6::GameHandler::load(int16 dataVar, int32 size, int32 offset) { @@ -95,22 +95,22 @@ bool SaveLoad_v6::GameHandler::load(int16 dataVar, int32 size, int32 offset) { size = varSize; } - if (offset < 500) { + if (offset < kPropsSize) { // Properties refreshProps(); - if ((offset + size) > 500) { + if ((offset + size) > kPropsSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } _vm->_inter->_variables->copyFrom(dataVar, _props + offset, size); - } else if (offset < 2900) { + } else if (offset < kPropsSize + kIndexSize) { // Save index - if (size != 2400) { + if (size != kIndexSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } @@ -191,10 +191,10 @@ bool SaveLoad_v6::GameHandler::save(int16 dataVar, int32 size, int32 offset) { size = varSize; } - if (offset < 500) { + if (offset < kPropsSize) { // Properties - if ((offset + size) > 500) { + if ((offset + size) > kPropsSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } @@ -203,16 +203,16 @@ bool SaveLoad_v6::GameHandler::save(int16 dataVar, int32 size, int32 offset) { refreshProps(); - } else if (offset < 2900) { + } else if (offset < kPropsSize + kIndexSize) { // Save index - if (size != 2400) { + if (size != kIndexSize) { warning("Wrong index size (%d, %d)", size, offset); return false; } // Just copy the index into our buffer - _vm->_inter->_variables->copyTo(dataVar, _index, 2400); + _vm->_inter->_variables->copyTo(dataVar, _index, kIndexSize); } else { // Save slot, whole variable block |