From 4c13725a55fed393188a008a6e95a28e0c9c74c8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 12 Jun 2013 11:34:49 +0300 Subject: NEVERHOOD: Hook the dump vars debug code into a command, "dumpvars" Also, did some minor cleanup of the console commands (alphabetical reordering) --- engines/neverhood/console.cpp | 11 +++++++++-- engines/neverhood/console.h | 1 + engines/neverhood/gamevars.cpp | 5 +++-- engines/neverhood/gamevars.h | 4 +++- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp index 8db62d8487..7b5add65c7 100644 --- a/engines/neverhood/console.cpp +++ b/engines/neverhood/console.cpp @@ -30,9 +30,10 @@ namespace Neverhood { Console::Console(NeverhoodEngine *vm) : GUI::Debugger(), _vm(vm) { + DCmd_Register("cheat", WRAP_METHOD(Console, Cmd_Cheat)); + DCmd_Register("dumpvars", WRAP_METHOD(Console, Cmd_Dumpvars)); DCmd_Register("room", WRAP_METHOD(Console, Cmd_Room)); DCmd_Register("surfaces", WRAP_METHOD(Console, Cmd_Surfaces)); - DCmd_Register("cheat", WRAP_METHOD(Console, Cmd_Cheat)); } Console::~Console() { @@ -75,8 +76,8 @@ bool Console::Cmd_Cheat(int argc, const char **argv) { DebugPrintf(" cannon - sets the correct cannon combination in module 3000, scene 8\n"); DebugPrintf(" dice - shows the correct dice combination in the teddy bear puzzle, module 1100, scene 6\n"); DebugPrintf(" memory - solves the memory puzzle, module 1400, scene 4\n"); - DebugPrintf(" radio - enables the radio, module 3000, scene 9 - same as pulling the rightmost cord in the flytrap room\n"); DebugPrintf(" music - shows the correct index in the radio music puzzle, module 2800, scene 1\n"); + DebugPrintf(" radio - enables the radio, module 3000, scene 9 - same as pulling the rightmost cord in the flytrap room\n"); DebugPrintf(" symbols - solves the symbols puzzle, module 1600, scene 8. Only available in that room\n"); DebugPrintf(" tubes - shows the correct test tube combination in module 2800, scenes 7 and 10, can be used anywhere\n"); return true; @@ -162,4 +163,10 @@ bool Console::Cmd_Cheat(int argc, const char **argv) { return true; } +bool Console::Cmd_Dumpvars(int argc, const char **argv) { + _vm->_gameVars->dumpVars(this); + + return true; +} + } // End of namespace Neverhood diff --git a/engines/neverhood/console.h b/engines/neverhood/console.h index 7349820507..40c11b50e3 100644 --- a/engines/neverhood/console.h +++ b/engines/neverhood/console.h @@ -40,6 +40,7 @@ private: bool Cmd_Room(int argc, const char **argv); bool Cmd_Surfaces(int argc, const char **argv); bool Cmd_Cheat(int argc, const char **argv); + bool Cmd_Dumpvars(int argc, const char **argv); }; } // End of namespace Neverhood diff --git a/engines/neverhood/gamevars.cpp b/engines/neverhood/gamevars.cpp index 87f5fe6dd9..dc25f74e56 100644 --- a/engines/neverhood/gamevars.cpp +++ b/engines/neverhood/gamevars.cpp @@ -20,6 +20,7 @@ * */ +#include "neverhood/console.h" #include "neverhood/gamevars.h" namespace Neverhood { @@ -123,10 +124,10 @@ int16 GameVars::getSubVarIndex(int16 varIndex, uint32 subNameHash) { return subVarIndex; } -void GameVars::dumpVars() { +void GameVars::dumpVars(Console *con) { for (Common::Array::iterator it = _vars.begin(); it != _vars.end(); ++it) { GameVar gameVar = *it; - debug("%08X %08X %3d %3d", gameVar.nameHash, gameVar.value, gameVar.firstIndex, gameVar.nextIndex); + con->DebugPrintf("hash: %08X, var: %08X, first index: %3d, next index: %3d\n", gameVar.nameHash, gameVar.value, gameVar.firstIndex, gameVar.nextIndex); } } diff --git a/engines/neverhood/gamevars.h b/engines/neverhood/gamevars.h index 5337c13394..de9ffb8ec5 100644 --- a/engines/neverhood/gamevars.h +++ b/engines/neverhood/gamevars.h @@ -169,6 +169,8 @@ struct GameVar { int16 firstIndex, nextIndex; }; +class Console; + class GameVars { public: GameVars(); @@ -179,7 +181,7 @@ public: void setGlobalVar(uint32 nameHash, uint32 value); uint32 getSubVar(uint32 nameHash, uint32 subNameHash); void setSubVar(uint32 nameHash, uint32 subNameHash, uint32 value); - void dumpVars(); + void dumpVars(Console *con); protected: Common::Array _vars; int16 addVar(uint32 nameHash, uint32 value); -- cgit v1.2.3