diff options
author | Paul Gilbert | 2011-05-15 09:23:02 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-05-15 09:23:02 +1000 |
commit | 0bcfbd3cbdc4910e40635846844b1d356b1ae82e (patch) | |
tree | 2c67bee46a4c46de877cf583a79c2da79951260a /engines/m4/globals.h | |
parent | 82343f6649fed0a8b315e31c8b5177e4840b76e4 (diff) | |
download | scummvm-rg350-0bcfbd3cbdc4910e40635846844b1d356b1ae82e.tar.gz scummvm-rg350-0bcfbd3cbdc4910e40635846844b1d356b1ae82e.tar.bz2 scummvm-rg350-0bcfbd3cbdc4910e40635846844b1d356b1ae82e.zip |
M4: Replaced the trouble variable data map code with direct statements.
Since there aren't expected to be all that many engine variables needed, this seems a cleaner overall implementation.
Diffstat (limited to 'engines/m4/globals.h')
-rw-r--r-- | engines/m4/globals.h | 59 |
1 files changed, 1 insertions, 58 deletions
diff --git a/engines/m4/globals.h b/engines/m4/globals.h index a1339632f3..a95e5169be 100644 --- a/engines/m4/globals.h +++ b/engines/m4/globals.h @@ -240,63 +240,6 @@ union DataMapEntry { typedef Common::HashMap<uint16, uint16> DataMapHash; -enum DataMapType {BOOL, UINT16, INT, INT_FN}; - -class DataMapWrapper { - friend class DataMap; -private: - DataMapEntry _value; - DataMapType _type; -public: - DataMapWrapper(bool *v) { _value.boolValue = v; _type = BOOL; } - DataMapWrapper(uint16 *v) { _value.uint16Value = v; _type = UINT16; } - DataMapWrapper(int16 *v) { _value.uint16Value = (uint16 *)v; _type = UINT16; } - DataMapWrapper(int *v) { _value.intValue = v; _type = INT; } - DataMapWrapper(IntFunctionPtr v) { _value.fnPtr = v; _type = INT_FN; } - - uint16 getIntValue() { - if (_type == BOOL) return *_value.boolValue ? 0xffff : 0; - else if (_type == UINT16) return *_value.uint16Value; - else if (_type == INT) return *_value.intValue; - else return _value.fnPtr(); - } - void setIntValue(uint16 v) { - if (_type == BOOL) *_value.boolValue = v != 0; - else if (_type == UINT16) *_value.uint16Value = v; - else if (_type == INT) *_value.intValue = v; - } -}; - -#define MAP_DATA(V) _madsVm->globals()->_dataMap.addMapping(new DataMapWrapper(V)) - -class DataMap { -private: - DataMapHash _data; - Common::Array<DataMapWrapper *> _mapList; -public: - DataMap() { - _mapList.push_back(NULL); - } - ~DataMap() { - for (uint i = 1; i < _mapList.size(); ++i) - delete _mapList[i]; - } - - void addMapping(DataMapWrapper *v) { _mapList.push_back(v); } - uint16 get(uint16 index) { - if (index < _mapList.size()) - return _mapList[index]->getIntValue(); - - return _data[index]; - } - void set(uint16 index, uint16 v) { - if (index < _mapList.size()) - _mapList[index]->setIntValue(v); - else - _data[index] = v; - } -}; - class MadsGlobals : public Globals { private: struct MessageItem { @@ -325,7 +268,7 @@ public: int previousScene; int16 _nextSceneId; uint16 actionNouns[3]; - DataMap _dataMap; + DataMapHash _dataMap; int _difficultyLevel; void loadMadsVocab(); |