WINTERMUTE: Fix a savegame-regression

This commit is contained in:
Einar Johan Trøan Sømåen 2012-06-27 15:15:46 +02:00
parent 8ecb9d937d
commit dde2d92c69
6 changed files with 27 additions and 10 deletions

View File

@ -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;

View File

@ -422,7 +422,7 @@ HRESULT CScEngine::Tick() {
break;
}
default:
warning("CScEngine::Tick - Unhandled enum");
//warning("CScEngine::Tick - Unhandled enum");
break;
} // switch
} // for each script

View File

@ -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();
}
}

View File

@ -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:

View File

@ -37,6 +37,7 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
CSysClassRegistry::CSysClassRegistry() {
_count = 0;
}

View File

@ -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