[Scummvm-git-logs] scummvm master -> 5ab8f7d059dca60d1f8b9596437553090eb50aa6
dreammaster
paulfgilbert at gmail.com
Sat Apr 11 18:21:09 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7eca8b6c8c ULTIMA4: Skeleton beginnings of debugger & keymapper
5ab8f7d059 ULTIMA4: Added gate dbugger command
Commit: 7eca8b6c8cfb47c4accb382a97c8594b0855b4df
https://github.com/scummvm/scummvm/commit/7eca8b6c8cfb47c4accb382a97c8594b0855b4df
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-11T11:20:47-07:00
Commit Message:
ULTIMA4: Skeleton beginnings of debugger & keymapper
Changed paths:
A engines/ultima/ultima4/core/debugger.cpp
A engines/ultima/ultima4/core/debugger.h
A engines/ultima/ultima4/meta_engine.cpp
A engines/ultima/ultima4/meta_engine.h
engines/ultima/POTFILES
engines/ultima/detection.cpp
engines/ultima/module.mk
engines/ultima/shared/engine/debugger.cpp
engines/ultima/shared/engine/debugger.h
engines/ultima/ultima4/ultima4.cpp
diff --git a/engines/ultima/POTFILES b/engines/ultima/POTFILES
index 7136d4337e..7997ff72be 100644
--- a/engines/ultima/POTFILES
+++ b/engines/ultima/POTFILES
@@ -1,5 +1,7 @@
engines/ultima/shared/engine/ultima.cpp
engines/ultima/shared/engine/data_archive.cpp
+engines/ultima/ultima4/meta_engine.cpp
engines/ultima/nuvie/save/save_game.cpp
+engines/ultima/ultima8/meta_engine.cpp
engines/ultima/ultima8/ultima8.cpp
engines/ultima/ultima8/gumps/u8_save_gump.cpp
diff --git a/engines/ultima/detection.cpp b/engines/ultima/detection.cpp
index 3618da321c..deb9c6998d 100644
--- a/engines/ultima/detection.cpp
+++ b/engines/ultima/detection.cpp
@@ -30,6 +30,7 @@
#include "common/translation.h"
#include "ultima/shared/early/ultima_early.h"
#include "ultima/ultima4/ultima4.h"
+#include "ultima/ultima4/meta_engine.h"
#include "ultima/nuvie/meta_engine.h"
#include "ultima/nuvie/nuvie.h"
#include "ultima/ultima8/ultima8.h"
@@ -117,6 +118,8 @@ SaveStateList UltimaMetaEngine::listSaves(const char *target) const {
Common::KeymapArray UltimaMetaEngine::initKeymaps(const char *target) const {
Common::String gameId = getGameId(target);
+ if (gameId == "ultima4")
+ return Ultima::Ultima4::MetaEngine::initKeymaps();
if (gameId == "ultima8")
return Ultima::Ultima8::MetaEngine::initKeymaps();
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 96b0c0f29c..0e002290e4 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -143,6 +143,7 @@ MODULE_OBJS := \
ultima4/core/lzw/lzw.o \
ultima4/core/lzw/u4decode.o \
ultima4/core/config.o \
+ ultima4/core/debugger.o \
ultima4/core/error.o \
ultima4/core/settings.o \
ultima4/core/utils.o \
@@ -209,6 +210,7 @@ MODULE_OBJS := \
ultima4/sound/music.o \
ultima4/sound/sound.o \
ultima4/sound/sound_scummvm.o \
+ ultima4/meta_engine.o \
ultima4/ultima4.o \
nuvie/meta_engine.o \
nuvie/nuvie.o \
diff --git a/engines/ultima/shared/engine/debugger.cpp b/engines/ultima/shared/engine/debugger.cpp
index 639e85fa84..1c80fc4b5f 100644
--- a/engines/ultima/shared/engine/debugger.cpp
+++ b/engines/ultima/shared/engine/debugger.cpp
@@ -47,5 +47,24 @@ int Debugger::strToInt(const char *s) {
return (int)tmp;
}
+void Debugger::executeCommand(const Common::String &cmd) {
+
+}
+
+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
index b0addff055..a93872f29b 100644
--- a/engines/ultima/shared/engine/debugger.h
+++ b/engines/ultima/shared/engine/debugger.h
@@ -43,6 +43,16 @@ protected:
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
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
new file mode 100644
index 0000000000..413a465651
--- /dev/null
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -0,0 +1,42 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "ultima/ultima4/core/debugger.h"
+#include "ultima/ultima4/ultima4.h"
+
+namespace Ultima {
+namespace Ultima4 {
+
+Debugger *g_debugger;
+
+Debugger::Debugger() : Shared::Debugger() {
+ g_debugger = this;
+
+// registerCmd("quit", WRAP_METHOD(Debugger, cmdQuit));
+}
+
+Debugger::~Debugger() {
+ g_debugger = nullptr;
+}
+
+} // End of namespace Ultima4
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/core/debugger.h b/engines/ultima/ultima4/core/debugger.h
new file mode 100644
index 0000000000..4f1ee6a280
--- /dev/null
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -0,0 +1,47 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ULTIMA4_CORE_DEBUGGER_H
+#define ULTIMA4_CORE_DEBUGGER_H
+
+#include "ultima/shared/engine/debugger.h"
+
+namespace Ultima {
+namespace Ultima4 {
+
+/**
+ * Debugger base class
+ */
+class Debugger : public Shared::Debugger {
+private:
+// bool cmdQuit(int argc, const char **argv);
+public:
+ Debugger();
+ ~Debugger() override;
+};
+
+extern Debugger *g_debugger;
+
+} // End of namespace Ultima4
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima4/meta_engine.cpp b/engines/ultima/ultima4/meta_engine.cpp
new file mode 100644
index 0000000000..0e8168db24
--- /dev/null
+++ b/engines/ultima/ultima4/meta_engine.cpp
@@ -0,0 +1,105 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "ultima/ultima4/meta_engine.h"
+#include "ultima/ultima4/core/debugger.h"
+#include "ultima/ultima4/ultima4.h"
+#include "common/translation.h"
+#include "backends/keymapper/action.h"
+
+namespace Ultima {
+namespace Ultima4 {
+
+struct KeybindingRecord {
+ KeybindingAction _action;
+ const char *_id;
+ const char *_desc;
+ const char *_method;
+ const char *_key;
+ const char *_joy;
+};
+
+static const KeybindingRecord KEYS[] = {
+ { ACTION_NORTH, "NORTH", "North", "walk north", "up", nullptr },
+ { ACTION_SOUTH, "SOUTH", "South", "walk south", "down", nullptr },
+ { ACTION_EAST, "EAST", "East", "walk east", "right", nullptr },
+ { ACTION_WEST, "WEST", "West", "walk west", "left", nullptr },
+
+ { ACTION_NONE, nullptr, nullptr, nullptr, nullptr, nullptr }
+};
+
+
+Common::KeymapArray MetaEngine::initKeymaps() {
+ Common::KeymapArray keymapArray;
+
+ // Core keymaps
+ Common::Keymap *keyMap = new Common::Keymap(Common::Keymap::kKeymapTypeGame, "ultima4", _("Ultima IV"));
+ keymapArray.push_back(keyMap);
+
+ Common::Action *act;
+
+ act = new Common::Action("LCLK", _("Interact via Left Click"));
+ act->setLeftClickEvent();
+ act->addDefaultInputMapping("MOUSE_LEFT");
+ act->addDefaultInputMapping("JOY_A");
+ keyMap->addAction(act);
+
+ act = new Common::Action("RCLK", _("Interact via Right Click"));
+ act->setRightClickEvent();
+ act->addDefaultInputMapping("MOUSE_RIGHT");
+ act->addDefaultInputMapping("JOY_B");
+ keyMap->addAction(act);
+
+ for (const KeybindingRecord *r = KEYS; r->_id; ++r) {
+ act = new Common::Action(r->_id, _(r->_desc));
+ act->setCustomEngineActionEvent(r->_action);
+ act->addDefaultInputMapping(r->_key);
+ if (r->_joy)
+ act->addDefaultInputMapping(r->_joy);
+ keyMap->addAction(act);
+ }
+
+ return keymapArray;
+}
+
+void MetaEngine::setKeybindingsActive(bool isActive) {
+ g_engine->getEventManager()->getKeymapper()->setEnabled(isActive);
+}
+
+
+void MetaEngine::pressAction(KeybindingAction keyAction) {
+ Common::String methodName = getMethod(keyAction);
+ if (!methodName.empty())
+ g_debugger->executeCommand(methodName);
+}
+
+Common::String MetaEngine::getMethod(KeybindingAction keyAction) {
+ for (const KeybindingRecord *r = KEYS; r->_id; ++r) {
+ if (r->_action == keyAction)
+ return r->_method;
+ }
+
+ return Common::String();
+}
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/meta_engine.h b/engines/ultima/ultima4/meta_engine.h
new file mode 100644
index 0000000000..446f1ca016
--- /dev/null
+++ b/engines/ultima/ultima4/meta_engine.h
@@ -0,0 +1,63 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ULTIMA4_META_ENGINE
+#define ULTIMA4_META_ENGINE
+
+#include "backends/keymapper/keymapper.h"
+
+namespace Ultima {
+namespace Ultima4 {
+
+enum KeybindingAction {
+ ACTION_NORTH, ACTION_SOUTH, ACTION_EAST, ACTION_WEST,
+
+ ACTION_NONE
+};
+
+class MetaEngine {
+private:
+ /**
+ * Get the method to execute
+ */
+ static Common::String getMethod(KeybindingAction keyAction);
+public:
+ /**
+ * Initialize keymaps
+ */
+ static Common::KeymapArray initKeymaps();
+
+ /**
+ * Execute an engine keymap press action
+ */
+ static void pressAction(KeybindingAction keyAction);
+
+ /**
+ * Enables/disables the keymaps when not waiting for an in-game action
+ */
+ static void setKeybindingsActive(bool isActive);
+};
+
+} // End of namespace Ultima4
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima4/ultima4.cpp b/engines/ultima/ultima4/ultima4.cpp
index 0169e85114..1168dcb5f2 100644
--- a/engines/ultima/ultima4/ultima4.cpp
+++ b/engines/ultima/ultima4/ultima4.cpp
@@ -23,6 +23,7 @@
#include "ultima/ultima4/ultima4.h"
#include "ultima/ultima4/conversation/dialogueloader.h"
#include "ultima/ultima4/core/config.h"
+#include "ultima/ultima4/core/debugger.h"
#include "ultima/ultima4/core/error.h"
#include "ultima/ultima4/events/event.h"
#include "ultima/ultima4/filesys/savegame.h"
@@ -88,6 +89,7 @@ bool Ultima4Engine::initialize() {
_saveGame = new SaveGame();
_screen->init();
+ setDebugger(new Debugger());
_saveSlotToLoad = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
Commit: 5ab8f7d059dca60d1f8b9596437553090eb50aa6
https://github.com/scummvm/scummvm/commit/5ab8f7d059dca60d1f8b9596437553090eb50aa6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-11T11:20:47-07:00
Commit Message:
ULTIMA4: Added gate dbugger command
Changed paths:
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/core/debugger.h
engines/ultima/ultima4/core/utils.cpp
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 413a465651..346d1c4d5a 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -21,6 +21,10 @@
*/
#include "ultima/ultima4/core/debugger.h"
+#include "ultima/ultima4/game/context.h"
+#include "ultima/ultima4/game/game.h"
+#include "ultima/ultima4/game/moongate.h"
+#include "ultima/ultima4/gfx/screen.h"
#include "ultima/ultima4/ultima4.h"
namespace Ultima {
@@ -31,12 +35,50 @@ Debugger *g_debugger;
Debugger::Debugger() : Shared::Debugger() {
g_debugger = this;
-// registerCmd("quit", WRAP_METHOD(Debugger, cmdQuit));
+ registerCmd("gate", WRAP_METHOD(Debugger, cmdGate));
}
Debugger::~Debugger() {
g_debugger = nullptr;
}
+void Debugger::print(const char *fmt, ...) {
+ // Format the string
+ va_list va;
+ va_start(va, fmt);
+ Common::String str = Common::String::vformat(fmt, va);
+ va_end(va);
+
+ if (isActive()) {
+ debugPrintf("%s\n", str.c_str());
+ } else {
+ screenMessage("%s\n", str.c_str());
+ }
+}
+
+bool Debugger::cmdGate(int argc, const char **argv) {
+ int gateNum = (argc == 2) ? strToInt(argv[1]) : -1;
+
+ if (!g_context || !g_game || gateNum < 1 || gateNum > 8) {
+ print("Gate <1 to 8>");
+ } else {
+ if (!isActive())
+ print("Gate %d!", gateNum);
+
+ if (g_context->_location->_map->isWorldMap()) {
+ const Coords *moongate = moongateGetGateCoordsForPhase(gateNum - 1);
+ if (moongate) {
+ g_context->_location->_coords = *moongate;
+ g_game->finishTurn();
+ return false;
+ }
+ } else {
+ print("Not here!");
+ }
+ }
+
+ return true;
+}
+
} // 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 4f1ee6a280..cf9663e3c6 100644
--- a/engines/ultima/ultima4/core/debugger.h
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -33,7 +33,16 @@ namespace Ultima4 {
*/
class Debugger : public Shared::Debugger {
private:
-// bool cmdQuit(int argc, const char **argv);
+ /**
+ * Prints a message to the console if it's active, or to the
+ * game screen if not
+ */
+ void print(const char *fmt, ...);
+
+ /**
+ * Moongate
+ */
+ bool cmdGate(int argc, const char **argv);
public:
Debugger();
~Debugger() override;
diff --git a/engines/ultima/ultima4/core/utils.cpp b/engines/ultima/ultima4/core/utils.cpp
index 562f2e8d56..c3ba81f6dd 100644
--- a/engines/ultima/ultima4/core/utils.cpp
+++ b/engines/ultima/ultima4/core/utils.cpp
@@ -41,7 +41,7 @@ void xu4_srandom() {
}
int xu4_random(int upperRange) {
- return g_ultima->getRandomNumber(upperRange - 1);
+ return g_ultima->getRandomNumber(upperRange);
}
Common::String &trim(Common::String &val, const Common::String &chars_to_trim) {
More information about the Scummvm-git-logs
mailing list