From bc7af1de19e249c2928dd8df9da6250334a9b652 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 10 May 2014 17:08:34 +0100 Subject: GUI: Add "debuglevel" command to Debugger base class. This allows the debug level to be changed at runtime from the debug console. --- gui/debugger.cpp | 17 +++++++++++++++++ gui/debugger.h | 1 + 2 files changed, 18 insertions(+) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 2ec9937fdb..832f49f0c9 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -61,6 +61,7 @@ Debugger::Debugger() { DCmd_Register("help", WRAP_METHOD(Debugger, Cmd_Help)); DCmd_Register("openlog", WRAP_METHOD(Debugger, Cmd_OpenLog)); + DCmd_Register("debuglevel", WRAP_METHOD(Debugger, Cmd_DebugLevel)); DCmd_Register("debugflag_list", WRAP_METHOD(Debugger, Cmd_DebugFlagsList)); DCmd_Register("debugflag_enable", WRAP_METHOD(Debugger, Cmd_DebugFlagEnable)); DCmd_Register("debugflag_disable", WRAP_METHOD(Debugger, Cmd_DebugFlagDisable)); @@ -501,6 +502,22 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) { } +bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { + if (argc == 1) { + DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); + } else { // set level + gDebugLevel = atoi(argv[1]); + if (gDebugLevel >= 0 && gDebugLevel < 11) { + DebugPrintf("Debug level set to level %d\n", gDebugLevel); + } else if (gDebugLevel < 0) { + DebugPrintf("Debugging is now disabled\n"); + } else + DebugPrintf("Not a valid debug level (0 - 10)\n"); + } + + return true; +} + bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) { const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels(); diff --git a/gui/debugger.h b/gui/debugger.h index 4ce5481fbb..7481f89df2 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -193,6 +193,7 @@ protected: bool Cmd_Exit(int argc, const char **argv); bool Cmd_Help(int argc, const char **argv); bool Cmd_OpenLog(int argc, const char **argv); + bool Cmd_DebugLevel(int argc, const char **argv); bool Cmd_DebugFlagsList(int argc, const char **argv); bool Cmd_DebugFlagEnable(int argc, const char **argv); bool Cmd_DebugFlagDisable(int argc, const char **argv); -- cgit v1.2.3 From c81d0b680eb4f65ab23f02799de3b465a5758803 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Mon, 12 May 2014 00:56:20 +0100 Subject: GUI: Minor further fixes to "debuglevel" command in Debugger base class. --- gui/debugger.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 832f49f0c9..b2ef193fa7 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -504,15 +504,20 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) { bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { if (argc == 1) { - DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); + if (gDebugLevel < 0) { + DebugPrintf("Debugging is disabled\n"); + } else { + DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); + } } else { // set level gDebugLevel = atoi(argv[1]); if (gDebugLevel >= 0 && gDebugLevel < 11) { DebugPrintf("Debug level set to level %d\n", gDebugLevel); } else if (gDebugLevel < 0) { DebugPrintf("Debugging is now disabled\n"); - } else + } else { DebugPrintf("Not a valid debug level (0 - 10)\n"); + } } return true; -- cgit v1.2.3 From bac58f3e1878bed442766bc03c4f43adb1cb05de Mon Sep 17 00:00:00 2001 From: D G Turner Date: Tue, 13 May 2014 19:39:47 +0100 Subject: GUI: Clarify "debuglevel" command output in Debugger base class. This should make it clear that -1 is used for disable. --- gui/debugger.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index b2ef193fa7..da342e26e9 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -503,12 +503,8 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) { bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { - if (argc == 1) { - if (gDebugLevel < 0) { - DebugPrintf("Debugging is disabled\n"); - } else { - DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); - } + if (argc == 1) { // print level + DebugPrintf("Debugging is currently %s (set at level %d)\n", (gDebugLevel >= 0) ? "enabled" : "disabled", gDebugLevel); } else { // set level gDebugLevel = atoi(argv[1]); if (gDebugLevel >= 0 && gDebugLevel < 11) { @@ -516,7 +512,7 @@ bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { } else if (gDebugLevel < 0) { DebugPrintf("Debugging is now disabled\n"); } else { - DebugPrintf("Not a valid debug level (0 - 10)\n"); + DebugPrintf("Invalid debug level value (0 to 10 or -1 to disable)\n"); } } -- cgit v1.2.3 From fbb923daee62567aa8d9a6a5b02faf647e6233fa Mon Sep 17 00:00:00 2001 From: D G Turner Date: Thu, 15 May 2014 01:35:48 +0100 Subject: GUI: Add usage for "debuglevel" command output in Debugger base class. --- gui/debugger.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index da342e26e9..3cfa9f9803 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -505,6 +505,7 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) { bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { if (argc == 1) { // print level DebugPrintf("Debugging is currently %s (set at level %d)\n", (gDebugLevel >= 0) ? "enabled" : "disabled", gDebugLevel); + DebugPrintf("Usage: %s where n is 0 to 10 or -1 to disable debugging\n", argv[0]); } else { // set level gDebugLevel = atoi(argv[1]); if (gDebugLevel >= 0 && gDebugLevel < 11) { @@ -512,7 +513,8 @@ bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { } else if (gDebugLevel < 0) { DebugPrintf("Debugging is now disabled\n"); } else { - DebugPrintf("Invalid debug level value (0 to 10 or -1 to disable)\n"); + DebugPrintf("Invalid debug level value\n"); + DebugPrintf("Usage: %s where n is 0 to 10 or -1 to disable debugging\n", argv[0]); } } -- cgit v1.2.3 From 6cf5cb939b8452bb924946529d955469e73a7a0c Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 25 May 2014 12:29:13 +0200 Subject: GUI: Fix compilation This adds a missing header in the case #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER --- gui/debugger.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 3cfa9f9803..d14b786e33 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -23,6 +23,7 @@ // NB: This is really only necessary if USE_READLINE is defined #define FORBIDDEN_SYMBOL_ALLOW_ALL +#include "common/debug.h" #include "common/debug-channels.h" #include "common/system.h" -- cgit v1.2.3 From daa8d57a866e2866369e432cf1d624179edc8875 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:07 +0200 Subject: ALL: Rename Debugger::DebugPrintf to Debugger::debugPrintf. --- gui/debugger.cpp | 96 ++++++++++++++++++++++++++++---------------------------- gui/debugger.h | 2 +- 2 files changed, 49 insertions(+), 49 deletions(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index d14b786e33..498f19df5f 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -76,7 +76,7 @@ Debugger::~Debugger() { // Initialisation Functions -int Debugger::DebugPrintf(const char *format, ...) { +int Debugger::debugPrintf(const char *format, ...) { va_list argptr; va_start(argptr, format); @@ -153,13 +153,13 @@ void Debugger::enter() { #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER if (_firstTime) { - DebugPrintf("Debugger started, type 'exit' to return to the game.\n"); - DebugPrintf("Type 'help' to see a little list of commands and variables.\n"); + debugPrintf("Debugger started, type 'exit' to return to the game.\n"); + debugPrintf("Type 'help' to see a little list of commands and variables.\n"); _firstTime = false; } if (_errStr) { - DebugPrintf("ERROR: %s\n\n", _errStr); + debugPrintf("ERROR: %s\n\n", _errStr); free(_errStr); _errStr = NULL; } @@ -250,37 +250,37 @@ bool Debugger::parseCommand(const char *inputOrig) { // Integer case DVAR_BYTE: *(byte *)_dvars[i].variable = atoi(param[1]); - DebugPrintf("byte%s = %d\n", param[0], *(byte *)_dvars[i].variable); + debugPrintf("byte%s = %d\n", param[0], *(byte *)_dvars[i].variable); break; case DVAR_INT: *(int32 *)_dvars[i].variable = atoi(param[1]); - DebugPrintf("(int)%s = %d\n", param[0], *(int32 *)_dvars[i].variable); + debugPrintf("(int)%s = %d\n", param[0], *(int32 *)_dvars[i].variable); break; case DVAR_BOOL: if (Common::parseBool(param[1], *(bool *)_dvars[i].variable)) - DebugPrintf("(bool)%s = %s\n", param[0], *(bool *)_dvars[i].variable ? "true" : "false"); + debugPrintf("(bool)%s = %s\n", param[0], *(bool *)_dvars[i].variable ? "true" : "false"); else - DebugPrintf("Invalid value for boolean variable. Valid values are \"true\", \"false\", \"1\", \"0\", \"yes\", \"no\"\n"); + debugPrintf("Invalid value for boolean variable. Valid values are \"true\", \"false\", \"1\", \"0\", \"yes\", \"no\"\n"); break; // Integer Array case DVAR_INTARRAY: { const char *chr = strchr(param[0], '['); if (!chr) { - DebugPrintf("You must access this array as %s[element]\n", param[0]); + debugPrintf("You must access this array as %s[element]\n", param[0]); } else { int element = atoi(chr+1); int32 *var = *(int32 **)_dvars[i].variable; if (element >= _dvars[i].arraySize) { - DebugPrintf("%s is out of range (array is %d elements big)\n", param[0], _dvars[i].arraySize); + debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _dvars[i].arraySize); } else { var[element] = atoi(param[1]); - DebugPrintf("(int)%s = %d\n", param[0], var[element]); + debugPrintf("(int)%s = %d\n", param[0], var[element]); } } } break; default: - DebugPrintf("Failed to set variable %s to %s - unknown type\n", _dvars[i].name.c_str(), param[1]); + debugPrintf("Failed to set variable %s to %s - unknown type\n", _dvars[i].name.c_str(), param[1]); break; } } else { @@ -288,36 +288,36 @@ bool Debugger::parseCommand(const char *inputOrig) { switch (_dvars[i].type) { // Integer case DVAR_BYTE: - DebugPrintf("(byte)%s = %d\n", param[0], *(const byte *)_dvars[i].variable); + debugPrintf("(byte)%s = %d\n", param[0], *(const byte *)_dvars[i].variable); break; case DVAR_INT: - DebugPrintf("(int)%s = %d\n", param[0], *(const int32 *)_dvars[i].variable); + debugPrintf("(int)%s = %d\n", param[0], *(const int32 *)_dvars[i].variable); break; case DVAR_BOOL: - DebugPrintf("(bool)%s = %s\n", param[0], *(const bool *)_dvars[i].variable ? "true" : "false"); + debugPrintf("(bool)%s = %s\n", param[0], *(const bool *)_dvars[i].variable ? "true" : "false"); break; // Integer array case DVAR_INTARRAY: { const char *chr = strchr(param[0], '['); if (!chr) { - DebugPrintf("You must access this array as %s[element]\n", param[0]); + debugPrintf("You must access this array as %s[element]\n", param[0]); } else { int element = atoi(chr+1); const int32 *var = *(const int32 **)_dvars[i].variable; if (element >= _dvars[i].arraySize) { - DebugPrintf("%s is out of range (array is %d elements big)\n", param[0], _dvars[i].arraySize); + debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _dvars[i].arraySize); } else { - DebugPrintf("(int)%s = %d\n", param[0], var[element]); + debugPrintf("(int)%s = %d\n", param[0], var[element]); } } } break; // String case DVAR_STRING: - DebugPrintf("(string)%s = %s\n", param[0], ((Common::String *)_dvars[i].variable)->c_str()); + debugPrintf("(string)%s = %s\n", param[0], ((Common::String *)_dvars[i].variable)->c_str()); break; default: - DebugPrintf("%s = (unknown type)\n", param[0]); + debugPrintf("%s = (unknown type)\n", param[0]); break; } } @@ -327,7 +327,7 @@ bool Debugger::parseCommand(const char *inputOrig) { } } - DebugPrintf("Unknown command or variable\n"); + debugPrintf("Unknown command or variable\n"); free(input); return true; } @@ -448,7 +448,7 @@ bool Debugger::Cmd_Help(int argc, const char **argv) { int width, size; uint i; - DebugPrintf("Commands are:\n"); + debugPrintf("Commands are:\n"); // Obtain a list of sorted command names Common::Array cmds; @@ -464,31 +464,31 @@ bool Debugger::Cmd_Help(int argc, const char **argv) { size = cmds[i].size() + 1; if ((width + size) >= charsPerLine) { - DebugPrintf("\n"); + debugPrintf("\n"); width = size; } else width += size; - DebugPrintf("%s ", cmds[i].c_str()); + debugPrintf("%s ", cmds[i].c_str()); } - DebugPrintf("\n"); + debugPrintf("\n"); if (!_dvars.empty()) { - DebugPrintf("\n"); - DebugPrintf("Variables are:\n"); + debugPrintf("\n"); + debugPrintf("Variables are:\n"); width = 0; for (i = 0; i < _dvars.size(); i++) { size = _dvars[i].name.size() + 1; if ((width + size) >= charsPerLine) { - DebugPrintf("\n"); + debugPrintf("\n"); width = size; } else width += size; - DebugPrintf("%s ", _dvars[i].name.c_str()); + debugPrintf("%s ", _dvars[i].name.c_str()); } - DebugPrintf("\n"); + debugPrintf("\n"); } return true; @@ -498,24 +498,24 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) { if (g_system->hasFeature(OSystem::kFeatureDisplayLogFile)) g_system->displayLogFile(); else - DebugPrintf("Opening the log file not supported on this system\n"); + debugPrintf("Opening the log file not supported on this system\n"); return true; } bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { if (argc == 1) { // print level - DebugPrintf("Debugging is currently %s (set at level %d)\n", (gDebugLevel >= 0) ? "enabled" : "disabled", gDebugLevel); - DebugPrintf("Usage: %s where n is 0 to 10 or -1 to disable debugging\n", argv[0]); + debugPrintf("Debugging is currently %s (set at level %d)\n", (gDebugLevel >= 0) ? "enabled" : "disabled", gDebugLevel); + debugPrintf("Usage: %s where n is 0 to 10 or -1 to disable debugging\n", argv[0]); } else { // set level gDebugLevel = atoi(argv[1]); if (gDebugLevel >= 0 && gDebugLevel < 11) { - DebugPrintf("Debug level set to level %d\n", gDebugLevel); + debugPrintf("Debug level set to level %d\n", gDebugLevel); } else if (gDebugLevel < 0) { - DebugPrintf("Debugging is now disabled\n"); + debugPrintf("Debugging is now disabled\n"); } else { - DebugPrintf("Invalid debug level value\n"); - DebugPrintf("Usage: %s where n is 0 to 10 or -1 to disable debugging\n", argv[0]); + debugPrintf("Invalid debug level value\n"); + debugPrintf("Usage: %s where n is 0 to 10 or -1 to disable debugging\n", argv[0]); } } @@ -525,29 +525,29 @@ bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) { const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels(); - DebugPrintf("Engine debug levels:\n"); - DebugPrintf("--------------------\n"); + debugPrintf("Engine debug levels:\n"); + debugPrintf("--------------------\n"); if (debugLevels.empty()) { - DebugPrintf("No engine debug levels\n"); + debugPrintf("No engine debug levels\n"); return true; } for (Common::DebugManager::DebugChannelList::const_iterator i = debugLevels.begin(); i != debugLevels.end(); ++i) { - DebugPrintf("%c%s - %s (%s)\n", i->enabled ? '+' : ' ', + debugPrintf("%c%s - %s (%s)\n", i->enabled ? '+' : ' ', i->name.c_str(), i->description.c_str(), i->enabled ? "enabled" : "disabled"); } - DebugPrintf("\n"); + debugPrintf("\n"); return true; } bool Debugger::Cmd_DebugFlagEnable(int argc, const char **argv) { if (argc < 2) { - DebugPrintf("debugflag_enable \n"); + debugPrintf("debugflag_enable \n"); } else { if (DebugMan.enableDebugChannel(argv[1])) { - DebugPrintf("Enabled debug flag '%s'\n", argv[1]); + debugPrintf("Enabled debug flag '%s'\n", argv[1]); } else { - DebugPrintf("Failed to enable debug flag '%s'\n", argv[1]); + debugPrintf("Failed to enable debug flag '%s'\n", argv[1]); } } return true; @@ -555,12 +555,12 @@ bool Debugger::Cmd_DebugFlagEnable(int argc, const char **argv) { bool Debugger::Cmd_DebugFlagDisable(int argc, const char **argv) { if (argc < 2) { - DebugPrintf("debugflag_disable \n"); + debugPrintf("debugflag_disable \n"); } else { if (DebugMan.disableDebugChannel(argv[1])) { - DebugPrintf("Disabled debug flag '%s'\n", argv[1]); + debugPrintf("Disabled debug flag '%s'\n", argv[1]); } else { - DebugPrintf("Failed to disable debug flag '%s'\n", argv[1]); + debugPrintf("Failed to disable debug flag '%s'\n", argv[1]); } } return true; diff --git a/gui/debugger.h b/gui/debugger.h index 7481f89df2..a2a7aa2d86 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -40,7 +40,7 @@ public: Debugger(); virtual ~Debugger(); - int DebugPrintf(const char *format, ...) GCC_PRINTF(2, 3); + int debugPrintf(const char *format, ...) GCC_PRINTF(2, 3); /** * The onFrame() method should be invoked by the engine at regular -- cgit v1.2.3 From 0adca2c579c29274f3c76bfe88b80b8ba9df26da Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:07 +0200 Subject: ALL: Rename Debugger::DVar_Register to Debugger::registerVar. --- gui/debugger.cpp | 4 ++-- gui/debugger.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 498f19df5f..1d74db30cc 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -52,7 +52,7 @@ Debugger::Debugger() { #endif // Register variables - DVar_Register("debug_countdown", &_frameCountdown, DVAR_INT, 0); + registerVar("debug_countdown", &_frameCountdown, DVAR_INT, 0); // Register commands //DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); @@ -406,7 +406,7 @@ char *Debugger::readlineComplete(const char *input, int state) { #endif // Variable registration function -void Debugger::DVar_Register(const Common::String &varname, void *pointer, VarType type, int arraySize) { +void Debugger::registerVar(const Common::String &varname, void *pointer, VarType type, int arraySize) { // TODO: Filter out duplicates // TODO: Sort this list? Then we can do binary search later on when doing lookups. assert(pointer); diff --git a/gui/debugger.h b/gui/debugger.h index a2a7aa2d86..6ccc77b129 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -107,7 +107,7 @@ protected: * * @todo replace this single method by type safe variants. */ - void DVar_Register(const Common::String &varname, void *variable, VarType type, int arraySize); + void registerVar(const Common::String &varname, void *variable, VarType type, int arraySize); void DCmd_Register(const Common::String &cmdname, Debuglet *debuglet); -- cgit v1.2.3 From ae4ffe01f0e4354938714c546034cd0f9806bfc3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:08 +0200 Subject: ALL: Rename Debugger::DCmd_Register to Debugger::registerCmd. --- gui/debugger.cpp | 20 ++++++++++---------- gui/debugger.h | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 1d74db30cc..a419ef4dfb 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -55,17 +55,17 @@ Debugger::Debugger() { registerVar("debug_countdown", &_frameCountdown, DVAR_INT, 0); // Register commands - //DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("exit", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("quit", WRAP_METHOD(Debugger, Cmd_Exit)); + //registerCmd("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + registerCmd("exit", WRAP_METHOD(Debugger, Cmd_Exit)); + registerCmd("quit", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("help", WRAP_METHOD(Debugger, Cmd_Help)); - DCmd_Register("openlog", WRAP_METHOD(Debugger, Cmd_OpenLog)); + registerCmd("help", WRAP_METHOD(Debugger, Cmd_Help)); + registerCmd("openlog", WRAP_METHOD(Debugger, Cmd_OpenLog)); - DCmd_Register("debuglevel", WRAP_METHOD(Debugger, Cmd_DebugLevel)); - DCmd_Register("debugflag_list", WRAP_METHOD(Debugger, Cmd_DebugFlagsList)); - DCmd_Register("debugflag_enable", WRAP_METHOD(Debugger, Cmd_DebugFlagEnable)); - DCmd_Register("debugflag_disable", WRAP_METHOD(Debugger, Cmd_DebugFlagDisable)); + registerCmd("debuglevel", WRAP_METHOD(Debugger, Cmd_DebugLevel)); + registerCmd("debugflag_list", WRAP_METHOD(Debugger, Cmd_DebugFlagsList)); + registerCmd("debugflag_enable", WRAP_METHOD(Debugger, Cmd_DebugFlagEnable)); + registerCmd("debugflag_disable", WRAP_METHOD(Debugger, Cmd_DebugFlagDisable)); } Debugger::~Debugger() { @@ -421,7 +421,7 @@ void Debugger::registerVar(const Common::String &varname, void *pointer, VarType } // Command registration function -void Debugger::DCmd_Register(const Common::String &cmdname, Debuglet *debuglet) { +void Debugger::registerCmd(const Common::String &cmdname, Debuglet *debuglet) { assert(debuglet && debuglet->isValid()); _cmds[cmdname] = Common::SharedPtr(debuglet); } diff --git a/gui/debugger.h b/gui/debugger.h index 6ccc77b129..9dbc4084e8 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -74,7 +74,7 @@ protected: * Convenience macro that makes it easier to register a method * of a debugger subclass as a command. * Usage example: - * DCmd_Register("COMMAND", WRAP_METHOD(MyDebugger, MyCmd)); + * registerCmd("COMMAND", WRAP_METHOD(MyDebugger, MyCmd)); * would register the method MyDebugger::MyCmd(int, const char **) * under the command name "COMMAND". */ @@ -108,7 +108,7 @@ protected: * @todo replace this single method by type safe variants. */ void registerVar(const Common::String &varname, void *variable, VarType type, int arraySize); - void DCmd_Register(const Common::String &cmdname, Debuglet *debuglet); + void registerCmd(const Common::String &cmdname, Debuglet *debuglet); private: -- cgit v1.2.3 From 07c9fea9cbde6ca260e5e8be99f976a51752b4d7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:08 +0200 Subject: GUI: Slight naming cleanup in Debugger. --- gui/debugger.cpp | 54 +++++++++++++++++++++++++++--------------------------- gui/debugger.h | 4 ++-- 2 files changed, 29 insertions(+), 29 deletions(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index a419ef4dfb..86aff489a5 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -242,23 +242,23 @@ bool Debugger::parseCommand(const char *inputOrig) { } // It's not a command, so things get a little tricky for variables. Do fuzzy matching to ignore things like subscripts. - for (uint i = 0; i < _dvars.size(); i++) { - if (!strncmp(_dvars[i].name.c_str(), param[0], _dvars[i].name.size())) { + for (uint i = 0; i < _vars.size(); i++) { + if (!strncmp(_vars[i].name.c_str(), param[0], _vars[i].name.size())) { if (num_params > 1) { // Alright, we need to check the TYPE of the variable to deref and stuff... the array stuff is a bit ugly :) - switch (_dvars[i].type) { + switch (_vars[i].type) { // Integer case DVAR_BYTE: - *(byte *)_dvars[i].variable = atoi(param[1]); - debugPrintf("byte%s = %d\n", param[0], *(byte *)_dvars[i].variable); + *(byte *)_vars[i].variable = atoi(param[1]); + debugPrintf("byte%s = %d\n", param[0], *(byte *)_vars[i].variable); break; case DVAR_INT: - *(int32 *)_dvars[i].variable = atoi(param[1]); - debugPrintf("(int)%s = %d\n", param[0], *(int32 *)_dvars[i].variable); + *(int32 *)_vars[i].variable = atoi(param[1]); + debugPrintf("(int)%s = %d\n", param[0], *(int32 *)_vars[i].variable); break; case DVAR_BOOL: - if (Common::parseBool(param[1], *(bool *)_dvars[i].variable)) - debugPrintf("(bool)%s = %s\n", param[0], *(bool *)_dvars[i].variable ? "true" : "false"); + if (Common::parseBool(param[1], *(bool *)_vars[i].variable)) + debugPrintf("(bool)%s = %s\n", param[0], *(bool *)_vars[i].variable ? "true" : "false"); else debugPrintf("Invalid value for boolean variable. Valid values are \"true\", \"false\", \"1\", \"0\", \"yes\", \"no\"\n"); break; @@ -269,9 +269,9 @@ bool Debugger::parseCommand(const char *inputOrig) { debugPrintf("You must access this array as %s[element]\n", param[0]); } else { int element = atoi(chr+1); - int32 *var = *(int32 **)_dvars[i].variable; - if (element >= _dvars[i].arraySize) { - debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _dvars[i].arraySize); + int32 *var = *(int32 **)_vars[i].variable; + if (element >= _vars[i].arraySize) { + debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _vars[i].arraySize); } else { var[element] = atoi(param[1]); debugPrintf("(int)%s = %d\n", param[0], var[element]); @@ -280,21 +280,21 @@ bool Debugger::parseCommand(const char *inputOrig) { } break; default: - debugPrintf("Failed to set variable %s to %s - unknown type\n", _dvars[i].name.c_str(), param[1]); + debugPrintf("Failed to set variable %s to %s - unknown type\n", _vars[i].name.c_str(), param[1]); break; } } else { // And again, type-dependent prints/defrefs. The array one is still ugly. - switch (_dvars[i].type) { + switch (_vars[i].type) { // Integer case DVAR_BYTE: - debugPrintf("(byte)%s = %d\n", param[0], *(const byte *)_dvars[i].variable); + debugPrintf("(byte)%s = %d\n", param[0], *(const byte *)_vars[i].variable); break; case DVAR_INT: - debugPrintf("(int)%s = %d\n", param[0], *(const int32 *)_dvars[i].variable); + debugPrintf("(int)%s = %d\n", param[0], *(const int32 *)_vars[i].variable); break; case DVAR_BOOL: - debugPrintf("(bool)%s = %s\n", param[0], *(const bool *)_dvars[i].variable ? "true" : "false"); + debugPrintf("(bool)%s = %s\n", param[0], *(const bool *)_vars[i].variable ? "true" : "false"); break; // Integer array case DVAR_INTARRAY: { @@ -303,9 +303,9 @@ bool Debugger::parseCommand(const char *inputOrig) { debugPrintf("You must access this array as %s[element]\n", param[0]); } else { int element = atoi(chr+1); - const int32 *var = *(const int32 **)_dvars[i].variable; - if (element >= _dvars[i].arraySize) { - debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _dvars[i].arraySize); + const int32 *var = *(const int32 **)_vars[i].variable; + if (element >= _vars[i].arraySize) { + debugPrintf("%s is out of range (array is %d elements big)\n", param[0], _vars[i].arraySize); } else { debugPrintf("(int)%s = %d\n", param[0], var[element]); } @@ -314,7 +314,7 @@ bool Debugger::parseCommand(const char *inputOrig) { break; // String case DVAR_STRING: - debugPrintf("(string)%s = %s\n", param[0], ((Common::String *)_dvars[i].variable)->c_str()); + debugPrintf("(string)%s = %s\n", param[0], ((Common::String *)_vars[i].variable)->c_str()); break; default: debugPrintf("%s = (unknown type)\n", param[0]); @@ -411,13 +411,13 @@ void Debugger::registerVar(const Common::String &varname, void *pointer, VarType // TODO: Sort this list? Then we can do binary search later on when doing lookups. assert(pointer); - DVar tmp; + Var tmp; tmp.name = varname; tmp.type = type; tmp.variable = pointer; tmp.arraySize = arraySize; - _dvars.push_back(tmp); + _vars.push_back(tmp); } // Command registration function @@ -473,12 +473,12 @@ bool Debugger::Cmd_Help(int argc, const char **argv) { } debugPrintf("\n"); - if (!_dvars.empty()) { + if (!_vars.empty()) { debugPrintf("\n"); debugPrintf("Variables are:\n"); width = 0; - for (i = 0; i < _dvars.size(); i++) { - size = _dvars[i].name.size() + 1; + for (i = 0; i < _vars.size(); i++) { + size = _vars[i].name.size() + 1; if ((width + size) >= charsPerLine) { debugPrintf("\n"); @@ -486,7 +486,7 @@ bool Debugger::Cmd_Help(int argc, const char **argv) { } else width += size; - debugPrintf("%s ", _dvars[i].name.c_str()); + debugPrintf("%s ", _vars[i].name.c_str()); } debugPrintf("\n"); } diff --git a/gui/debugger.h b/gui/debugger.h index 9dbc4084e8..f764623e90 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -89,7 +89,7 @@ protected: DVAR_STRING }; - struct DVar { + struct Var { Common::String name; void *variable; VarType type; @@ -125,7 +125,7 @@ private: */ uint _frameCountdown; - Common::Array _dvars; + Common::Array _vars; typedef Common::HashMap, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> CommandsMap; CommandsMap _cmds; -- cgit v1.2.3 From 30d64edac449cde1f1c387b817ec33446ddd4698 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:08 +0200 Subject: ALL: Make Debugger command function names conform to our guidelines. --- gui/debugger.cpp | 32 ++++++++++++++++---------------- gui/debugger.h | 16 ++++++++-------- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'gui') diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 86aff489a5..4d97338b9c 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -55,17 +55,17 @@ Debugger::Debugger() { registerVar("debug_countdown", &_frameCountdown, DVAR_INT, 0); // Register commands - //registerCmd("continue", WRAP_METHOD(Debugger, Cmd_Exit)); - registerCmd("exit", WRAP_METHOD(Debugger, Cmd_Exit)); - registerCmd("quit", WRAP_METHOD(Debugger, Cmd_Exit)); + //registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); + registerCmd("exit", WRAP_METHOD(Debugger, cmdExit)); + registerCmd("quit", WRAP_METHOD(Debugger, cmdExit)); - registerCmd("help", WRAP_METHOD(Debugger, Cmd_Help)); - registerCmd("openlog", WRAP_METHOD(Debugger, Cmd_OpenLog)); + registerCmd("help", WRAP_METHOD(Debugger, cmdHelp)); + registerCmd("openlog", WRAP_METHOD(Debugger, cmdOpenLog)); - registerCmd("debuglevel", WRAP_METHOD(Debugger, Cmd_DebugLevel)); - registerCmd("debugflag_list", WRAP_METHOD(Debugger, Cmd_DebugFlagsList)); - registerCmd("debugflag_enable", WRAP_METHOD(Debugger, Cmd_DebugFlagEnable)); - registerCmd("debugflag_disable", WRAP_METHOD(Debugger, Cmd_DebugFlagDisable)); + registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel)); + registerCmd("debugflag_list", WRAP_METHOD(Debugger, cmdDebugFlagsList)); + registerCmd("debugflag_enable", WRAP_METHOD(Debugger, cmdDebugFlagEnable)); + registerCmd("debugflag_disable", WRAP_METHOD(Debugger, cmdDebugFlagDisable)); } Debugger::~Debugger() { @@ -428,14 +428,14 @@ void Debugger::registerCmd(const Common::String &cmdname, Debuglet *debuglet) { // Detach ("exit") the debugger -bool Debugger::Cmd_Exit(int argc, const char **argv) { +bool Debugger::cmdExit(int argc, const char **argv) { detach(); return false; } // Print a list of all registered commands (and variables, if any), // nicely word-wrapped. -bool Debugger::Cmd_Help(int argc, const char **argv) { +bool Debugger::cmdHelp(int argc, const char **argv) { #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER const int charsPerLine = _debuggerDialog->getCharsPerLine(); #elif defined(USE_READLINE) @@ -494,7 +494,7 @@ bool Debugger::Cmd_Help(int argc, const char **argv) { return true; } -bool Debugger::Cmd_OpenLog(int argc, const char **argv) { +bool Debugger::cmdOpenLog(int argc, const char **argv) { if (g_system->hasFeature(OSystem::kFeatureDisplayLogFile)) g_system->displayLogFile(); else @@ -503,7 +503,7 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) { } -bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { +bool Debugger::cmdDebugLevel(int argc, const char **argv) { if (argc == 1) { // print level debugPrintf("Debugging is currently %s (set at level %d)\n", (gDebugLevel >= 0) ? "enabled" : "disabled", gDebugLevel); debugPrintf("Usage: %s where n is 0 to 10 or -1 to disable debugging\n", argv[0]); @@ -522,7 +522,7 @@ bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { return true; } -bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) { +bool Debugger::cmdDebugFlagsList(int argc, const char **argv) { const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels(); debugPrintf("Engine debug levels:\n"); @@ -540,7 +540,7 @@ bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) { return true; } -bool Debugger::Cmd_DebugFlagEnable(int argc, const char **argv) { +bool Debugger::cmdDebugFlagEnable(int argc, const char **argv) { if (argc < 2) { debugPrintf("debugflag_enable \n"); } else { @@ -553,7 +553,7 @@ bool Debugger::Cmd_DebugFlagEnable(int argc, const char **argv) { return true; } -bool Debugger::Cmd_DebugFlagDisable(int argc, const char **argv) { +bool Debugger::cmdDebugFlagDisable(int argc, const char **argv) { if (argc < 2) { debugPrintf("debugflag_disable \n"); } else { diff --git a/gui/debugger.h b/gui/debugger.h index f764623e90..dc81fcb891 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -168,7 +168,7 @@ protected: virtual void postEnter(); /** - * Subclasses should invoke the detach() method in their Cmd_FOO methods + * Subclasses should invoke the detach() method in their cmdFOO methods * if that command will resume execution of the program (as opposed to * executing, say, a "single step through code" command). * @@ -190,13 +190,13 @@ private: virtual bool handleCommand(int argc, const char **argv, bool &keepRunning); protected: - bool Cmd_Exit(int argc, const char **argv); - bool Cmd_Help(int argc, const char **argv); - bool Cmd_OpenLog(int argc, const char **argv); - bool Cmd_DebugLevel(int argc, const char **argv); - bool Cmd_DebugFlagsList(int argc, const char **argv); - bool Cmd_DebugFlagEnable(int argc, const char **argv); - bool Cmd_DebugFlagDisable(int argc, const char **argv); + bool cmdExit(int argc, const char **argv); + bool cmdHelp(int argc, const char **argv); + bool cmdOpenLog(int argc, const char **argv); + bool cmdDebugLevel(int argc, const char **argv); + bool cmdDebugFlagsList(int argc, const char **argv); + bool cmdDebugFlagEnable(int argc, const char **argv); + bool cmdDebugFlagDisable(int argc, const char **argv); #ifndef USE_TEXT_CONSOLE_FOR_DEBUGGER private: -- cgit v1.2.3 From 75a78c89fac67b9b2efffc2c47e3d8daf3eb8022 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:08 +0200 Subject: GUI: Don't endorse function naming against our guidelines in docu. --- gui/debugger.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/debugger.h b/gui/debugger.h index dc81fcb891..319fa68dae 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -74,8 +74,8 @@ protected: * Convenience macro that makes it easier to register a method * of a debugger subclass as a command. * Usage example: - * registerCmd("COMMAND", WRAP_METHOD(MyDebugger, MyCmd)); - * would register the method MyDebugger::MyCmd(int, const char **) + * registerCmd("COMMAND", WRAP_METHOD(MyDebugger, myCmd)); + * would register the method MyDebugger::myCmd(int, const char **) * under the command name "COMMAND". */ #define WRAP_METHOD(cls, method) \ -- cgit v1.2.3 From 8b7672b64cc179660a4e1706db114b3b6b7073f7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:08 +0200 Subject: ALL: Introduce typesafe Debugger::registerVar functions. This also adds a FIXME to SCI which registered an enum type as int... --- gui/debugger.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'gui') diff --git a/gui/debugger.h b/gui/debugger.h index 319fa68dae..8c7481b61f 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -96,7 +96,7 @@ protected: int arraySize; }; - +private: /** * Register a variable with the debugger. This allows the user to read and modify * this variable. @@ -104,10 +104,30 @@ protected: * @param variable pointer to the actual storage of the variable * @param type the type of the variable (byte, int, bool, ...) * @paral arraySize for type DVAR_INTARRAY this specifies the size of the array - * - * @todo replace this single method by type safe variants. */ void registerVar(const Common::String &varname, void *variable, VarType type, int arraySize); + +protected: + void registerVar(const Common::String &varname, byte *variable) { + registerVar(varname, variable, DVAR_BYTE, 0); + } + + void registerVar(const Common::String &varname, int *variable) { + registerVar(varname, variable, DVAR_INT, 0); + } + + void registerVar(const Common::String &varname, bool *variable) { + registerVar(varname, variable, DVAR_BOOL, 0); + } + + void registerVar(const Common::String &varname, int32 **variable, int arraySize) { + registerVar(varname, variable, DVAR_INTARRAY, arraySize); + } + + void registerVar(const Common::String &varname, Common::String *variable) { + registerVar(varname, variable, DVAR_STRING, 0); + } + void registerCmd(const Common::String &cmdname, Debuglet *debuglet); -- cgit v1.2.3 From 6908c1ee42f28dce39d8572d4f77e90ff6ba7de5 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 28 May 2014 23:18:17 +0200 Subject: CREDITS: Update for Voyeur- and MADS-changes --- gui/credits.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index bcace12d13..d5c12515d3 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -168,6 +168,12 @@ static const char *credits[] = { "C0""Benjamin Haisch", "C0""Filippos Karapetis", "", +"C1""MADS", +"A0""Arnaud Boutonne", +"C0""Arnaud Boutonn\351", +"C0""Paul Gilbert", +"C0""Filippos Karapetis", +"", "C1""Mohawk", "C0""Bastien Bouclet", "C0""Matthew Hoops", @@ -299,6 +305,11 @@ static const char *credits[] = { "C0""Gregory Montoir", "C2""(retired)", "", +"C1""Voyeur", +"A0""Arnaud Boutonne", +"C0""Arnaud Boutonn\351", +"C0""Paul Gilbert", +"", "C1""Wintermute", "A0""Einar Johan T. Somaaen", "C0""Einar Johan T. S\370m\345en", -- cgit v1.2.3