aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorChristopher Page2008-08-04 22:34:07 +0000
committerChristopher Page2008-08-04 22:34:07 +0000
commit4198ee962399305a4a158b1f43224c00e2e04a1b (patch)
treeeea375b5cb471509df2e2c5d9123d963a62403c6 /engines/gob
parenta51f45407659bba43254b466d20b6af2e8f17ffd (diff)
parent4f5479ee744ac6b419cdf7ec1e96fbf7c83d36ef (diff)
downloadscummvm-rg350-4198ee962399305a4a158b1f43224c00e2e04a1b.tar.gz
scummvm-rg350-4198ee962399305a4a158b1f43224c00e2e04a1b.tar.bz2
scummvm-rg350-4198ee962399305a4a158b1f43224c00e2e04a1b.zip
Merged revisions 33188-33189,33191-33193,33196,33198,33202-33203,33206,33210,33212,33218-33220,33222,33224-33226,33229-33243,33246,33248-33250,33252,33258-33261,33263,33266,33270,33272-33283,33285,33287-33290,33295-33298,33321,33325-33330,33332-33335,33337-33340,33342,33345,33347,33349-33350,33352-33357,33359-33367,33369-33371,33373,33375-33377,33379-33380,33383-33385,33387-33389,33392-33394,33400-33402,33404-33405,33407-33410,33412-33416,33418-33419,33425-33427,33432,33436-33438,33444,33446,33452-33453,33455-33459,33463-33464,33466-33471,33473-33474,33478,33490,33492,33495-33496,33509-33512,33518-33519,33522-33527,33529-33530,33537,33541,33544,33546,33550,33552-33554,33556,33558,33561-33562,33565,33568,33570,33574,33576,33578-33581,33584-33587,33590,33596,33604-33611,33614-33615,33617-33618,33620-33621 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk svn-id: r33624
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/dataio.cpp11
-rw-r--r--engines/gob/dataio.h6
-rw-r--r--engines/gob/gob.cpp9
-rw-r--r--engines/gob/gob.h6
-rw-r--r--engines/gob/inter.cpp4
-rw-r--r--engines/gob/saveload.cpp49
-rw-r--r--engines/gob/saveload.h29
-rw-r--r--engines/gob/saveload_v2.cpp20
-rw-r--r--engines/gob/saveload_v3.cpp34
-rw-r--r--engines/gob/saveload_v4.cpp24
10 files changed, 118 insertions, 74 deletions
diff --git a/engines/gob/dataio.cpp b/engines/gob/dataio.cpp
index 8ae11b8755..bcf566d134 100644
--- a/engines/gob/dataio.cpp
+++ b/engines/gob/dataio.cpp
@@ -202,7 +202,7 @@ const Common::File *DataIO::file_getHandle(int16 handle) const {
return &_filesHandles[handle];
}
-int16 DataIO::file_open(const char *path, Common::File::AccessMode mode) {
+int16 DataIO::file_open(const char *path) {
int16 i;
for (i = 0; i < MAX_FILES; i++) {
@@ -212,7 +212,7 @@ int16 DataIO::file_open(const char *path, Common::File::AccessMode mode) {
if (i == MAX_FILES)
return -1;
- file_getHandle(i)->open(path, mode);
+ file_getHandle(i)->open(path);
if (file_getHandle(i)->isOpen())
return i;
@@ -467,17 +467,14 @@ void DataIO::closeData(int16 handle) {
file_getHandle(handle)->close();
}
-int16 DataIO::openData(const char *path, Common::File::AccessMode mode) {
+int16 DataIO::openData(const char *path) {
int16 handle;
- if (mode != Common::File::kFileReadMode)
- return file_open(path, mode);
-
handle = getChunk(path);
if (handle >= 0)
return handle;
- return file_open(path, mode);
+ return file_open(path);
}
DataStream *DataIO::openAsStream(int16 handle, bool dispose) {
diff --git a/engines/gob/dataio.h b/engines/gob/dataio.h
index a990dbeda5..4b4c79d1eb 100644
--- a/engines/gob/dataio.h
+++ b/engines/gob/dataio.h
@@ -79,8 +79,7 @@ public:
void closeDataFile(bool itk = 0);
byte *getUnpackedData(const char *name);
void closeData(int16 handle);
- int16 openData(const char *path,
- Common::File::AccessMode mode = Common::File::kFileReadMode);
+ int16 openData(const char *path);
DataStream *openAsStream(int16 handle, bool dispose = false);
int32 getDataSize(const char *name);
@@ -104,8 +103,7 @@ protected:
class GobEngine *_vm;
- int16 file_open(const char *path,
- Common::File::AccessMode mode = Common::File::kFileReadMode);
+ int16 file_open(const char *path);
Common::File *file_getHandle(int16 handle);
const Common::File *file_getHandle(int16 handle) const;
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index a8cbfa0550..d64ce3c9cc 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -141,6 +141,15 @@ void GobEngine::validateVideoMode(int16 videoMode) {
error("Video mode 0x%X is not supported!", videoMode);
}
+Endianness GobEngine::getEndianness() const {
+ if ((_vm->getPlatform() == Common::kPlatformAmiga) ||
+ (_vm->getPlatform() == Common::kPlatformMacintosh) ||
+ (_vm->getPlatform() == Common::kPlatformAtariST))
+ return kEndiannessBE;
+
+ return kEndiannessLE;
+}
+
Common::Platform GobEngine::getPlatform() const {
return _platform;
}
diff --git a/engines/gob/gob.h b/engines/gob/gob.h
index 842a1dc59f..485389f990 100644
--- a/engines/gob/gob.h
+++ b/engines/gob/gob.h
@@ -79,6 +79,11 @@ class SaveLoad;
#define VAR(var) READ_VAR_UINT32(var)
+enum Endianness {
+ kEndiannessLE,
+ kEndiannessBE
+};
+
enum GameType {
kGameTypeNone = 0,
kGameTypeGob1,
@@ -227,6 +232,7 @@ public:
void validateLanguage();
void validateVideoMode(int16 videoMode);
+ Endianness getEndianness() const;
Common::Platform getPlatform() const;
GameType getGameType() const;
bool isCD() const;
diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp
index c0a1bfc21a..4973bd756d 100644
--- a/engines/gob/inter.cpp
+++ b/engines/gob/inter.cpp
@@ -296,9 +296,7 @@ void Inter::callSub(int16 retFlag) {
}
void Inter::allocateVars(uint32 count) {
- if ((_vm->getPlatform() == Common::kPlatformAmiga) ||
- (_vm->getPlatform() == Common::kPlatformMacintosh) ||
- (_vm->getPlatform() == Common::kPlatformAtariST))
+ if (_vm->getEndianness() == kEndiannessBE)
_variables = new VariablesBE(count * 4);
else
_variables = new VariablesLE(count * 4);
diff --git a/engines/gob/saveload.cpp b/engines/gob/saveload.cpp
index 2788716858..fa9f8ea7a9 100644
--- a/engines/gob/saveload.cpp
+++ b/engines/gob/saveload.cpp
@@ -153,7 +153,7 @@ bool TempSprite::fromBuffer(const byte *buffer, int32 size, bool palette) {
}
-PlainSave::PlainSave() {
+PlainSave::PlainSave(Endianness endianness) : _endianness(endianness) {
}
PlainSave::~PlainSave() {
@@ -230,7 +230,8 @@ bool PlainSave::save(int16 dataVar, int32 size, int32 offset, const char *name,
}
bool retVal;
- retVal = SaveLoad::saveDataEndian(*out, dataVar, size, variables, variableSizes);
+ retVal = SaveLoad::saveDataEndian(*out, dataVar, size,
+ variables, variableSizes, _endianness);
out->finalize();
if (out->ioFailed()) {
@@ -258,13 +259,14 @@ bool PlainSave::load(int16 dataVar, int32 size, int32 offset, const char *name,
return false;
}
- bool retVal = SaveLoad::loadDataEndian(*in, dataVar, size, variables, variableSizes);
+ bool retVal = SaveLoad::loadDataEndian(*in, dataVar, size,
+ variables, variableSizes, _endianness);
delete in;
return retVal;
}
-StagedSave::StagedSave() {
+StagedSave::StagedSave(Endianness endianness) : _endianness(endianness) {
_mode = kModeNone;
_name = 0;
_loaded = false;
@@ -487,7 +489,7 @@ bool StagedSave::write() const {
} else
result = SaveLoad::saveDataEndian(*out, 0, _stages[i].size,
- _stages[i].bufVar, _stages[i].bufVarSizes);
+ _stages[i].bufVar, _stages[i].bufVarSizes, _endianness);
}
if (result) {
@@ -533,7 +535,7 @@ bool StagedSave::read() {
_stages[i].bufVarSizes = new byte[_stages[i].size];
result = SaveLoad::loadDataEndian(*in, 0, _stages[i].size,
- _stages[i].bufVar, _stages[i].bufVarSizes);
+ _stages[i].bufVar, _stages[i].bufVarSizes, _endianness);
}
}
@@ -734,12 +736,14 @@ void SaveLoad::buildIndex(byte *buffer, char *name, int n, int32 size, int32 off
}
}
-bool SaveLoad::fromEndian(byte *buf, const byte *sizes, uint32 count) {
+bool SaveLoad::fromEndian(byte *buf, const byte *sizes, uint32 count, Endianness endianness) {
+ bool LE = (endianness == kEndiannessLE);
+
while (count-- > 0) {
if (*sizes == 3)
- *((uint32 *) buf) = READ_LE_UINT32(buf);
+ *((uint32 *) buf) = LE ? READ_LE_UINT32(buf) : READ_BE_UINT32(buf);
else if (*sizes == 1)
- *((uint16 *) buf) = READ_LE_UINT16(buf);
+ *((uint16 *) buf) = LE ? READ_LE_UINT16(buf) : READ_BE_UINT16(buf);
else if (*sizes != 0) {
warning("SaveLoad::fromEndian(): Corrupted variables sizes");
return false;
@@ -753,12 +757,19 @@ bool SaveLoad::fromEndian(byte *buf, const byte *sizes, uint32 count) {
return true;
}
-bool SaveLoad::toEndian(byte *buf, const byte *sizes, uint32 count) {
+bool SaveLoad::toEndian(byte *buf, const byte *sizes, uint32 count, Endianness endianness) {
while (count-- > 0) {
- if (*sizes == 3)
- WRITE_LE_UINT32(buf, *((uint32 *) buf));
- else if (*sizes == 1)
- WRITE_LE_UINT16(buf, *((uint16 *) buf));
+ if (*sizes == 3) {
+ if (endianness == kEndiannessLE)
+ WRITE_LE_UINT32(buf, *((uint32 *) buf));
+ else
+ WRITE_BE_UINT32(buf, *((uint32 *) buf));
+ } else if (*sizes == 1) {
+ if (endianness == kEndiannessLE)
+ WRITE_LE_UINT16(buf, *((uint16 *) buf));
+ else
+ WRITE_BE_UINT16(buf, *((uint16 *) buf));
+ }
else if (*sizes != 0) {
warning("SaveLoad::toEndian(): Corrupted variables sizes");
return false;
@@ -811,7 +822,8 @@ uint32 SaveLoad::write(Common::WriteStream &out,
}
bool SaveLoad::loadDataEndian(Common::ReadStream &in,
- int16 dataVar, uint32 size, byte *variables, byte *variableSizes) {
+ int16 dataVar, uint32 size,
+ byte *variables, byte *variableSizes, Endianness endianness) {
bool retVal = false;
@@ -821,7 +833,7 @@ bool SaveLoad::loadDataEndian(Common::ReadStream &in,
assert(varBuf && sizeBuf);
if (read(in, varBuf, sizeBuf, size) == size) {
- if (fromEndian(varBuf, sizeBuf, size)) {
+ if (fromEndian(varBuf, sizeBuf, size, endianness)) {
memcpy(variables + dataVar, varBuf, size);
memcpy(variableSizes + dataVar, sizeBuf, size);
retVal = true;
@@ -835,7 +847,8 @@ bool SaveLoad::loadDataEndian(Common::ReadStream &in,
}
bool SaveLoad::saveDataEndian(Common::WriteStream &out,
- int16 dataVar, uint32 size, const byte *variables, const byte *variableSizes) {
+ int16 dataVar, uint32 size,
+ const byte *variables, const byte *variableSizes, Endianness endianness) {
bool retVal = false;
@@ -847,7 +860,7 @@ bool SaveLoad::saveDataEndian(Common::WriteStream &out,
memcpy(varBuf, variables + dataVar, size);
memcpy(sizeBuf, variableSizes + dataVar, size);
- if (toEndian(varBuf, sizeBuf, size))
+ if (toEndian(varBuf, sizeBuf, size, endianness))
if (write(out, varBuf, sizeBuf, size) == size)
retVal = true;
diff --git a/engines/gob/saveload.h b/engines/gob/saveload.h
index 29f7ee2594..52c3a9b260 100644
--- a/engines/gob/saveload.h
+++ b/engines/gob/saveload.h
@@ -65,7 +65,7 @@ private:
class PlainSave {
public:
- PlainSave();
+ PlainSave(Endianness endianness);
~PlainSave();
bool save(int16 dataVar, int32 size, int32 offset, const char *name,
@@ -77,11 +77,14 @@ public:
const byte *variables, const byte *variableSizes) const;
bool load(int16 dataVar, int32 size, int32 offset, const char *name,
byte *variables, byte *variableSizes) const;
+
+private:
+ Endianness _endianness;
};
class StagedSave {
public:
- StagedSave();
+ StagedSave(Endianness endianness);
~StagedSave();
void addStage(int32 size, bool endianed = true);
@@ -114,6 +117,8 @@ private:
kModeLoad
};
+ Endianness _endianness;
+
Common::Array<Stage> _stages;
enum Mode _mode;
char *_name;
@@ -178,17 +183,19 @@ public:
static const char *stripPath(const char *fileName);
- static bool fromEndian(byte *buf, const byte *sizes, uint32 count);
- static bool toEndian(byte *buf, const byte *sizes, uint32 count);
+ static bool fromEndian(byte *buf, const byte *sizes, uint32 count, Endianness endianness);
+ static bool toEndian(byte *buf, const byte *sizes, uint32 count, Endianness endianness);
static uint32 read(Common::ReadStream &in,
byte *buf, byte *sizes, uint32 count);
static uint32 write(Common::WriteStream &out,
const byte *buf, const byte *sizes, uint32 count);
static bool loadDataEndian(Common::ReadStream &in,
- int16 dataVar, uint32 size, byte *variables, byte *variableSizes);
+ int16 dataVar, uint32 size,
+ byte *variables, byte *variableSizes, Endianness endianness);
static bool saveDataEndian(Common::WriteStream &out,
- int16 dataVar, uint32 size, const byte *variables, const byte *variableSizes);
+ int16 dataVar, uint32 size,
+ const byte *variables, const byte *variableSizes, Endianness endianness);
protected:
GobEngine *_vm;
@@ -228,8 +235,8 @@ protected:
int32 _varSize;
TempSprite _tmpSprite;
- PlainSave _notes;
- StagedSave _save;
+ PlainSave *_notes;
+ StagedSave *_save;
byte _indexBuffer[600];
bool _hasIndex;
@@ -306,8 +313,8 @@ protected:
TempSprite _screenshot;
TempSprite _tmpSprite;
- PlainSave _notes;
- StagedSave _save;
+ PlainSave *_notes;
+ StagedSave *_save;
byte _propBuffer[1000];
byte _indexBuffer[1200];
@@ -370,7 +377,7 @@ protected:
int32 _varSize;
- StagedSave _save;
+ StagedSave *_save;
byte _propBuffer[1000];
byte _indexBuffer[1200];
diff --git a/engines/gob/saveload_v2.cpp b/engines/gob/saveload_v2.cpp
index a92fe8cf01..fc11950368 100644
--- a/engines/gob/saveload_v2.cpp
+++ b/engines/gob/saveload_v2.cpp
@@ -45,6 +45,9 @@ SaveLoad_v2::SaveFile SaveLoad_v2::_saveFiles[] = {
SaveLoad_v2::SaveLoad_v2(GobEngine *vm, const char *targetName) :
SaveLoad(vm, targetName) {
+ _notes = new PlainSave(_vm->getEndianness());
+ _save = new StagedSave(_vm->getEndianness());
+
_saveFiles[0].destName = new char[strlen(targetName) + 5];
_saveFiles[1].destName = _saveFiles[0].destName;
_saveFiles[2].destName = 0;
@@ -58,6 +61,9 @@ SaveLoad_v2::SaveLoad_v2(GobEngine *vm, const char *targetName) :
}
SaveLoad_v2::~SaveLoad_v2() {
+ delete _notes;
+ delete _save;
+
delete[] _saveFiles[0].destName;
delete[] _saveFiles[3].destName;
}
@@ -227,7 +233,7 @@ bool SaveLoad_v2::loadGame(SaveFile &saveFile,
return false;
}
- if (!_save.load(dataVar, size, 40, saveFile.destName, _vm->_inter->_variables))
+ if (!_save->load(dataVar, size, 40, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -268,7 +274,7 @@ bool SaveLoad_v2::loadNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Loading the notes");
- return _notes.load(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
+ return _notes->load(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
}
bool SaveLoad_v2::saveGame(SaveFile &saveFile,
@@ -313,10 +319,10 @@ bool SaveLoad_v2::saveGame(SaveFile &saveFile,
byte sizes[40];
memset(sizes, 0, 40);
- if(!_save.save(0, 40, 0, saveFile.destName, _indexBuffer + (slot * 40), sizes))
+ if(!_save->save(0, 40, 0, saveFile.destName, _indexBuffer + (slot * 40), sizes))
return false;
- if (!_save.save(dataVar, size, 40, saveFile.destName, _vm->_inter->_variables))
+ if (!_save->save(dataVar, size, 40, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -350,7 +356,7 @@ bool SaveLoad_v2::saveNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Saving the notes");
- return _notes.save(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
+ return _notes->save(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
return false;
}
@@ -360,8 +366,8 @@ void SaveLoad_v2::assertInited() {
_varSize = READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4;
- _save.addStage(40);
- _save.addStage(_varSize);
+ _save->addStage(40);
+ _save->addStage(_varSize);
}
} // End of namespace Gob
diff --git a/engines/gob/saveload_v3.cpp b/engines/gob/saveload_v3.cpp
index 67879db3d1..dab5fd9385 100644
--- a/engines/gob/saveload_v3.cpp
+++ b/engines/gob/saveload_v3.cpp
@@ -48,6 +48,9 @@ SaveLoad_v3::SaveLoad_v3(GobEngine *vm, const char *targetName,
uint32 screenshotSize, int32 indexOffset, int32 screenshotOffset) :
SaveLoad(vm, targetName) {
+ _notes = new PlainSave(_vm->getEndianness());
+ _save = new StagedSave(_vm->getEndianness());
+
_screenshotSize = screenshotSize;
_indexOffset = indexOffset;
_screenshotOffset = screenshotOffset;
@@ -71,6 +74,9 @@ SaveLoad_v3::SaveLoad_v3(GobEngine *vm, const char *targetName,
}
SaveLoad_v3::~SaveLoad_v3() {
+ delete _notes;
+ delete _save;
+
delete[] _saveFiles[0].destName;
delete[] _saveFiles[3].destName;
}
@@ -243,7 +249,7 @@ int32 SaveLoad_v3::getSizeNotes(SaveFile &saveFile) {
int32 SaveLoad_v3::getSizeScreenshot(SaveFile &saveFile) {
if (!_useScreenshots) {
_useScreenshots = true;
- _save.addStage(_screenshotSize, false);
+ _save->addStage(_screenshotSize, false);
}
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
@@ -312,7 +318,7 @@ bool SaveLoad_v3::loadGame(SaveFile &saveFile,
return false;
}
- if (!_save.load(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
+ if (!_save->load(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -353,7 +359,7 @@ bool SaveLoad_v3::loadNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Loading the notes");
- return _notes.load(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
+ return _notes->load(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
}
bool SaveLoad_v3::loadScreenshot(SaveFile &saveFile,
@@ -363,7 +369,7 @@ bool SaveLoad_v3::loadScreenshot(SaveFile &saveFile,
if (!_useScreenshots) {
_useScreenshots = true;
- _save.addStage(_screenshotSize, false);
+ _save->addStage(_screenshotSize, false);
}
if (offset == _indexOffset) {
@@ -395,7 +401,7 @@ bool SaveLoad_v3::loadScreenshot(SaveFile &saveFile,
byte *buffer = new byte[_screenshotSize];
- if (!_save.load(0, _screenshotSize, _varSize + 540, saveFile.destName, buffer, 0)) {
+ if (!_save->load(0, _screenshotSize, _varSize + 540, saveFile.destName, buffer, 0)) {
delete[] buffer;
return false;
}
@@ -483,13 +489,13 @@ bool SaveLoad_v3::saveGame(SaveFile &saveFile,
_hasIndex = false;
- if(!_save.save(0, 500, 0, saveFile.destName, _propBuffer, _propBuffer + 500))
+ if(!_save->save(0, 500, 0, saveFile.destName, _propBuffer, _propBuffer + 500))
return false;
- if(!_save.save(0, 40, 500, saveFile.destName, _indexBuffer + (saveFile.slot * 40), 0))
+ if(!_save->save(0, 40, 500, saveFile.destName, _indexBuffer + (saveFile.slot * 40), 0))
return false;
- if (!_save.save(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
+ if (!_save->save(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -523,7 +529,7 @@ bool SaveLoad_v3::saveNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Saving the notes");
- return _notes.save(dataVar, size - 160, offset, saveFile.destName, _vm->_inter->_variables);
+ return _notes->save(dataVar, size - 160, offset, saveFile.destName, _vm->_inter->_variables);
return false;
}
@@ -534,7 +540,7 @@ bool SaveLoad_v3::saveScreenshot(SaveFile &saveFile,
if (!_useScreenshots) {
_useScreenshots = true;
- _save.addStage(_screenshotSize, false);
+ _save->addStage(_screenshotSize, false);
}
if (offset >= _screenshotOffset) {
@@ -571,7 +577,7 @@ bool SaveLoad_v3::saveScreenshot(SaveFile &saveFile,
return false;
}
- if (!_save.save(0, _screenshotSize, _varSize + 540, saveFile.destName, buffer, 0)) {
+ if (!_save->save(0, _screenshotSize, _varSize + 540, saveFile.destName, buffer, 0)) {
delete[] buffer;
return false;
}
@@ -588,9 +594,9 @@ void SaveLoad_v3::assertInited() {
_varSize = READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4;
- _save.addStage(500);
- _save.addStage(40, false);
- _save.addStage(_varSize);
+ _save->addStage(500);
+ _save->addStage(40, false);
+ _save->addStage(_varSize);
}
void SaveLoad_v3::buildScreenshotIndex(byte *buffer, char *name, int n) {
diff --git a/engines/gob/saveload_v4.cpp b/engines/gob/saveload_v4.cpp
index a6548dd82d..0bd3dc03e6 100644
--- a/engines/gob/saveload_v4.cpp
+++ b/engines/gob/saveload_v4.cpp
@@ -50,6 +50,8 @@ SaveLoad_v4::SaveFile SaveLoad_v4::_saveFiles[] = {
SaveLoad_v4::SaveLoad_v4(GobEngine *vm, const char *targetName) :
SaveLoad(vm, targetName) {
+ _save = new StagedSave(_vm->getEndianness());
+
_firstSizeGame = true;
_saveFiles[0].destName = 0;
@@ -76,6 +78,8 @@ SaveLoad_v4::SaveLoad_v4(GobEngine *vm, const char *targetName) :
}
SaveLoad_v4::~SaveLoad_v4() {
+ delete _save;
+
delete[] _screenProps;
delete[] _saveFiles[1].destName;
}
@@ -297,7 +301,7 @@ bool SaveLoad_v4::loadGame(SaveFile &saveFile,
return false;
}
- if (!_save.load(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
+ if (!_save->load(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -314,7 +318,7 @@ bool SaveLoad_v4::loadGameScreenProps(SaveFile &saveFile,
setCurrentSlot(saveFile.destName, saveFile.sourceName[4] - '0');
- if (!_save.load(0, 256000, _varSize + 540, saveFile.destName,
+ if (!_save->load(0, 256000, _varSize + 540, saveFile.destName,
_screenProps, _screenProps + 256000))
return false;
@@ -393,13 +397,13 @@ bool SaveLoad_v4::saveGame(SaveFile &saveFile,
_hasIndex = false;
- if(!_save.save(0, 500, 0, saveFile.destName, _propBuffer, _propBuffer + 500))
+ if(!_save->save(0, 500, 0, saveFile.destName, _propBuffer, _propBuffer + 500))
return false;
- if(!_save.save(0, 40, 500, saveFile.destName, _indexBuffer + (slot * 40), 0))
+ if(!_save->save(0, 40, 500, saveFile.destName, _indexBuffer + (slot * 40), 0))
return false;
- if (!_save.save(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
+ if (!_save->save(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -417,7 +421,7 @@ bool SaveLoad_v4::saveGameScreenProps(SaveFile &saveFile,
setCurrentSlot(saveFile.destName, saveFile.sourceName[4] - '0');
- if (!_save.save(0, 256000, _varSize + 540, saveFile.destName,
+ if (!_save->save(0, 256000, _varSize + 540, saveFile.destName,
_screenProps, _screenProps + 256000))
return false;
@@ -430,10 +434,10 @@ void SaveLoad_v4::assertInited() {
_varSize = READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4;
- _save.addStage(500);
- _save.addStage(40, false);
- _save.addStage(_varSize);
- _save.addStage(256000);
+ _save->addStage(500);
+ _save->addStage(40, false);
+ _save->addStage(_varSize);
+ _save->addStage(256000);
}
} // End of namespace Gob