diff options
author | johndoe123 | 2012-10-19 10:51:15 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:47:32 +0200 |
commit | ef8f0215cfa6287c5d45fef54f040276d95de9b2 (patch) | |
tree | 72bb767284c748558ab61eb9ec7869027ac99c08 /engines | |
parent | 126a306c899924cf774dfc0db1111728f9ac366b (diff) | |
download | scummvm-rg350-ef8f0215cfa6287c5d45fef54f040276d95de9b2.tar.gz scummvm-rg350-ef8f0215cfa6287c5d45fef54f040276d95de9b2.tar.bz2 scummvm-rg350-ef8f0215cfa6287c5d45fef54f040276d95de9b2.zip |
NEVERHOOD: Add GameVars::dumpVars() for debugging
Diffstat (limited to 'engines')
-rw-r--r-- | engines/neverhood/gamemodule.h | 2 | ||||
-rw-r--r-- | engines/neverhood/gamevars.cpp | 28 | ||||
-rw-r--r-- | engines/neverhood/gamevars.h | 1 | ||||
-rw-r--r-- | engines/neverhood/neverhood.cpp | 1 |
4 files changed, 12 insertions, 20 deletions
diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h index eb043cb646..40834ce5cd 100644 --- a/engines/neverhood/gamemodule.h +++ b/engines/neverhood/gamemodule.h @@ -20,8 +20,6 @@ * */ -// TODO: I couldn't come up with a better name than 'Module' so far - #ifndef NEVERHOOD_GAMEMODULE_H #define NEVERHOOD_GAMEMODULE_H diff --git a/engines/neverhood/gamevars.cpp b/engines/neverhood/gamevars.cpp index 3e4e60438a..e56ec1ec7d 100644 --- a/engines/neverhood/gamevars.cpp +++ b/engines/neverhood/gamevars.cpp @@ -32,41 +32,32 @@ GameVars::~GameVars() { } uint32 GameVars::getGlobalVar(uint32 nameHash) { - //debug("GameVars::getGlobalVar(%08X)", nameHash); int16 varIndex = findSubVarIndex(0, nameHash); return varIndex != -1 ? _vars[varIndex].value : 0; } void GameVars::setGlobalVar(uint32 nameHash, uint32 value) { - //debug("GameVars::setGlobalVar(%08X, %d)", nameHash, value); _vars[getSubVarIndex(0, nameHash)].value = value; } uint32 GameVars::getSubVar(uint32 nameHash, uint32 subNameHash) { - //debug("GameVars::getSubVar(%08X, %08X)", nameHash, subNameHash); uint32 value = 0; int16 varIndex = findSubVarIndex(0, nameHash); if (varIndex != -1) { int16 subVarIndex = findSubVarIndex(varIndex, subNameHash); - if (subVarIndex != -1) { + if (subVarIndex != -1) value = _vars[subVarIndex].value; - } } return value; } void GameVars::setSubVar(uint32 nameHash, uint32 subNameHash, uint32 value) { - //debug("GameVars::setSubVar(%08X, %08X, %d)", nameHash, subNameHash, value); int16 varIndex = getSubVarIndex(0, nameHash); - //debug(" varIndex = %d", varIndex); int16 subVarIndex = getSubVarIndex(varIndex, subNameHash); - //debug(" subVarIndex = %d", subVarIndex); _vars[subVarIndex].value = value; - //_vars[getSubVarIndex(getSubVarIndex(0, nameHash), subNameHash)].value = value; } int16 GameVars::addVar(uint32 nameHash, uint32 value) { - //debug("GameVars::addVar(%08X, %d)", nameHash, value); GameVar gameVar; gameVar.nameHash = nameHash; gameVar.value = value; @@ -77,16 +68,13 @@ int16 GameVars::addVar(uint32 nameHash, uint32 value) { } int16 GameVars::findSubVarIndex(int16 varIndex, uint32 subNameHash) { - //debug("GameVars::findSubVarIndex(%d, %08X)", varIndex, subNameHash); - for (int16 nextIndex = _vars[varIndex].firstIndex; nextIndex != -1; nextIndex = _vars[nextIndex].nextIndex) { + for (int16 nextIndex = _vars[varIndex].firstIndex; nextIndex != -1; nextIndex = _vars[nextIndex].nextIndex) if (_vars[nextIndex].nameHash == subNameHash) return nextIndex; - } return -1; } int16 GameVars::addSubVar(int16 varIndex, uint32 subNameHash, uint32 value) { - //debug("GameVars::addSubVar(%d, %08X, %d)", varIndex, subNameHash, value); int16 nextIndex = _vars[varIndex].firstIndex; int16 subVarIndex; if (nextIndex == -1) { @@ -102,13 +90,17 @@ int16 GameVars::addSubVar(int16 varIndex, uint32 subNameHash, uint32 value) { } int16 GameVars::getSubVarIndex(int16 varIndex, uint32 subNameHash) { - //debug("GameVars::getSubVarIndex(%d, %08X)", varIndex, subNameHash); int16 subVarIndex = findSubVarIndex(varIndex, subNameHash); - if (subVarIndex == -1) { + if (subVarIndex == -1) subVarIndex = addSubVar(varIndex, subNameHash, 0); - debug("need to create: subVarIndex = %d", subVarIndex); - } return subVarIndex; } +void GameVars::dumpVars() { + for (Common::Array<GameVar>::iterator it = _vars.begin(); it != _vars.end(); ++it) { + GameVar gameVar = *it; + debug("%08X %08X %3d %3d", gameVar.nameHash, gameVar.value, gameVar.firstIndex, gameVar.nextIndex); + } +} + } // End of namespace Neverhood diff --git a/engines/neverhood/gamevars.h b/engines/neverhood/gamevars.h index 3e32803acc..623e5b5c6f 100644 --- a/engines/neverhood/gamevars.h +++ b/engines/neverhood/gamevars.h @@ -176,6 +176,7 @@ public: void setGlobalVar(uint32 nameHash, uint32 value); uint32 getSubVar(uint32 nameHash, uint32 subNameHash); void setSubVar(uint32 nameHash, uint32 subNameHash, uint32 value); + void dumpVars(); protected: Common::Array<GameVar> _vars; int16 addVar(uint32 nameHash, uint32 value); diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp index 6a06ad66f6..76c2bc09eb 100644 --- a/engines/neverhood/neverhood.cpp +++ b/engines/neverhood/neverhood.cpp @@ -155,6 +155,7 @@ Common::Error NeverhoodEngine::run() { _gameModule->draw(); _screen->update(); nextFrameTime = _screen->getNextFrameTime(); + //_gameVars->dumpVars(); }; _soundMan->update(); |