[Scummvm-git-logs] scummvm master -> 17611ac289be3f727a484efe555d3832d17ad584
dreammaster
paulfgilbert at gmail.com
Sun Apr 12 02:54:49 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
17611ac289 ULTIMA4: Move destroy debug key to debugger
Commit: 17611ac289be3f727a484efe555d3832d17ad584
https://github.com/scummvm/scummvm/commit/17611ac289be3f727a484efe555d3832d17ad584
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-11T19:54:37-07:00
Commit Message:
ULTIMA4: Move destroy debug key to debugger
Changed paths:
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/core/debugger.h
engines/ultima/ultima4/game/game.cpp
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index ddb6ee8d31..84348a2348 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -45,6 +45,7 @@ Debugger::Debugger() : Shared::Debugger() {
registerCmd("3d", WRAP_METHOD(Debugger, cmd3d));
registerCmd("collisions", WRAP_METHOD(Debugger, cmdCollisions));
registerCmd("companions", WRAP_METHOD(Debugger, cmdCompanions));
+ registerCmd("destroy", WRAP_METHOD(Debugger, cmdDestroy));
registerCmd("dungeon", WRAP_METHOD(Debugger, cmdDungeon));
registerCmd("equipment", WRAP_METHOD(Debugger, cmdEquipment));
registerCmd("exit", WRAP_METHOD(Debugger, cmdExit));
@@ -133,6 +134,27 @@ Direction Debugger::directionFromName(const Common::String &dirStr) {
return DIR_NONE;
}
+bool Debugger::destroyAt(const Coords &coords) {
+ Object *obj = g_context->_location->_map->objectAt(coords);
+
+ if (obj) {
+ if (isCreature(obj)) {
+ Creature *c = dynamic_cast<Creature *>(obj);
+ screenMessage("%s Destroyed!\n", c->getName().c_str());
+ } else {
+ Tile *t = g_context->_location->_map->_tileset->get(obj->getTile()._id);
+ screenMessage("%s Destroyed!\n", t->getName().c_str());
+ }
+
+ g_context->_location->_map->removeObject(obj);
+ screenPrompt();
+
+ return true;
+ }
+
+ return false;
+}
+
bool Debugger::cmd3d(int argc, const char **argv) {
if (g_context->_location->_context == CTX_DUNGEON) {
@@ -166,6 +188,35 @@ bool Debugger::cmdCompanions(int argc, const char **argv) {
return isActive();
}
+bool Debugger::cmdDestroy(int argc, const char **argv) {
+ Direction dir;
+
+ if (argc == 2) {
+ dir = directionFromName(argv[1]);
+ } else if (isActive()) {
+ print("destroy <direction>");
+ return isActive();
+ } else {
+ screenMessage("Destroy Object\nDir: ");
+ dir = gameGetDirection();
+ }
+
+ if (dir == DIR_NONE)
+ return isActive();
+
+ Std::vector<Coords> path = gameGetDirectionalActionPath(MASK_DIR(dir),
+ MASK_DIR_ALL, g_context->_location->_coords, 1, 1, NULL, true);
+ for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
+ if (destroyAt(*i)) {
+ g_game->finishTurn();
+ return false;
+ }
+ }
+
+ print("%cNothing there!%c\n", FG_GREY, FG_WHITE);
+ return isActive();
+}
+
bool Debugger::cmdDungeon(int argc, const char **argv) {
if (g_context->_location->_context & CTX_WORLDMAP) {
if (argc == 2) {
diff --git a/engines/ultima/ultima4/core/debugger.h b/engines/ultima/ultima4/core/debugger.h
index c4ff877967..d46cf010a2 100644
--- a/engines/ultima/ultima4/core/debugger.h
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -23,6 +23,7 @@
#ifndef ULTIMA4_CORE_DEBUGGER_H
#define ULTIMA4_CORE_DEBUGGER_H
+#include "ultima/ultima4/core/coords.h"
#include "ultima/ultima4/core/types.h"
#include "ultima/shared/engine/debugger.h"
@@ -49,6 +50,11 @@ private:
*/
void summonCreature(const Common::String &name);
+ /**
+ * Destroy object at a given co-ordinate
+ */
+ bool destroyAt(const Coords &coords);
+
/**
* Returns a direction from a given string
*/
@@ -69,6 +75,11 @@ private:
*/
bool cmdCompanions(int argc, const char **argv);
+ /**
+ * Destroy an object
+ */
+ bool cmdDestroy(int argc, const char **argv);
+
/**
* Jumps to a given dungeon
*/
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index 4f110ab71b..405a933bf5 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -99,7 +99,6 @@ void talkRunConversation(Conversation &conv, Person *talker, bool showPrompt);
/* action functions */
bool attackAt(const Coords &coords);
-bool destroyAt(const Coords &coords);
bool getChestTrapHandler(int player);
bool jimmyAt(const Coords &coords);
bool openAt(const Coords &coords);
@@ -648,15 +647,8 @@ bool GameController::keyPressed(int key) {
endTurn = (retval & MOVE_END_TURN); /* let the movement handler decide to end the turn */
}
-
break;
- case 4: /* ctrl-D */
- if (settings._debug) {
- destroy();
- } else valid = false;
- break;
-
case ' ':
screenMessage("Pass\n");
break;
@@ -1240,45 +1232,6 @@ bool ZtatsController::keyPressed(int key) {
}
}
-void destroy() {
- screenMessage("Destroy Object\nDir: ");
-
- Direction dir = gameGetDirection();
-
- if (dir == DIR_NONE)
- return;
-
- Std::vector<Coords> path = gameGetDirectionalActionPath(MASK_DIR(dir), MASK_DIR_ALL,
- g_context->_location->_coords, 1, 1, NULL, true);
- for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
- if (destroyAt(*i))
- return;
- }
-
- screenMessage("%cNothing there!%c\n", FG_GREY, FG_WHITE);
-}
-
-bool destroyAt(const Coords &coords) {
- Object *obj = g_context->_location->_map->objectAt(coords);
-
- if (obj) {
- if (isCreature(obj)) {
- Creature *c = dynamic_cast<Creature *>(obj);
- screenMessage("%s Destroyed!\n", c->getName().c_str());
- } else {
- Tile *t = g_context->_location->_map->_tileset->get(obj->getTile()._id);
- screenMessage("%s Destroyed!\n", t->getName().c_str());
- }
-
- g_context->_location->_map->removeObject(obj);
- screenPrompt();
-
- return true;
- }
-
- return false;
-}
-
void attack() {
screenMessage("Attack: ");
More information about the Scummvm-git-logs
mailing list