diff options
author | Matthew Hoops | 2011-03-23 21:45:39 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-03-23 21:45:39 -0400 |
commit | b3e27bc0d6daa31783315b7f5f40316182971e95 (patch) | |
tree | e1899c3b577d5b92c7bc94d8dc1657c94627ff45 /engines/mohawk | |
parent | aaf05b2a5986fbbaed817fdaa5d2e8f961987dd7 (diff) | |
download | scummvm-rg350-b3e27bc0d6daa31783315b7f5f40316182971e95.tar.gz scummvm-rg350-b3e27bc0d6daa31783315b7f5f40316182971e95.tar.bz2 scummvm-rg350-b3e27bc0d6daa31783315b7f5f40316182971e95.zip |
MOHAWK: Make Riven's save/load code use the variable map directly
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/riven.h | 13 | ||||
-rw-r--r-- | engines/mohawk/riven_saveload.cpp | 18 | ||||
-rw-r--r-- | engines/mohawk/riven_vars.cpp | 12 |
3 files changed, 15 insertions, 28 deletions
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 5d23678beb..413f618f96 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -106,6 +106,8 @@ struct ZipMode { bool operator== (const ZipMode& z) const; }; +typedef Common::HashMap<Common::String, uint32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> RivenVariableMap; + class MohawkEngine_Riven : public MohawkEngine { protected: Common::Error run(); @@ -153,9 +155,7 @@ private: void checkHotspotChange(); // Variables - typedef Common::HashMap<Common::String, uint32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> VariableMap; - VariableMap _vars; - uint32 _varCount; + void initVars(); // Timer TimerProc _timerProc; @@ -189,11 +189,8 @@ public: Common::String getHotspotName(uint16 hotspot); void updateCurrentHotspot(); - // Variable functions - void initVars(); - uint32 getVarCount() const { return _varCount; } - uint32 getGlobalVar(uint32 index); - Common::String getGlobalVarName(uint32 index); + // Variables + RivenVariableMap _vars; uint32 *getLocalVar(uint32 index); uint32 *getVar(const Common::String &varName); diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp index 3aef584e3f..b4552aa4d5 100644 --- a/engines/mohawk/riven_saveload.cpp +++ b/engines/mohawk/riven_saveload.cpp @@ -224,14 +224,14 @@ Common::MemoryWriteStreamDynamic *RivenSaveLoad::genVERSSection() { Common::MemoryWriteStreamDynamic *RivenSaveLoad::genVARSSection() { Common::MemoryWriteStreamDynamic *stream = new Common::MemoryWriteStreamDynamic(); - for (uint32 i = 0; i < _vm->getVarCount(); i++) { + for (RivenVariableMap::const_iterator it = _vm->_vars.begin(); it != _vm->_vars.end(); it++) { stream->writeUint32BE(0); // Unknown stream->writeUint32BE(0); // Unknown // Remap returnstackid here because we don't actually want to change // our internal returnstackid. - uint32 variable = _vm->getGlobalVar(i); - if (_vm->getGlobalVarName(i) == "returnstackid") + uint32 variable = it->_value; + if (it->_key == "returnstackid") variable = mapNewStackIDToOld(variable); stream->writeUint32BE(variable); @@ -243,19 +243,19 @@ Common::MemoryWriteStreamDynamic *RivenSaveLoad::genVARSSection() { Common::MemoryWriteStreamDynamic *RivenSaveLoad::genNAMESection() { Common::MemoryWriteStreamDynamic *stream = new Common::MemoryWriteStreamDynamic(); - stream->writeUint16BE((uint16)_vm->getVarCount()); + stream->writeUint16BE(_vm->_vars.size()); uint16 curPos = 0; - for (uint16 i = 0; i < _vm->getVarCount(); i++) { + for (RivenVariableMap::const_iterator it = _vm->_vars.begin(); it != _vm->_vars.end(); it++) { stream->writeUint16BE(curPos); - curPos += _vm->getGlobalVarName(i).size() + 1; + curPos += it->_key.size() + 1; } - for (uint16 i = 0; i < _vm->getVarCount(); i++) + for (uint16 i = 0; i < _vm->_vars.size(); i++) stream->writeUint16BE(i); - for (uint16 i = 0; i < _vm->getVarCount(); i++) { - stream->write(_vm->getGlobalVarName(i).c_str(), _vm->getGlobalVarName(i).size()); + for (RivenVariableMap::const_iterator it = _vm->_vars.begin(); it != _vm->_vars.end(); it++) { + stream->write(it->_key.c_str(), it->_key.size()); stream->writeByte(0); } diff --git a/engines/mohawk/riven_vars.cpp b/engines/mohawk/riven_vars.cpp index 6306b9b624..dd891ef1b3 100644 --- a/engines/mohawk/riven_vars.cpp +++ b/engines/mohawk/riven_vars.cpp @@ -274,14 +274,6 @@ uint32 *MohawkEngine_Riven::getLocalVar(uint32 index) { return getVar(getName(VariableNames, index)); } -uint32 MohawkEngine_Riven::getGlobalVar(uint32 index) { - return _vars[variableNames[index]]; -} - -Common::String MohawkEngine_Riven::getGlobalVarName(uint32 index) { - return variableNames[index]; -} - uint32 *MohawkEngine_Riven::getVar(const Common::String &varName) { if (!_vars.contains(varName)) error("Unknown variable: '%s'", varName.c_str()); @@ -290,10 +282,8 @@ uint32 *MohawkEngine_Riven::getVar(const Common::String &varName) { } void MohawkEngine_Riven::initVars() { - _varCount = ARRAYSIZE(variableNames); - // Most variables just start at 0, it's simpler to do this - for (uint32 i = 0; i < _varCount; i++) + for (uint32 i = 0; i < ARRAYSIZE(variableNames); i++) _vars[variableNames[i]] = 0; // Initialize the rest of the variables to their proper state |