[Scummvm-git-logs] scummvm master -> 8445a7063924d0efb94ca7ddb5089d1d63629b1b

dreammaster noreply at scummvm.org
Thu Jun 5 00:52:38 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
8445a70639 ULTIMA: Split up the Debugger classes


Commit: 8445a7063924d0efb94ca7ddb5089d1d63629b1b
    https://github.com/scummvm/scummvm/commit/8445a7063924d0efb94ca7ddb5089d1d63629b1b
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-04T17:52:35-07:00

Commit Message:
ULTIMA: Split up the Debugger classes

Changed paths:
  R engines/ultima/nuvie/core/debugger.cpp
  R engines/ultima/nuvie/core/debugger.h
  R engines/ultima/shared/engine/debugger.cpp
  R engines/ultima/shared/engine/debugger.h
    engines/ultima/module.mk
    engines/ultima/nuvie/nuvie.cpp
    engines/ultima/shared/early/game_base.cpp
    engines/ultima/shared/early/ultima_early.cpp
    engines/ultima/shared/early/ultima_early.h
    engines/ultima/ultima1/core/debugger.cpp
    engines/ultima/ultima1/core/debugger.h
    engines/ultima/ultima4/core/debugger.cpp
    engines/ultima/ultima4/core/debugger.h
    engines/ultima/ultima4/core/debugger_actions.h


diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index ed0503ef4a2..8af5db7605d 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -6,7 +6,6 @@ MODULE_OBJS := \
 	shared/conf/xml_tree.o \
 	shared/engine/ultima.o \
 	shared/engine/data_archive.o \
-	shared/engine/debugger.o \
 	shared/engine/events.o \
 	shared/std/string.o
 
@@ -247,7 +246,6 @@ MODULE_OBJS += \
 	nuvie/core/converse_speech.o \
 	nuvie/core/cursor.o \
 	nuvie/core/debug.o \
-	nuvie/core/debugger.o \
 	nuvie/core/effect.o \
 	nuvie/core/effect_manager.o \
 	nuvie/core/egg_manager.o \
