diff options
author | Sven Hesse | 2008-05-28 21:15:11 +0000 |
---|---|---|
committer | Sven Hesse | 2008-05-28 21:15:11 +0000 |
commit | 8da68b29648f9dbdcc05b3a1efe4a29ed2c4e88c (patch) | |
tree | 7f2416cbf176f53a871b0cc3bea4785284ba4889 /engines/gob/saveload.cpp | |
parent | c9fd5fef7645cc7ba6e14ddfeaab91d941f3b8f7 (diff) | |
download | scummvm-rg350-8da68b29648f9dbdcc05b3a1efe4a29ed2c4e88c.tar.gz scummvm-rg350-8da68b29648f9dbdcc05b3a1efe4a29ed2c4e88c.tar.bz2 scummvm-rg350-8da68b29648f9dbdcc05b3a1efe4a29ed2c4e88c.zip |
Script variables are now always stored in the game version's native endianess.
This should make Woodruff playable on big-endian systems.
svn-id: r32352
Diffstat (limited to 'engines/gob/saveload.cpp')
-rw-r--r-- | engines/gob/saveload.cpp | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/engines/gob/saveload.cpp b/engines/gob/saveload.cpp index 50f41db47e..2788716858 100644 --- a/engines/gob/saveload.cpp +++ b/engines/gob/saveload.cpp @@ -160,6 +160,60 @@ PlainSave::~PlainSave() { } bool PlainSave::save(int16 dataVar, int32 size, int32 offset, const char *name, + const Variables *variables) { + + if ((size <= 0) || (offset != 0)) { + warning("Invalid size (%d) or offset (%d)", size, offset); + return false; + } + + byte *vars = new byte[size]; + byte *varSizes = new byte[size]; + + if (!variables->copyTo(dataVar, vars, varSizes, size)) { + delete[] vars; + delete[] varSizes; + warning("dataVar (%d) or size (%d) out of range", dataVar, size); + return false; + } + + bool result = save(0, size, offset, name, vars, varSizes); + + delete[] vars; + delete[] varSizes; + + return result; +} + +bool PlainSave::load(int16 dataVar, int32 size, int32 offset, const char *name, + Variables *variables) { + + if ((size <= 0) || (offset != 0)) { + warning("Invalid size (%d) or offset (%d)", size, offset); + return false; + } + + byte *vars = new byte[size]; + byte *varSizes = new byte[size]; + + bool result = load(0, size, offset, name, vars, varSizes); + + if (result && variables) { + if (!variables->copyFrom(dataVar, vars, varSizes, size)) { + delete[] vars; + delete[] varSizes; + warning("dataVar (%d) or size (%d) out of range", dataVar, size); + return false; + } + } + + delete[] vars; + delete[] varSizes; + + return result; +} + +bool PlainSave::save(int16 dataVar, int32 size, int32 offset, const char *name, const byte *variables, const byte *variableSizes) const { if ((size <= 0) || (offset != 0)) { @@ -286,6 +340,64 @@ void StagedSave::assertMode(Mode mode, const char *name) { } bool StagedSave::save(int16 dataVar, int32 size, int32 offset, const char *name, + const Variables *variables) { + + if ((dataVar < 0) || (size <= 0) || (offset < 0)) { + warning("Invalid dataVar (%d), size (%d) or offset (%d)", dataVar, size, offset); + return false; + } + + byte *vars = 0, *varSizes = 0; + + if (variables) { + vars = new byte[size]; + varSizes = new byte[size]; + + if (!variables->copyTo(dataVar, vars, varSizes, size)) { + delete[] vars; + delete[] varSizes; + warning("dataVar (%d) or size (%d) out of range", dataVar, size); + return false; + } + } + + bool result = save(0, size, offset, name, vars, varSizes); + + delete[] vars; + delete[] varSizes; + + return result; +} + +bool StagedSave::load(int16 dataVar, int32 size, int32 offset, const char *name, + Variables *variables) { + + if ((dataVar < 0) || (size <= 0) || (offset < 0)) { + warning("Invalid dataVar (%d), size (%d) or offset (%d)", dataVar, size, offset); + return false; + } + + byte *vars = new byte[size]; + byte *varSizes = new byte[size]; + + bool result = load(0, size, offset, name, vars, varSizes); + + if (result && variables) { + if (!variables->copyFrom(dataVar, vars, varSizes, size)) { + delete[] vars; + delete[] varSizes; + warning("dataVar (%d) or size (%d) out of range", dataVar, size); + return false; + } + } + + delete[] vars; + delete[] varSizes; + + return result; +} + +bool StagedSave::save(int16 dataVar, int32 size, int32 offset, const char *name, const byte *variables, const byte *variableSizes) { if ((dataVar < 0) || (size <= 0) || (offset < 0)) { |