diff options
author | Einar Johan Trøan Sømåen | 2012-06-27 15:15:46 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-06-27 15:15:46 +0200 |
commit | dde2d92c69e73d02c185ca3390b5ba71c0cb7fa0 (patch) | |
tree | 712f64f760852975c1dbd41846ae8c2351a33451 | |
parent | 8ecb9d937d33787a7130062664649021a06989a4 (diff) | |
download | scummvm-rg350-dde2d92c69e73d02c185ca3390b5ba71c0cb7fa0.tar.gz scummvm-rg350-dde2d92c69e73d02c185ca3390b5ba71c0cb7fa0.tar.bz2 scummvm-rg350-dde2d92c69e73d02c185ca3390b5ba71c0cb7fa0.zip |
WINTERMUTE: Fix a savegame-regression
-rw-r--r-- | engines/wintermute/Base/BPersistMgr.cpp | 2 | ||||
-rw-r--r-- | engines/wintermute/Base/scriptables/ScEngine.cpp | 2 | ||||
-rw-r--r-- | engines/wintermute/Base/scriptables/ScScript.cpp | 29 | ||||
-rw-r--r-- | engines/wintermute/Base/scriptables/ScScript.h | 1 | ||||
-rw-r--r-- | engines/wintermute/Sys/SysClassRegistry.cpp | 1 | ||||
-rw-r--r-- | engines/wintermute/dcgf.h | 2 |
6 files changed, 27 insertions, 10 deletions
diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index e5479ea8f6..5a70fd3729 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -319,6 +319,7 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD)
) {
Game->LOG(0, "ERROR: Saved game version is newer than current game");
+ Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
cleanup();
return E_FAIL;
}
@@ -329,6 +330,7 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD)
) {
Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine");
+ Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
cleanup();
return E_FAIL;
diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index a24475db7a..6ec70a561a 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -422,7 +422,7 @@ HRESULT CScEngine::Tick() { break;
}
default:
- warning("CScEngine::Tick - Unhandled enum");
+ //warning("CScEngine::Tick - Unhandled enum");
break;
} // switch
} // for each script
diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 62d5221184..4060ad8472 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -102,13 +102,9 @@ CScScript::~CScScript() { cleanup();
}
-
-
-//////////////////////////////////////////////////////////////////////////
-HRESULT CScScript::InitScript() {
- if (!_scriptStream) {
- _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize);
- }
+void CScScript::readHeader() {
+ uint32 oldPos = _scriptStream->pos();
+ _scriptStream->seek(0);
_header.magic = _scriptStream->readUint32LE();
_header.version = _scriptStream->readUint32LE();
_header.code_start = _scriptStream->readUint32LE();
@@ -117,6 +113,16 @@ HRESULT CScScript::InitScript() { _header.event_table = _scriptStream->readUint32LE();
_header.externals_table = _scriptStream->readUint32LE();
_header.method_table = _scriptStream->readUint32LE();
+ _scriptStream->seek(oldPos);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CScScript::InitScript() {
+ if (!_scriptStream) {
+ _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize);
+ }
+ readHeader();
if (_header.magic != SCRIPT_MAGIC) {
Game->LOG(0, "File '%s' is not a valid compiled script", _filename);
@@ -162,6 +168,7 @@ HRESULT CScScript::InitScript() { HRESULT CScScript::InitTables() {
uint32 OrigIP = _iP;
+ readHeader();
// load symbol table
_iP = _header.symbol_table;
@@ -1197,7 +1204,10 @@ HRESULT CScScript::persist(CBPersistMgr *persistMgr) { persistMgr->getBytes(_buffer, _bufferSize);
_scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize);
InitTables();
- } else _buffer = NULL;
+ } else {
+ _buffer = NULL;
+ _scriptStream = NULL;
+ }
}
persistMgr->transfer(TMEMBER(_callStack));
@@ -1617,6 +1627,9 @@ void CScScript::afterLoad() { _buffer = new byte [_bufferSize];
memcpy(_buffer, buffer, _bufferSize);
+ delete _scriptStream;
+ _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize);
+
InitTables();
}
}
diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 3ce878aef9..4f6cc50332 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -144,6 +144,7 @@ public: HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner);
uint32 _iP;
private:
+ void readHeader();
uint32 _bufferSize;
byte *_buffer;
public:
diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 88b45c3c3a..5ac5cb2ccf 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -37,6 +37,7 @@ namespace WinterMute { //////////////////////////////////////////////////////////////////////////
CSysClassRegistry::CSysClassRegistry() {
+ _count = 0;
}
diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 305ff0b5b7..8e222cfce3 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////////////////////
#define DCGF_VER_MAJOR 1
-#define DCGF_VER_MINOR 0
+#define DCGF_VER_MINOR 1
#define DCGF_VER_BUILD 1
#define DCGF_VER_SUFFIX "beta"
#define DCGF_VER_BETA true
|