diff --git a/engines/ultima/nuvie/core/debugger.cpp b/engines/ultima/nuvie/core/debugger.cpp
deleted file mode 100644
index 359c8961a11..00000000000
--- a/engines/ultima/nuvie/core/debugger.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ultima/nuvie/core/debugger.h"
-
-namespace Ultima {
-namespace Nuvie {
-
-Debugger::Debugger() : Shared::Debugger() {
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/nuvie/core/debugger.h b/engines/ultima/nuvie/core/debugger.h
deleted file mode 100644
index 8bb9dd98ac3..00000000000
--- a/engines/ultima/nuvie/core/debugger.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ULTIMA_NUVIE_ENGINE_DEBUGGER_H
-#define ULTIMA_NUVIE_ENGINE_DEBUGGER_H
-
-#include "ultima/shared/engine/debugger.h"
-
-namespace Ultima {
-namespace Nuvie {
-
-/**
- * Debugger base class
- */
-class Debugger : public Shared::Debugger {
-public:
-	Debugger();
-	~Debugger() override {}
-};
-
-} // End of namespace Nuvie
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/nuvie/nuvie.cpp b/engines/ultima/nuvie/nuvie.cpp
index 4c1766cc1c4..e7a71276e5c 100644
--- a/engines/ultima/nuvie/nuvie.cpp
+++ b/engines/ultima/nuvie/nuvie.cpp
@@ -24,7 +24,6 @@
 #include "ultima/nuvie/core/events.h"
 #include "ultima/nuvie/actors/actor.h"
 #include "ultima/nuvie/core/nuvie_defs.h"
-#include "ultima/nuvie/core/debugger.h"
 #include "ultima/nuvie/conf/configuration.h"
 #include "ultima/nuvie/misc/u6_misc.h"
 #include "ultima/nuvie/files/nuvie_io_file.h"
@@ -106,9 +105,6 @@ bool NuvieEngine::initialize() {
 	// Setup savegame handler
 	_savegame = new SaveGame(_config);
 
-	// Setup debugger
-	setDebugger(new Debugger());
-
 	// Setup screen
 	_screen = new Screen(_config);
 
diff --git a/engines/ultima/shared/early/game_base.cpp b/engines/ultima/shared/early/game_base.cpp
index db6b88b468b..c309fcaa04f 100644
--- a/engines/ultima/shared/early/game_base.cpp
+++ b/engines/ultima/shared/early/game_base.cpp
@@ -23,7 +23,6 @@
 #include "common/system.h"
 #include "ultima/shared/early/ultima_early.h"
 #include "ultima/shared/early/game_base.h"
-#include "ultima/shared/engine/debugger.h"
 #include "ultima/shared/engine/messages.h"
 #include "ultima/shared/core/mouse_cursor.h"
 #include "ultima/shared/gfx/font.h"
diff --git a/engines/ultima/shared/early/ultima_early.cpp b/engines/ultima/shared/early/ultima_early.cpp
index f75709911d7..fdc80542500 100644
--- a/engines/ultima/shared/early/ultima_early.cpp
+++ b/engines/ultima/shared/early/ultima_early.cpp
@@ -30,7 +30,6 @@
 #include "ultima/shared/early/ultima_early.h"
 #include "ultima/shared/early/game.h"
 #include "ultima/shared/engine/ultima.h"
-#include "ultima/shared/engine/debugger.h"
 #include "ultima/shared/engine/events.h"
 #include "ultima/shared/engine/resources.h"
 #include "ultima/shared/core/mouse_cursor.h"
@@ -72,7 +71,6 @@ bool UltimaEarlyEngine::initialize() {
 	}
 	SearchMan.add("ultima", res);
 
-	setDebugger(new Debugger());
 	_events = new EventsManager(this);
 	_screen = new Gfx::Screen();
 
diff --git a/engines/ultima/shared/early/ultima_early.h b/engines/ultima/shared/early/ultima_early.h
index 02d48ec8126..316b7259882 100644
--- a/engines/ultima/shared/early/ultima_early.h
+++ b/engines/ultima/shared/early/ultima_early.h
@@ -55,7 +55,6 @@ struct UltimaSavegameHeader {
 	int _totalFrames;
 };
 
-class Debugger;
 class Events;
 class Game;
 class GameBase;
diff --git a/engines/ultima/shared/engine/debugger.cpp b/engines/ultima/shared/engine/debugger.cpp
deleted file mode 100644
index 4d0cc91b250..00000000000
--- a/engines/ultima/shared/engine/debugger.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ultima/shared/engine/debugger.h"
-#include "ultima/shared/early/ultima_early.h"
-#include "ultima/shared/early/game.h"
-#include "ultima/shared/maps/map.h"
-
-namespace Ultima {
-namespace Shared {
-
-Debugger::Debugger() : GUI::Debugger() {
-}
-
-int Debugger::strToInt(const char *s) {
-	if (!*s)
-		// No string at all
-		return 0;
-	else if (toupper(s[strlen(s) - 1]) != 'H')
-		// Standard decimal string
-		return atoi(s);
-
-	// Hexadecimal string
-	uint tmp = 0;
-	int read = sscanf(s, "%xh", &tmp);
-	if (read < 1)
-		error("strToInt failed on string \"%s\"", s);
-	return (int)tmp;
-}
-
-void Debugger::splitString(const Common::String &str,
-		Common::StringArray &argv) {
-	// Clear the vector
-	argv.clear();
-
-	bool quoted = false;
-	Common::String::const_iterator it;
-	int ch;
-	Common::String arg;
-
-	for (it = str.begin(); it != str.end(); ++it) {
-		ch = *it;
-
-		// Toggle quoted string handling
-		if (ch == '\"') {
-			quoted = !quoted;
-			continue;
-		}
-
-		// Handle \\, \", \', \n, \r, \t
-		if (ch == '\\') {
-			Common::String::const_iterator next = it + 1;
-			if (next != str.end()) {
-				if (*next == '\\' || *next == '\"' || *next == '\'') {
-					ch = *next;
-					++it;
-				} else if (*next == 'n') {
-					ch = '\n';
-					++it;
-				} else if (*next == 'r') {
-					ch = '\r';
-					++it;
-				} else if (*next == 't') {
-					ch = '\t';
-					++it;
-				} else if (*next == ' ') {
-					ch = ' ';
-					++it;
-				}
-			}
-		}
-
-		// A space, a tab, line feed, carriage return
-		if (!quoted && (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) {
-			// If we are not empty then we are at the end of the arg
-			// otherwise we will ignore the extra chars
-			if (!arg.empty()) {
-				argv.push_back(arg);
-				arg.clear();
-			}
-
-			continue;
-		}
-
-		// Add the charater to the string
-		arg += ch;
-	}
-
-	// Push any arg if it's left
-	if (!arg.empty())
-		argv.push_back(arg);
-}
-
-void Debugger::executeCommand(const Common::String &cmd) {
-	// Split up the command, and form a const char * array
-	Common::StringArray args;
-	splitString(cmd, args);
-
-	Common::Array<const char *> argv;
-	for (uint idx = 0; idx < args.size(); ++idx)
-		argv.push_back(args[idx].c_str());
-
-	// Execute the command
-	executeCommand(argv.size(), &argv[0]);
-}
-
-void Debugger::executeCommand(int argc, const char **argv) {
-	if (argc <= 0)
-		return;
-
-	bool keepRunning = false;
-	if (!handleCommand(argc, argv, keepRunning)) {
-		debugPrintf("Unknown command - %s\n", argv[0]);
-		keepRunning = true;
-	}
-
-	// If any message occurred, then we need to ensure the debugger is opened if it isn't already
-	if (keepRunning)
-		attach();
-}
-
-} // End of namespace Shared
-} // End of namespace Ultima
diff --git a/engines/ultima/shared/engine/debugger.h b/engines/ultima/shared/engine/debugger.h
deleted file mode 100644
index 97f6539fc24..00000000000
--- a/engines/ultima/shared/engine/debugger.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ULTIMA_SHARED_ENGINE_DEBUGGER_H
-#define ULTIMA_SHARED_ENGINE_DEBUGGER_H
-
-#include "common/scummsys.h"
-#include "gui/debugger.h"
-
-namespace Ultima {
-namespace Shared {
-
-class UltimaEngine;
-
-/**
- * Debugger base class
- */
-class Debugger : public GUI::Debugger {
-protected:
-	/**
-	 * Converts a string to an integer
-	 */
-	int strToInt(const char *s);
-
-	/**
-	 * Converts a string to a boolean
-	 */
-	bool strToBool(const char *s) {
-		return s && tolower(*s) == 't';
-	}
-
-	/**
-	 * Split up a command string into arg values
-	 */
-	void splitString(const Common::String &str, Common::StringArray &argv);
-public:
-	Debugger();
-	~Debugger() override {}
-
-	/**
-	 * Executes the given command
-	 */
-	void executeCommand(const Common::String &cmd);
-
-	/**
-	 * Executes the given command
-	 */
-	void executeCommand(int argc, const char **argv);
-};
-
-} // End of namespace Shared
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima1/core/debugger.cpp b/engines/ultima/ultima1/core/debugger.cpp
index c62dd416752..d5d6438deed 100644
--- a/engines/ultima/ultima1/core/debugger.cpp
+++ b/engines/ultima/ultima1/core/debugger.cpp
@@ -27,7 +27,23 @@
 namespace Ultima {
 namespace Ultima1 {
 
-Debugger::Debugger() : Shared::Debugger() {
+static int strToInt(const char *s) {
+	if (!*s)
+		// No string at all
+		return 0;
+	else if (toupper(s[strlen(s) - 1]) != 'H')
+		// Standard decimal string
+		return atoi(s);
+
+	// Hexadecimal string
+	uint tmp = 0;
+	int read = sscanf(s, "%xh", &tmp);
+	if (read < 1)
+		error("strToInt failed on string \"%s\"", s);
+	return (int)tmp;
+}
+
+Debugger::Debugger() : GUI::Debugger() {
 	registerCmd("spell", WRAP_METHOD(Debugger, cmdSpell));
 }
 
diff --git a/engines/ultima/ultima1/core/debugger.h b/engines/ultima/ultima1/core/debugger.h
index 9cd7091b6e4..5b4ff97a8c7 100644
--- a/engines/ultima/ultima1/core/debugger.h
+++ b/engines/ultima/ultima1/core/debugger.h
@@ -22,7 +22,7 @@
 #ifndef ULTIMA_ULTIMA1_ENGINE_DEBUGGER_H
 #define ULTIMA_ULTIMA1_ENGINE_DEBUGGER_H
 
-#include "ultima/shared/engine/debugger.h"
+#include "gui/debugger.h"
 
 namespace Ultima {
 namespace Ultima1 {
@@ -30,7 +30,7 @@ namespace Ultima1 {
 /**
  * Debugger base class
  */
-class Debugger : public Shared::Debugger {
+class Debugger : public GUI::Debugger {
 private:
 	bool cmdSpell(int argc, const char **argv);
 public:
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 82099c7716f..087de584656 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -48,7 +48,90 @@ namespace Ultima4 {
 
 Debugger *g_debugger;
 
-Debugger::Debugger() : Shared::Debugger() {
+static bool strToBool(const char *s) {
+	return s && tolower(*s) == 't';
+}
+
+static int strToInt(const char *s) {
+	if (!*s)
+		// No string at all
+		return 0;
+	else if (toupper(s[strlen(s) - 1]) != 'H')
+		// Standard decimal string
+		return atoi(s);
+
+	// Hexadecimal string
+	uint tmp = 0;
+	int read = sscanf(s, "%xh", &tmp);
+	if (read < 1)
+		error("strToInt failed on string \"%s\"", s);
+	return (int)tmp;
+}
+
+static void splitString(const Common::String &str,
+		Common::StringArray &argv) {
+	// Clear the vector
+	argv.clear();
+
+	bool quoted = false;
+	Common::String::const_iterator it;
+	int ch;
+	Common::String arg;
+
+	for (it = str.begin(); it != str.end(); ++it) {
+		ch = *it;
+
+		// Toggle quoted string handling
+		if (ch == '\"') {
+			quoted = !quoted;
+			continue;
+		}
+
+		// Handle \\, \", \', \n, \r, \t
+		if (ch == '\\') {
+			Common::String::const_iterator next = it + 1;
+			if (next != str.end()) {
+				if (*next == '\\' || *next == '\"' || *next == '\'') {
+					ch = *next;
+					++it;
+				} else if (*next == 'n') {
+					ch = '\n';
+					++it;
+				} else if (*next == 'r') {
+					ch = '\r';
+					++it;
+				} else if (*next == 't') {
+					ch = '\t';
+					++it;
+				} else if (*next == ' ') {
+					ch = ' ';
+					++it;
+				}
+			}
+		}
+
+		// A space, a tab, line feed, carriage return
+		if (!quoted && (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) {
+			// If we are not empty then we are at the end of the arg
+			// otherwise we will ignore the extra chars
+			if (!arg.empty()) {
+				argv.push_back(arg);
+				arg.clear();
+			}
+
+			continue;
+		}
+
+		// Add the charater to the string
+		arg += ch;
+	}
+
+	// Push any arg if it's left
+	if (!arg.empty())
+		argv.push_back(arg);
+}
+
+Debugger::Debugger() : GUI::Debugger() {
 	g_debugger = this;
 	_collisionOverride = false;
 	_disableCombat = false;
@@ -194,7 +277,7 @@ bool Debugger::handleCommand(int argc, const char **argv, bool &keepRunning) {
 		}
 	}
 
-	bool result = Shared::Debugger::handleCommand(argc, argv, keepRunning);
+	bool result = GUI::Debugger::handleCommand(argc, argv, keepRunning);
 
 	if (result) {
 		Controller *ctl = eventHandler->getController();
@@ -1887,5 +1970,33 @@ bool Debugger::cmdListTriggers(int argc, const char **argv) {
 	return isDebuggerActive();
 }
 
+void Debugger::executeCommand(const Common::String &cmd) {
+	// Split up the command, and form a const char * array
+	Common::StringArray args;
+	splitString(cmd, args);
+
+	Common::Array<const char *> argv;
+	for (uint idx = 0; idx < args.size(); ++idx)
+		argv.push_back(args[idx].c_str());
+
+	// Execute the command
+	executeCommand(argv.size(), &argv[0]);
+}
+
+void Debugger::executeCommand(int argc, const char **argv) {
+	if (argc <= 0)
+		return;
+
+	bool keepRunning = false;
+	if (!handleCommand(argc, argv, keepRunning)) {
+		debugPrintf("Unknown command - %s\n", argv[0]);
+		keepRunning = true;
+	}
+
+	// If any message occurred, then we need to ensure the debugger is opened if it isn't already
+	if (keepRunning)
+		attach();
+}
+
 } // End of namespace Ultima4
 } // End of namespace Ultima
diff --git a/engines/ultima/ultima4/core/debugger.h b/engines/ultima/ultima4/core/debugger.h
index b33dacb2f8f..54d09b41c97 100644
--- a/engines/ultima/ultima4/core/debugger.h
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -25,7 +25,7 @@
 #include "ultima/ultima4/core/coords.h"
 #include "ultima/ultima4/core/types.h"
 #include "ultima/ultima4/core/debugger_actions.h"
-#include "ultima/shared/engine/debugger.h"
+#include "gui/debugger.h"
 
 namespace Ultima {
 namespace Ultima4 {
@@ -33,7 +33,7 @@ namespace Ultima4 {
 /**
  * Debugger base class
  */
-class Debugger : public Shared::Debugger, public DebuggerActions {
+class Debugger : public GUI::Debugger, public DebuggerActions {
 private:
 	MapTile _horse, _ship, _balloon;
 	bool _dontEndTurn;
@@ -413,6 +413,16 @@ public:
 	 * user. Otherwise, a non-negative player number is expected
 	 */
 	void getChest(int player = -2);
+
+	/**
+	 * Executes the given command
+	 */
+	void executeCommand(const Common::String &cmd);
+
+	/**
+	 * Executes the given command
+	 */
+	void executeCommand(int argc, const char **argv);
 };
 
 extern Debugger *g_debugger;
diff --git a/engines/ultima/ultima4/core/debugger_actions.h b/engines/ultima/ultima4/core/debugger_actions.h
index a1c5977b9f7..983d0b92ab6 100644
--- a/engines/ultima/ultima4/core/debugger_actions.h
+++ b/engines/ultima/ultima4/core/debugger_actions.h
@@ -25,7 +25,6 @@
 #include "ultima/ultima4/core/coords.h"
 #include "ultima/ultima4/game/spell.h"
 #include "ultima/ultima4/core/types.h"
-#include "ultima/shared/engine/debugger.h"
 
 namespace Ultima {
 namespace Ultima4 {




More information about the Scummvm-git-logs mailing list