[Scummvm-git-logs] scummvm master -> 3a29bc3e18361c7fdb0a6f398e274ff038e95e35
dreammaster
paulfgilbert at gmail.com
Sun Apr 12 00:55:25 UTC 2020
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9783bccf12 ULTIMA4: More debugger commands
effaae3c16 ULTIMA4: Remainder of cheat debugger commands
1ac6450cdd ULTIMA4: Remove old cheat controller
3a29bc3e18 ULTIMA4: Fixes to transport debugger action
Commit: 9783bccf12b2b5aa793f31ff97a7f75fc75f3695
https://github.com/scummvm/scummvm/commit/9783bccf12b2b5aa793f31ff97a7f75fc75f3695
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-11T17:54:13-07:00
Commit Message:
ULTIMA4: More debugger commands
Changed paths:
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/core/debugger.h
engines/ultima/ultima4/game/cheat.cpp
engines/ultima/ultima4/game/game.cpp
engines/ultima/ultima4/map/movement.cpp
engines/ultima/ultima4/map/movement.h
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 07ddf4c5f7..0a23993d81 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -24,7 +24,10 @@
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/game/moongate.h"
+#include "ultima/ultima4/game/portal.h"
+#include "ultima/ultima4/game/weapon.h"
#include "ultima/ultima4/gfx/screen.h"
+#include "ultima/ultima4/map/mapmgr.h"
#include "ultima/ultima4/ultima4.h"
namespace Ultima {
@@ -34,9 +37,14 @@ Debugger *g_debugger;
Debugger::Debugger() : Shared::Debugger() {
g_debugger = this;
+ _collisionOverride = false;
+ registerCmd("collisions", WRAP_METHOD(Debugger, cmdCollisions));
+ registerCmd("equipment", WRAP_METHOD(Debugger, cmdEquipment));
registerCmd("gate", WRAP_METHOD(Debugger, cmdGate));
+ registerCmd("goto", WRAP_METHOD(Debugger, cmdGoto));
registerCmd("moon", WRAP_METHOD(Debugger, cmdMoon));
+ registerCmd("stats", WRAP_METHOD(Debugger, cmdStats));
}
Debugger::~Debugger() {
@@ -57,6 +65,32 @@ void Debugger::print(const char *fmt, ...) {
}
}
+bool Debugger::cmdCollisions(int argc, const char **argv) {
+ _collisionOverride = !_collisionOverride;
+ print("Collision detection %s",
+ _collisionOverride ? "off" : "on");
+
+ return isActive();
+}
+
+bool Debugger::cmdEquipment(int argc, const char **argv) {
+ int i;
+
+ for (i = ARMR_NONE + 1; i < ARMR_MAX; ++i)
+ g_ultima->_saveGame->_armor[i] = 8;
+
+ for (i = WEAP_HANDS + 1; i < WEAP_MAX; ++i) {
+ const Weapon *weapon = Weapon::get(static_cast<WeaponType>(i));
+ if (weapon->loseWhenUsed() || weapon->loseWhenRanged())
+ g_ultima->_saveGame->_weapons[i] = 99;
+ else
+ g_ultima->_saveGame->_weapons[i] = 8;
+ }
+
+ print("All equipment given");
+ return isActive();
+}
+
bool Debugger::cmdGate(int argc, const char **argv) {
int gateNum = (argc == 2) ? strToInt(argv[1]) : -1;
@@ -81,6 +115,58 @@ bool Debugger::cmdGate(int argc, const char **argv) {
return isActive();
}
+bool Debugger::cmdGoto(int argc, const char **argv) {
+ Common::String dest;
+
+ if (argc == 2) {
+ dest = argv[1];
+ } else if (isActive()) {
+ print("teleport <destination name>");
+ return true;
+ } else {
+ screenMessage("Goto: ");
+ dest = gameGetInput(32);
+ screenMessage("\n");
+ }
+
+ dest.toLowercase();
+
+ bool found = false;
+ for (unsigned p = 0; p < g_context->_location->_map->_portals.size(); p++) {
+ MapId destid = g_context->_location->_map->_portals[p]->_destid;
+ Common::String destNameLower = mapMgr->get(destid)->getName();
+ destNameLower.toLowercase();
+
+ if (destNameLower.find(dest) != Common::String::npos) {
+ screenMessage("\n%s\n", mapMgr->get(destid)->getName().c_str());
+ g_context->_location->_coords = g_context->_location->_map->_portals[p]->_coords;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ MapCoords coords = g_context->_location->_map->getLabel(dest);
+ if (coords != MapCoords::nowhere) {
+ print("%s", dest.c_str());
+ g_context->_location->_coords = coords;
+ found = true;
+ }
+ }
+
+ if (found) {
+ g_game->finishTurn();
+ return false;
+ } else {
+ if (isActive())
+ print("Can't find %s", dest.c_str());
+ else
+ print("Can't find\n%s", dest.c_str());
+
+ return isActive();
+ }
+}
+
bool Debugger::cmdMoon(int argc, const char **argv) {
int moonNum;
@@ -102,5 +188,22 @@ bool Debugger::cmdMoon(int argc, const char **argv) {
return isActive();
}
+bool Debugger::cmdStats(int argc, const char **argv) {
+ for (int i = 0; i < g_ultima->_saveGame->_members; i++) {
+ g_ultima->_saveGame->_players[i]._str = 50;
+ g_ultima->_saveGame->_players[i]._dex = 50;
+ g_ultima->_saveGame->_players[i]._intel = 50;
+
+ if (g_ultima->_saveGame->_players[i]._hpMax < 800) {
+ g_ultima->_saveGame->_players[i]._xp = 9999;
+ g_ultima->_saveGame->_players[i]._hpMax = 800;
+ g_ultima->_saveGame->_players[i]._hp = 800;
+ }
+ }
+
+ print("Full Stats given");
+ return isActive();
+}
+
} // 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 5dd8055c57..3a52335ea2 100644
--- a/engines/ultima/ultima4/core/debugger.h
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -39,16 +39,37 @@ private:
*/
void print(const char *fmt, ...);
+ /**
+ * Collision detection on/off
+ */
+ bool cmdCollisions(int argc, const char **argv);
+
+ /**
+ * All equipement
+ */
+ bool cmdEquipment(int argc, const char **argv);
+
/**
* Moongate teleportation
*/
bool cmdGate(int argc, const char **argv);
+ /**
+ * Go to any specified location by name
+ */
+ bool cmdGoto(int argc, const char **argv);
+
/**
* Moon phase
*/
bool cmdMoon(int argc, const char **argv);
+ /**
+ * Full stats
+ */
+ bool cmdStats(int argc, const char **argv);
+public:
+ bool _collisionOverride;
public:
Debugger();
~Debugger() override;
diff --git a/engines/ultima/ultima4/game/cheat.cpp b/engines/ultima/ultima4/game/cheat.cpp
index 284390af55..31e1d0b536 100644
--- a/engines/ultima/ultima4/game/cheat.cpp
+++ b/engines/ultima/ultima4/game/cheat.cpp
@@ -49,108 +49,9 @@ bool CheatMenuController::keyPressed(int key) {
bool valid = true;
switch (key) {
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- screenMessage("Gate %d!\n", key - '0');
-
- if (g_context->_location->_map->isWorldMap()) {
- const Coords *moongate = moongateGetGateCoordsForPhase(key - '1');
- if (moongate)
- g_context->_location->_coords = *moongate;
- } else
- screenMessage("Not here!\n");
- break;
-
- case 'a': {
- int newTrammelphase = g_ultima->_saveGame->_trammelPhase + 1;
- if (newTrammelphase > 7)
- newTrammelphase = 0;
-
- screenMessage("Advance Moons!\n");
- while (g_ultima->_saveGame->_trammelPhase != newTrammelphase)
- g_game->updateMoons(true);
- break;
- }
-
- case 'c':
- collisionOverride = !collisionOverride;
- screenMessage("Collision detection %s!\n", collisionOverride ? "off" : "on");
- break;
-
- case 'e':
- screenMessage("Equipment!\n");
- for (i = ARMR_NONE + 1; i < ARMR_MAX; i++)
- g_ultima->_saveGame->_armor[i] = 8;
- for (i = WEAP_HANDS + 1; i < WEAP_MAX; i++) {
- const Weapon *weapon = Weapon::get(static_cast<WeaponType>(i));
- if (weapon->loseWhenUsed() || weapon->loseWhenRanged())
- g_ultima->_saveGame->_weapons[i] = 99;
- else
- g_ultima->_saveGame->_weapons[i] = 8;
- }
- break;
-
- case 'f':
- screenMessage("Full Stats!\n");
- for (i = 0; i < g_ultima->_saveGame->_members; i++) {
- g_ultima->_saveGame->_players[i]._str = 50;
- g_ultima->_saveGame->_players[i]._dex = 50;
- g_ultima->_saveGame->_players[i]._intel = 50;
-
- if (g_ultima->_saveGame->_players[i]._hpMax < 800) {
- g_ultima->_saveGame->_players[i]._xp = 9999;
- g_ultima->_saveGame->_players[i]._hpMax = 800;
- g_ultima->_saveGame->_players[i]._hp = 800;
- }
- }
- break;
-
- case 'g': {
- screenMessage("Goto: ");
- Common::String dest = gameGetInput(32);
- lowercase(dest);
-
- bool found = false;
- for (unsigned p = 0; p < g_context->_location->_map->_portals.size(); p++) {
- MapId destid = g_context->_location->_map->_portals[p]->_destid;
- Common::String destNameLower = mapMgr->get(destid)->getName();
- lowercase(destNameLower);
- if (destNameLower.find(dest) != Common::String::npos) {
- screenMessage("\n%s\n", mapMgr->get(destid)->getName().c_str());
- g_context->_location->_coords = g_context->_location->_map->_portals[p]->_coords;
- found = true;
- break;
- }
- }
- if (!found) {
- MapCoords coords = g_context->_location->_map->getLabel(dest);
- if (coords != MapCoords::nowhere) {
- screenMessage("\n%s\n", dest.c_str());
- g_context->_location->_coords = coords;
- found = true;
- }
- }
- if (!found)
- screenMessage("\ncan't find\n%s!\n", dest.c_str());
- break;
- }
-
case 'h': {
screenMessage("Help:\n"
- "1-8 - Gate\n"
"F1-F8 - +Virtue\n"
- "a - Adv. Moons\n"
- "c - Collision\n"
- "e - Equipment\n"
- "f - Full Stats\n"
- "g - Goto\n"
- "h - Help\n"
"i - Items\n"
"k - Show Karma\n"
"(more)");
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index eaa80a2565..dfc15d20df 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -21,48 +21,49 @@
*/
#include "ultima/ultima4/ultima4.h"
+#include "ultima/ultima4/conversation/conversation.h"
#include "ultima/ultima4/core/config.h"
+#include "ultima/ultima4/core/debugger.h"
+#include "ultima/ultima4/core/error.h"
+#include "ultima/ultima4/core/settings.h"
+#include "ultima/ultima4/core/utils.h"
+#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/game/game.h"
-#include "ultima/ultima4/map/annotation.h"
#include "ultima/ultima4/game/armor.h"
-#include "ultima/ultima4/map/camp.h"
#include "ultima/ultima4/game/cheat.h"
-#include "ultima/ultima4/map/city.h"
-#include "ultima/ultima4/conversation/conversation.h"
-#include "ultima/ultima4/map/dungeon.h"
-#include "ultima/ultima4/map/combat.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/death.h"
-#include "ultima/ultima4/map/direction.h"
-#include "ultima/ultima4/core/error.h"
-#include "ultima/ultima4/events/event.h"
#include "ultima/ultima4/game/intro.h"
#include "ultima/ultima4/game/item.h"
-#include "ultima/ultima4/gfx/imagemgr.h"
-#include "ultima/ultima4/map/location.h"
-#include "ultima/ultima4/map/mapmgr.h"
#include "ultima/ultima4/game/menu.h"
#include "ultima/ultima4/game/creature.h"
#include "ultima/ultima4/game/moongate.h"
-#include "ultima/ultima4/map/movement.h"
-#include "ultima/ultima4/sound/music.h"
#include "ultima/ultima4/game/names.h"
#include "ultima/ultima4/game/person.h"
#include "ultima/ultima4/game/player.h"
#include "ultima/ultima4/game/portal.h"
-#include "ultima/ultima4/filesys/savegame.h"
-#include "ultima/ultima4/gfx/screen.h"
-#include "ultima/ultima4/core/settings.h"
-#include "ultima/ultima4/map/shrine.h"
-#include "ultima/ultima4/sound/sound.h"
#include "ultima/ultima4/game/spell.h"
#include "ultima/ultima4/game/stats.h"
-#include "ultima/ultima4/map/tilemap.h"
-#include "ultima/ultima4/map/tileset.h"
-#include "ultima/ultima4/core/utils.h"
#include "ultima/ultima4/game/script.h"
#include "ultima/ultima4/game/weapon.h"
+#include "ultima/ultima4/gfx/imagemgr.h"
+#include "ultima/ultima4/gfx/screen.h"
+#include "ultima/ultima4/map/camp.h"
+#include "ultima/ultima4/map/city.h"
+#include "ultima/ultima4/map/annotation.h"
+#include "ultima/ultima4/map/dungeon.h"
+#include "ultima/ultima4/map/combat.h"
+#include "ultima/ultima4/map/direction.h"
+#include "ultima/ultima4/map/location.h"
+#include "ultima/ultima4/map/mapmgr.h"
+#include "ultima/ultima4/map/movement.h"
+#include "ultima/ultima4/map/shrine.h"
+#include "ultima/ultima4/map/tilemap.h"
+#include "ultima/ultima4/map/tileset.h"
#include "ultima/ultima4/map/dungeonview.h"
+#include "ultima/ultima4/sound/music.h"
+#include "ultima/ultima4/sound/sound.h"
#include "common/savefile.h"
#include "common/system.h"
@@ -2711,7 +2712,7 @@ void gameCheckHullIntegrity() {
}
- if (!collisionOverride && g_context->_transportContext == TRANSPORT_FOOT &&
+ if (!g_debugger->_collisionOverride && g_context->_transportContext == TRANSPORT_FOOT &&
g_context->_location->_map->tileTypeAt(g_context->_location->_coords, WITHOUT_OBJECTS)->isSailable() &&
!g_context->_location->_map->tileTypeAt(g_context->_location->_coords, WITH_GROUND_OBJECTS)->isShip() &&
!g_context->_location->_map->getValidMoves(g_context->_location->_coords, g_context->_party->getTransport())) {
diff --git a/engines/ultima/ultima4/map/movement.cpp b/engines/ultima/ultima4/map/movement.cpp
index ac44387b23..811a94a8ee 100644
--- a/engines/ultima/ultima4/map/movement.cpp
+++ b/engines/ultima/ultima4/map/movement.cpp
@@ -32,13 +32,12 @@
#include "ultima/ultima4/game/player.h"
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/map/tile.h"
+#include "ultima/ultima4/core/debugger.h"
#include "ultima/ultima4/core/utils.h"
namespace Ultima {
namespace Ultima4 {
-bool collisionOverride = false;
-
/**
* Attempt to move the avatar in the given direction. User event
* should be set if the avatar is being moved in response to a
@@ -85,7 +84,7 @@ void moveAvatar(MoveEvent &event) {
return;
}
- if (!collisionOverride && !g_context->_party->isFlying()) {
+ if (!g_debugger->_collisionOverride && !g_context->_party->isFlying()) {
int movementMask = g_context->_location->_map->getValidMoves(g_context->_location->_coords, g_context->_party->getTransport());
/* See if movement was blocked */
if (!DIR_IN_MASK(event._dir, movementMask)) {
@@ -161,7 +160,7 @@ void moveAvatarInDungeon(MoveEvent &event) {
return;
}
- if (!collisionOverride) {
+ if (!g_debugger->_collisionOverride) {
int movementMask = g_context->_location->_map->getValidMoves(g_context->_location->_coords, g_context->_party->getTransport());
if (advancing && !tile->getTileType()->canWalkOn(DIR_ADVANCE))
diff --git a/engines/ultima/ultima4/map/movement.h b/engines/ultima/ultima4/map/movement.h
index 23a90308e2..1c277a0a53 100644
--- a/engines/ultima/ultima4/map/movement.h
+++ b/engines/ultima/ultima4/map/movement.h
@@ -68,8 +68,6 @@ void movePartyMember(MoveEvent &event);
bool slowedByTile(const Tile *tile);
bool slowedByWind(int direction);
-extern bool collisionOverride;
-
} // End of namespace Ultima4
} // End of namespace Ultima
Commit: effaae3c161546fd237c283d29d79b38be32b62f
https://github.com/scummvm/scummvm/commit/effaae3c161546fd237c283d29d79b38be32b62f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-11T17:54:13-07:00
Commit Message:
ULTIMA4: Remainder of cheat debugger commands
Changed paths:
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/core/debugger.h
engines/ultima/ultima4/game/cheat.cpp
engines/ultima/ultima4/game/cheat.h
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 0a23993d81..24ff750960 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -24,7 +24,9 @@
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/game/moongate.h"
+#include "ultima/ultima4/game/player.h"
#include "ultima/ultima4/game/portal.h"
+#include "ultima/ultima4/game/stats.h"
#include "ultima/ultima4/game/weapon.h"
#include "ultima/ultima4/gfx/screen.h"
#include "ultima/ultima4/map/mapmgr.h"
@@ -35,16 +37,33 @@ namespace Ultima4 {
Debugger *g_debugger;
-Debugger::Debugger() : Shared::Debugger() {
+Debugger::Debugger() : Shared::Debugger(),
+ _horse(g_context->_location->_map->_tileset->getByName("horse")->getId()),
+ _ship(g_context->_location->_map->_tileset->getByName("ship")->getId()),
+ _balloon(g_context->_location->_map->_tileset->getByName("balloon")->getId()) {
g_debugger = this;
_collisionOverride = false;
registerCmd("collisions", WRAP_METHOD(Debugger, cmdCollisions));
+ registerCmd("companions", WRAP_METHOD(Debugger, cmdCompanions));
registerCmd("equipment", WRAP_METHOD(Debugger, cmdEquipment));
+ registerCmd("exit", WRAP_METHOD(Debugger, cmdExit));
registerCmd("gate", WRAP_METHOD(Debugger, cmdGate));
registerCmd("goto", WRAP_METHOD(Debugger, cmdGoto));
+ registerCmd("items", WRAP_METHOD(Debugger, cmdItems));
+ registerCmd("karma", WRAP_METHOD(Debugger, cmdKarma));
+ registerCmd("location", WRAP_METHOD(Debugger, cmdLocation));
+ registerCmd("mixtures", WRAP_METHOD(Debugger, cmdMixtures));
registerCmd("moon", WRAP_METHOD(Debugger, cmdMoon));
+ registerCmd("opacity", WRAP_METHOD(Debugger, cmdOpacity));
+ registerCmd("peer", WRAP_METHOD(Debugger, cmdPeer));
+ registerCmd("reagents", WRAP_METHOD(Debugger, cmdReagents));
registerCmd("stats", WRAP_METHOD(Debugger, cmdStats));
+ registerCmd("summon", WRAP_METHOD(Debugger, cmdSummon));
+ registerCmd("up", WRAP_METHOD(Debugger, cmdUp));
+ registerCmd("down", WRAP_METHOD(Debugger, cmdDown));
+ registerCmd("virtue", WRAP_METHOD(Debugger, cmdVirtue));
+ registerCmd("wind", WRAP_METHOD(Debugger, cmdWind));
}
Debugger::~Debugger() {
@@ -65,6 +84,37 @@ void Debugger::print(const char *fmt, ...) {
}
}
+void Debugger::summonCreature(const Common::String &name) {
+ const Creature *m = NULL;
+ Common::String creatureName = name;
+
+ creatureName.trim();
+ if (creatureName.empty()) {
+ print("\n");
+ return;
+ }
+
+ /* find the creature by its id and spawn it */
+ unsigned int id = atoi(creatureName.c_str());
+ if (id > 0)
+ m = creatureMgr->getById(id);
+
+ if (!m)
+ m = creatureMgr->getByName(creatureName);
+
+ if (m) {
+ if (gameSpawnCreature(m))
+ print("\n%s summoned!\n", m->getName().c_str());
+ else
+ print("\n\nNo place to put %s!\n\n", m->getName().c_str());
+
+ return;
+ }
+
+ print("\n%s not found\n", creatureName.c_str());
+}
+
+
bool Debugger::cmdCollisions(int argc, const char **argv) {
_collisionOverride = !_collisionOverride;
print("Collision detection %s",
@@ -73,6 +123,20 @@ bool Debugger::cmdCollisions(int argc, const char **argv) {
return isActive();
}
+bool Debugger::cmdCompanions(int argc, const char **argv) {
+ for (int m = g_ultima->_saveGame->_members; m < 8; m++) {
+ debug("m = %d\n", m);
+ debug("n = %s\n", g_ultima->_saveGame->_players[m].name);
+ if (g_context->_party->canPersonJoin(g_ultima->_saveGame->_players[m].name, NULL)) {
+ g_context->_party->join(g_ultima->_saveGame->_players[m].name);
+ }
+ }
+
+ g_context->_stats->update();
+ print("Joined by companions");
+ return isActive();
+}
+
bool Debugger::cmdEquipment(int argc, const char **argv) {
int i;
@@ -86,11 +150,22 @@ bool Debugger::cmdEquipment(int argc, const char **argv) {
else
g_ultima->_saveGame->_weapons[i] = 8;
}
-
+
print("All equipment given");
return isActive();
}
+bool Debugger::cmdExit(int argc, const char **argv) {
+ if (!g_game->exitToParentMap()) {
+ print("Not Here");
+ } else {
+ g_music->play();
+ print("Exited");
+ }
+
+ return isActive();
+}
+
bool Debugger::cmdGate(int argc, const char **argv) {
int gateNum = (argc == 2) ? strToInt(argv[1]) : -1;
@@ -167,6 +242,72 @@ bool Debugger::cmdGoto(int argc, const char **argv) {
}
}
+bool Debugger::cmdItems(int argc, const char **argv) {
+ SaveGame &sg = *g_ultima->_saveGame;
+ sg._torches = 99;
+ sg._gems = 99;
+ sg._keys = 99;
+ sg._sextants = 1;
+ sg._items = ITEM_SKULL | ITEM_CANDLE | ITEM_BOOK | ITEM_BELL | ITEM_KEY_C | ITEM_KEY_L | ITEM_KEY_T | ITEM_HORN | ITEM_WHEEL;
+ sg._stones = 0xff;
+ sg._runes = 0xff;
+ sg._food = 999900;
+ sg._gold = 9999;
+
+ g_context->_stats->update();
+ print("All items given");
+ return isActive();
+}
+
+bool Debugger::cmdKarma(int argc, const char **argv) {
+ print("Karma!\n");
+
+ for (int i = 0; i < 8; ++i) {
+ Common::String line = Common::String::format("%s:",
+ getVirtueName(static_cast<Virtue>(i)));
+ while (line.size() < 13)
+ line += ' ';
+
+ if (g_ultima->_saveGame->_karma[i] > 0)
+ line += Common::String::format("%.2d", g_ultima->_saveGame->_karma[i]);
+ else
+ line += "--";
+ print("%s", line.c_str());
+ }
+
+ return isActive();
+}
+
+bool Debugger::cmdLocation(int argc, const char **argv) {
+ const MapCoords &pos = g_context->_location->_coords;
+
+ if (isActive()) {
+ if (g_context->_location->_map->isWorldMap())
+ print("Location: %s x: %d, y: %d",
+ "World Map", pos.x, pos.y);
+ else
+ print("Location: %s x: %d, y: %d, z: %d",
+ g_context->_location->_map->getName().c_str(), pos.x, pos.y, pos.z);
+ } else {
+ if (g_context->_location->_map->isWorldMap())
+ print("\nLocation:\n%s\nx: %d\ny: %d\n", "World Map",
+ pos.x, pos.y);
+ else
+ print("\nLocation:\n%s\nx: %d\ny: %d\nz: %d\n",
+ g_context->_location->_map->getName().c_str(), pos.x, pos.y, pos.z);
+ }
+
+ return isActive();
+}
+
+bool Debugger::cmdMixtures(int argc, const char **argv) {
+ for (int i = 0; i < SPELL_MAX; i++)
+ g_ultima->_saveGame->_mixtures[i] = 99;
+
+ screenMessage("All mixtures given");
+ return isActive();
+}
+
bool Debugger::cmdMoon(int argc, const char **argv) {
int moonNum;
@@ -188,6 +329,32 @@ bool Debugger::cmdMoon(int argc, const char **argv) {
return isActive();
}
+bool Debugger::cmdOpacity(int argc, const char **argv) {
+ g_context->_opacity = !g_context->_opacity;
+ screenMessage("Opacity is %s", g_context->_opacity ? "on" : "off");
+ return isActive();
+}
+
+bool Debugger::cmdPeer(int argc, const char **argv) {
+ if ((g_context->_location->_viewMode == VIEW_NORMAL) || (g_context->_location->_viewMode == VIEW_DUNGEON))
+ g_context->_location->_viewMode = VIEW_GEM;
+ else if (g_context->_location->_context == CTX_DUNGEON)
+ g_context->_location->_viewMode = VIEW_DUNGEON;
+ else
+ g_context->_location->_viewMode = VIEW_NORMAL;
+
+ print("Toggle view");
+ return isActive();
+}
+
+bool Debugger::cmdReagents(int argc, const char **argv) {
+ for (int i = 0; i < REAG_MAX; i++)
+ g_ultima->_saveGame->_reagents[i] = 99;
+
+ print("Reagents given");
+ return isActive();
+}
+
bool Debugger::cmdStats(int argc, const char **argv) {
for (int i = 0; i < g_ultima->_saveGame->_members; i++) {
g_ultima->_saveGame->_players[i]._str = 50;
@@ -205,5 +372,193 @@ bool Debugger::cmdStats(int argc, const char **argv) {
return isActive();
}
+bool Debugger::cmdSummon(int argc, const char **argv) {
+ Common::String creature;
+
+ if (argc == 2) {
+ creature = argv[1];
+ } else if (isActive()) {
+ print("summon <creature name>");
+ return true;
+ } else {
+ screenMessage("Summon!\n");
+ screenMessage("What?\n");
+ creature = gameGetInput();
+ }
+
+ summonCreature(creature);
+ return isActive();
+}
+
+bool Debugger::cmdTransport(int argc, const char **argv) {
+ if (!g_context->_location->_map->isWorldMap()) {
+ print("Not here!");
+ return isActive();
+ }
+
+ MapCoords coords = g_context->_location->_coords;
+ MapTile *choice;
+ Tile *tile;
+
+ screenMessage("Create transport!\nWhich? ");
+
+ // Get the transport of choice
+ char transport;
+ if (argc == 2) {
+ transport = argv[1][0];
+ } else if (isActive()) {
+ print("transport <transport name>");
+ return isActive();
+ } else {
+ transport = ReadChoiceController::get("shb \033\015");
+ }
+
+ switch (transport) {
+ case 's':
+ choice = &_ship;
+ break;
+ case 'h':
+ choice = &_horse;
+ break;
+ case 'b':
+ choice = &_balloon;
+ break;
+ default:
+ print("Unknown transport");
+ return isActive();
+ }
+
+ if (choice) {
+ ReadDirController readDir;
+ tile = g_context->_location->_map->_tileset->get(choice->getId());
+
+ screenMessage("%s\n", tile->getName().c_str());
+
+ // Get the direction in which to create the transport
+ eventHandler->pushController(&readDir);
+
+ screenMessage("Dir: ");
+ coords.move(readDir.waitFor(), g_context->_location->_map);
+ if (coords != g_context->_location->_coords) {
+ bool ok = false;
+ MapTile *ground = g_context->_location->_map->tileAt(coords, WITHOUT_OBJECTS);
+
+ screenMessage("%s\n", getDirectionName(readDir.getValue()));
+
+ switch (transport) {
+ case 's':
+ ok = ground->getTileType()->isSailable();
+ break;
+ case 'h':
+ ok = ground->getTileType()->isWalkable();
+ break;
+ case 'b':
+ ok = ground->getTileType()->isWalkable();
+ break;
+ default:
+ break;
+ }
+
+ if (choice && ok) {
+ g_context->_location->_map->addObject(*choice, *choice, coords);
+ print("%s created!", tile->getName().c_str());
+ } else if (!choice) {
+ print("Invalid transport!");
+ } else {
+ print("Can't place %s there!", tile->getName().c_str());
+ }
+ }
+ }
+
+ return isActive();
+}
+
+bool Debugger::cmdUp(int argc, const char **argv) {
+ if ((g_context->_location->_context & CTX_DUNGEON) && (g_context->_location->_coords.z > 0)) {
+ g_context->_location->_coords.z--;
+ g_game->finishTurn();
+
+ return false;
+ } else {
+ print("Leaving...");
+ g_game->exitToParentMap();
+ g_music->play();
+
+ return isActive();
+ }
+}
+
+bool Debugger::cmdDown(int argc, const char **argv) {
+ if ((g_context->_location->_context & CTX_DUNGEON) && (g_context->_location->_coords.z < 7)) {
+ g_context->_location->_coords.z++;
+ return false;
+ } else {
+ print("Not here");
+ return isActive();
+ }
+}
+
+bool Debugger::cmdVirtue(int argc, const char **argv) {
+ if (argc == 1) {
+ for (int i = 0; i < 8; i++)
+ g_ultima->_saveGame->_karma[i] = 0;
+
+ g_context->_stats->update();
+ screenMessage("Full virtues");
+ } else {
+ int virtue = strToInt(argv[1]);
+
+ if (virtue <= 0 || virtue >= VIRT_MAX) {
+ print("Invalid virtue");
+ } else {
+ print("Improved %s", getVirtueName((Virtue)virtue));
+
+ if (g_ultima->_saveGame->_karma[virtue] == 99)
+ g_ultima->_saveGame->_karma[virtue] = 0;
+ else if (g_ultima->_saveGame->_karma[virtue] != 0)
+ g_ultima->_saveGame->_karma[virtue] += 10;
+ if (g_ultima->_saveGame->_karma[virtue] > 99)
+ g_ultima->_saveGame->_karma[virtue] = 99;
+ g_context->_stats->update();
+ }
+ }
+
+ return isActive();
+}
+
+bool Debugger::cmdWind(int argc, const char **argv) {
+ Common::String windDir;
+
+ if (argc == 2) {
+ windDir = argv[1];
+ } else if (isActive()) {
+ print("wind <direction or 'lock'>");
+ return true;
+ } else {
+ print("Wind Dir ('l' to lock)");
+ windDir = gameGetInput();
+ }
+
+ windDir.toLowercase();
+ if (windDir == "lock" || windDir == "l") {
+ g_context->_windLock = !g_context->_windLock;
+ print("Wind direction is %slocked",
+ g_context->_windLock ? "" : "un");
+ } else if (windDir == "up" || windDir == "north") {
+ g_context->_windDirection = DIR_NORTH;
+ } else if (windDir == "down" || windDir == "south") {
+ g_context->_windDirection = DIR_SOUTH;
+ } else if (windDir == "right" || windDir == "east") {
+ g_context->_windDirection = DIR_EAST;
+ } else if (windDir == "left" || windDir == "west") {
+ g_context->_windDirection = DIR_WEST;
+ } else {
+ print("Unknown direction");
+ return isActive();
+ }
+
+ return false;
+}
+
} // 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 3a52335ea2..71ed4a082d 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/types.h"
#include "ultima/shared/engine/debugger.h"
namespace Ultima {
@@ -32,6 +33,8 @@ namespace Ultima4 {
* Debugger base class
*/
class Debugger : public Shared::Debugger {
+private:
+ MapTile _horse, _ship, _balloon;
private:
/**
* Prints a message to the console if it's active, or to the
@@ -39,16 +42,33 @@ private:
*/
void print(const char *fmt, ...);
+ /**
+ * Summons a creature given by 'creatureName'. This can either be given
+ * as the creature's name, or the creature's id. Once it finds the
+ * creature to be summoned, it calls gameSpawnCreature() to spawn it.
+ */
+ void summonCreature(const Common::String &name);
+private:
/**
* Collision detection on/off
*/
bool cmdCollisions(int argc, const char **argv);
+ /**
+ * Have all the companions join the party
+ */
+ bool cmdCompanions(int argc, const char **argv);
+
/**
* All equipement
*/
bool cmdEquipment(int argc, const char **argv);
+ /**
+ * Exit the current location
+ */
+ bool cmdExit(int argc, const char **argv);
+
/**
* Moongate teleportation
*/
@@ -59,15 +79,81 @@ private:
*/
bool cmdGoto(int argc, const char **argv);
+ /**
+ * Grant karma
+ */
+ bool cmdKarma(int argc, const char **argv);
+
+ /**
+ * Give all the items
+ */
+ bool cmdItems(int argc, const char **argv);
+
+ /**
+ * Displays the current location
+ */
+ bool cmdLocation(int argc, const char **argv);
+
+ /**
+ * Give all the mixtures
+ */
+ bool cmdMixtures(int argc, const char **argv);
+
/**
* Moon phase
*/
bool cmdMoon(int argc, const char **argv);
+ /**
+ * Toggle opacity
+ */
+ bool cmdOpacity(int argc, const char **argv);
+
+ /**
+ * Peer
+ */
+ bool cmdPeer(int argc, const char **argv);
+
+ /**
+ * Give all the reagents
+ */
+ bool cmdReagents(int argc, const char **argv);
+
/**
* Full stats
*/
bool cmdStats(int argc, const char **argv);
+
+ /**
+ * Summons a creature to fight
+ */
+ bool cmdSummon(int argc, const char **argv);
+
+ /**
+ * Creates a given transport
+ */
+ bool cmdTransport(int argc, const char **argv);
+
+ /**
+ * Move up a floor
+ */
+ bool cmdUp(int argc, const char **argv);
+
+ /**
+ * Move down a floor
+ */
+ bool cmdDown(int argc, const char **argv);
+
+ /**
+ * Gives full virtue, or increments a specific virtue
+ */
+ bool cmdVirtue(int argc, const char **argv);
+
+ /**
+ * Set wind direction or locks the direction
+ */
+ bool cmdWind(int argc, const char **argv);
+
public:
bool _collisionOverride;
public:
diff --git a/engines/ultima/ultima4/game/cheat.cpp b/engines/ultima/ultima4/game/cheat.cpp
index 31e1d0b536..d24b87df5b 100644
--- a/engines/ultima/ultima4/game/cheat.cpp
+++ b/engines/ultima/ultima4/game/cheat.cpp
@@ -45,15 +45,12 @@ CheatMenuController::CheatMenuController(GameController *gc) : _game(gc) {
}
bool CheatMenuController::keyPressed(int key) {
- int i;
bool valid = true;
switch (key) {
case 'h': {
screenMessage("Help:\n"
"F1-F8 - +Virtue\n"
- "i - Items\n"
- "k - Show Karma\n"
"(more)");
ReadChoiceController pauseController("");
@@ -61,236 +58,14 @@ bool CheatMenuController::keyPressed(int key) {
pauseController.waitFor();
screenMessage("\n"
- "l - Location\n"
- "m - Mixtures\n"
- "o - Opacity\n"
- "p - Peer\n"
- "r - Reagents\n"
- "s - Summon\n"
"t - Transports\n"
- "v - Full Virtues\n"
- "w - Change Wind\n"
- "x - Exit Map\n"
- "y - Y-up\n"
"(more)");
eventHandler->pushController(&pauseController);
pauseController.waitFor();
-
- screenMessage("\n"
- "z - Z-down\n"
- );
- break;
- }
-
- case 'i':
- screenMessage("Items!\n");
- g_ultima->_saveGame->_torches = 99;
- g_ultima->_saveGame->_gems = 99;
- g_ultima->_saveGame->_keys = 99;
- g_ultima->_saveGame->_sextants = 1;
- g_ultima->_saveGame->_items = ITEM_SKULL | ITEM_CANDLE | ITEM_BOOK | ITEM_BELL | ITEM_KEY_C | ITEM_KEY_L | ITEM_KEY_T | ITEM_HORN | ITEM_WHEEL;
- g_ultima->_saveGame->_stones = 0xff;
- g_ultima->_saveGame->_runes = 0xff;
- g_ultima->_saveGame->_food = 999900;
- g_ultima->_saveGame->_gold = 9999;
- g_context->_stats->update();
- break;
-
- case 'j':
- screenMessage("Joined by companions!\n");
- for (int m = g_ultima->_saveGame->_members; m < 8; m++) {
- debug("m = %d\n", m);
- debug("n = %s\n", g_ultima->_saveGame->_players[m].name);
- if (g_context->_party->canPersonJoin(g_ultima->_saveGame->_players[m].name, NULL)) {
- g_context->_party->join(g_ultima->_saveGame->_players[m].name);
- }
- }
- g_context->_stats->update();
- break;
-
- case 'k':
- screenMessage("Karma!\n\n");
- for (i = 0; i < 8; i++) {
- unsigned int j;
- screenMessage("%s:", getVirtueName(static_cast<Virtue>(i)));
- for (j = 13; j > strlen(getVirtueName(static_cast<Virtue>(i))); j--)
- screenMessage(" ");
- if (g_ultima->_saveGame->_karma[i] > 0)
- screenMessage("%.2d\n", g_ultima->_saveGame->_karma[i]);
- else screenMessage("--\n");
- }
- break;
-
- case 'l':
- if (g_context->_location->_map->isWorldMap())
- screenMessage("\nLocation:\n%s\nx: %d\ny: %d\n", "World Map", g_context->_location->_coords.x, g_context->_location->_coords.y);
- else
- screenMessage("\nLocation:\n%s\nx: %d\ny: %d\nz: %d\n", g_context->_location->_map->getName().c_str(), g_context->_location->_coords.x, g_context->_location->_coords.y, g_context->_location->_coords.z);
- break;
-
- case 'm':
- screenMessage("Mixtures!\n");
- for (i = 0; i < SPELL_MAX; i++)
- g_ultima->_saveGame->_mixtures[i] = 99;
- break;
-
- case 'o':
- g_context->_opacity = !g_context->_opacity;
- screenMessage("Opacity %s!\n", g_context->_opacity ? "on" : "off");
- break;
-
- case 'p':
- if ((g_context->_location->_viewMode == VIEW_NORMAL) || (g_context->_location->_viewMode == VIEW_DUNGEON))
- g_context->_location->_viewMode = VIEW_GEM;
- else if (g_context->_location->_context == CTX_DUNGEON)
- g_context->_location->_viewMode = VIEW_DUNGEON;
- else
- g_context->_location->_viewMode = VIEW_NORMAL;
-
- screenMessage("\nToggle View!\n");
- break;
-
- case 'r':
- screenMessage("Reagents!\n");
- for (i = 0; i < REAG_MAX; i++)
- g_ultima->_saveGame->_reagents[i] = 99;
- break;
-
- case 's':
- screenMessage("Summon!\n");
- screenMessage("What?\n");
- summonCreature(gameGetInput());
- break;
-
- case 't':
- if (g_context->_location->_map->isWorldMap()) {
- MapCoords coords = g_context->_location->_coords;
- static MapTile horse = g_context->_location->_map->_tileset->getByName("horse")->getId(),
- ship = g_context->_location->_map->_tileset->getByName("ship")->getId(),
- balloon = g_context->_location->_map->_tileset->getByName("balloon")->getId();
- MapTile *choice;
- Tile *tile;
-
- screenMessage("Create transport!\nWhich? ");
-
- // Get the transport of choice
- char transport = ReadChoiceController::get("shb \033\015");
- switch (transport) {
- case 's':
- choice = &ship;
- break;
- case 'h':
- choice = &horse;
- break;
- case 'b':
- choice = &balloon;
- break;
- default:
- choice = NULL;
- break;
- }
-
- if (choice) {
- ReadDirController readDir;
- tile = g_context->_location->_map->_tileset->get(choice->getId());
-
- screenMessage("%s\n", tile->getName().c_str());
-
- // Get the direction in which to create the transport
- eventHandler->pushController(&readDir);
-
- screenMessage("Dir: ");
- coords.move(readDir.waitFor(), g_context->_location->_map);
- if (coords != g_context->_location->_coords) {
- bool ok = false;
- MapTile *ground = g_context->_location->_map->tileAt(coords, WITHOUT_OBJECTS);
-
- screenMessage("%s\n", getDirectionName(readDir.getValue()));
-
- switch (transport) {
- case 's':
- ok = ground->getTileType()->isSailable();
- break;
- case 'h':
- ok = ground->getTileType()->isWalkable();
- break;
- case 'b':
- ok = ground->getTileType()->isWalkable();
- break;
- default:
- break;
- }
-
- if (choice && ok) {
- g_context->_location->_map->addObject(*choice, *choice, coords);
- screenMessage("%s created!\n", tile->getName().c_str());
- } else if (!choice)
- screenMessage("Invalid transport!\n");
- else screenMessage("Can't place %s there!\n", tile->getName().c_str());
- }
- } else screenMessage("None!\n");
- }
- break;
-
- case 'v':
- screenMessage("\nFull Virtues!\n");
- for (i = 0; i < 8; i++)
- g_ultima->_saveGame->_karma[i] = 0;
- g_context->_stats->update();
- break;
-
- case 'w': {
- screenMessage("Wind Dir ('l' to lock):\n");
- WindCmdController ctrl;
- eventHandler->pushController(&ctrl);
- ctrl.waitFor();
break;
}
- case 'x':
- screenMessage("\nX-it!\n");
- if (!g_game->exitToParentMap())
- screenMessage("Not Here!\n");
- g_music->play();
- break;
-
- case 'y':
- screenMessage("Y-up!\n");
- if ((g_context->_location->_context & CTX_DUNGEON) && (g_context->_location->_coords.z > 0))
- g_context->_location->_coords.z--;
- else {
- screenMessage("Leaving...\n");
- g_game->exitToParentMap();
- g_music->play();
- }
- break;
-
- case 'z':
- screenMessage("Z-down!\n");
- if ((g_context->_location->_context & CTX_DUNGEON) && (g_context->_location->_coords.z < 7))
- g_context->_location->_coords.z++;
- else screenMessage("Not Here!\n");
- break;
-
- case Common::KEYCODE_F1:
- case Common::KEYCODE_F2:
- case Common::KEYCODE_F3:
- case Common::KEYCODE_F4:
- case Common::KEYCODE_F5:
- case Common::KEYCODE_F6:
- case Common::KEYCODE_F7:
- case Common::KEYCODE_F8:
- screenMessage("Improve %s!\n", getVirtueName(static_cast<Virtue>(key - Common::KEYCODE_F1)));
- if (g_ultima->_saveGame->_karma[key - Common::KEYCODE_F1] == 99)
- g_ultima->_saveGame->_karma[key - Common::KEYCODE_F1] = 0;
- else if (g_ultima->_saveGame->_karma[key - Common::KEYCODE_F1] != 0)
- g_ultima->_saveGame->_karma[key - Common::KEYCODE_F1] += 10;
- if (g_ultima->_saveGame->_karma[key - Common::KEYCODE_F1] > 99)
- g_ultima->_saveGame->_karma[key - Common::KEYCODE_F1] = 99;
- g_context->_stats->update();
- break;
-
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_RETURN:
case Common::KEYCODE_SPACE:
@@ -310,35 +85,6 @@ bool CheatMenuController::keyPressed(int key) {
return valid;
}
-void CheatMenuController::summonCreature(const Common::String &name) {
- const Creature *m = NULL;
- Common::String creatureName = name;
-
- trim(creatureName);
- if (creatureName.empty()) {
- screenMessage("\n");
- return;
- }
-
- /* find the creature by its id and spawn it */
- unsigned int id = atoi(creatureName.c_str());
- if (id > 0)
- m = creatureMgr->getById(id);
-
- if (!m)
- m = creatureMgr->getByName(creatureName);
-
- if (m) {
- if (gameSpawnCreature(m))
- screenMessage("\n%s summoned!\n", m->getName().c_str());
- else screenMessage("\n\nNo place to put %s!\n\n", m->getName().c_str());
-
- return;
- }
-
- screenMessage("\n%s not found\n", creatureName.c_str());
-}
-
bool WindCmdController::keyPressed(int key) {
switch (key) {
case Common::KEYCODE_UP:
diff --git a/engines/ultima/ultima4/game/cheat.h b/engines/ultima/ultima4/game/cheat.h
index 8d4eb7ed6a..1f5c820556 100644
--- a/engines/ultima/ultima4/game/cheat.h
+++ b/engines/ultima/ultima4/game/cheat.h
@@ -37,13 +37,6 @@ public:
bool keyPressed(int key);
private:
- /**
- * Summons a creature given by 'creatureName'. This can either be given
- * as the creature's name, or the creature's id. Once it finds the
- * creature to be summoned, it calls gameSpawnCreature() to spawn it.
- */
- void summonCreature(const Common::String &name);
-
GameController *_game;
};
Commit: 1ac6450cdd42204146fde86e2a5c6de576b76e7f
https://github.com/scummvm/scummvm/commit/1ac6450cdd42204146fde86e2a5c6de576b76e7f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-11T17:54:13-07:00
Commit Message:
ULTIMA4: Remove old cheat controller
Changed paths:
R engines/ultima/ultima4/game/cheat.cpp
R engines/ultima/ultima4/game/cheat.h
engines/ultima/module.mk
engines/ultima/ultima4/game/game.cpp
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 0e002290e4..38f2d8ca4e 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -157,7 +157,6 @@ MODULE_OBJS := \
ultima4/filesys/u4file.o \
ultima4/game/armor.o \
ultima4/game/aura.o \
- ultima4/game/cheat.o \
ultima4/game/codex.o \
ultima4/game/context.o \
ultima4/game/creature.o \
diff --git a/engines/ultima/ultima4/game/cheat.cpp b/engines/ultima/ultima4/game/cheat.cpp
deleted file mode 100644
index d24b87df5b..0000000000
--- a/engines/ultima/ultima4/game/cheat.cpp
+++ /dev/null
@@ -1,110 +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 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/game/cheat.h"
-#include "ultima/ultima4/game/context.h"
-#include "ultima/ultima4/game/game.h"
-#include "ultima/ultima4/game/moongate.h"
-#include "ultima/ultima4/game/portal.h"
-#include "ultima/ultima4/game/player.h"
-#include "ultima/ultima4/game/stats.h"
-#include "ultima/ultima4/game/weapon.h"
-#include "ultima/ultima4/gfx/screen.h"
-#include "ultima/ultima4/map/location.h"
-#include "ultima/ultima4/map/map.h"
-#include "ultima/ultima4/map/mapmgr.h"
-#include "ultima/ultima4/map/tileset.h"
-#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/sound/music.h"
-#include "common/debug.h"
-#include "common/events.h"
-
-namespace Ultima {
-namespace Ultima4 {
-
-CheatMenuController::CheatMenuController(GameController *gc) : _game(gc) {
-}
-
-bool CheatMenuController::keyPressed(int key) {
- bool valid = true;
-
- switch (key) {
- case 'h': {
- screenMessage("Help:\n"
- "F1-F8 - +Virtue\n"
- "(more)");
-
- ReadChoiceController pauseController("");
- eventHandler->pushController(&pauseController);
- pauseController.waitFor();
-
- screenMessage("\n"
- "t - Transports\n"
- "(more)");
-
- eventHandler->pushController(&pauseController);
- pauseController.waitFor();
- break;
- }
-
- case Common::KEYCODE_ESCAPE:
- case Common::KEYCODE_RETURN:
- case Common::KEYCODE_SPACE:
- screenMessage("Nothing\n");
- break;
-
- default:
- valid = false;
- break;
- }
-
- if (valid) {
- doneWaiting();
- screenPrompt();
- }
-
- return valid;
-}
-
-bool WindCmdController::keyPressed(int key) {
- switch (key) {
- case Common::KEYCODE_UP:
- case Common::KEYCODE_LEFT:
- case Common::KEYCODE_DOWN:
- case Common::KEYCODE_RIGHT:
- g_context->_windDirection = keyToDirection(key);
- screenMessage("Wind %s!\n", getDirectionName(static_cast<Direction>(g_context->_windDirection)));
- doneWaiting();
- return true;
-
- case 'l':
- g_context->_windLock = !g_context->_windLock;
- screenMessage("Wind direction is %slocked!\n", g_context->_windLock ? "" : "un");
- doneWaiting();
- return true;
- }
-
- return KeyHandler::defaultHandler(key, NULL);
-}
-
-} // End of namespace Ultima4
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/game/cheat.h b/engines/ultima/ultima4/game/cheat.h
deleted file mode 100644
index 1f5c820556..0000000000
--- a/engines/ultima/ultima4/game/cheat.h
+++ /dev/null
@@ -1,56 +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 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_CHEAT_H
-#define ULTIMA4_CHEAT_H
-
-#include "ultima/ultima4/events/controller.h"
-#include "common/str.h"
-
-namespace Ultima {
-namespace Ultima4 {
-
-class GameController;
-
-class CheatMenuController : public WaitableController<void *> {
-public:
- CheatMenuController(GameController *gc);
- bool keyPressed(int key);
-
-private:
- GameController *_game;
-};
-
-/**
- * This class controls the wind option from the cheat menu. It
- * handles setting the wind direction as well as locking/unlocking.
- * The value field of WaitableController isn't used.
- */
-class WindCmdController : public WaitableController<void *> {
-public:
- bool keyPressed(int key);
-};
-
-} // End of namespace Ultima4
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index dfc15d20df..21f0e41335 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -31,7 +31,6 @@
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/game/armor.h"
-#include "ultima/ultima4/game/cheat.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/death.h"
#include "ultima/ultima4/game/intro.h"
@@ -698,15 +697,6 @@ bool GameController::keyPressed(int key) {
} else valid = false;
break;
- case 3: /* ctrl-C */
- if (settings._debug) {
- screenMessage("Cmd (h = help):");
- CheatMenuController cheatMenuController(this);
- eventHandler->pushController(&cheatMenuController);
- cheatMenuController.waitFor();
- } else valid = false;
- break;
-
case 4: /* ctrl-D */
if (settings._debug) {
destroy();
Commit: 3a29bc3e18361c7fdb0a6f398e274ff038e95e35
https://github.com/scummvm/scummvm/commit/3a29bc3e18361c7fdb0a6f398e274ff038e95e35
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-11T17:54:13-07:00
Commit Message:
ULTIMA4: Fixes to transport debugger action
Changed paths:
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/core/debugger.h
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 24ff750960..e2fa238765 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -37,10 +37,7 @@ namespace Ultima4 {
Debugger *g_debugger;
-Debugger::Debugger() : Shared::Debugger(),
- _horse(g_context->_location->_map->_tileset->getByName("horse")->getId()),
- _ship(g_context->_location->_map->_tileset->getByName("ship")->getId()),
- _balloon(g_context->_location->_map->_tileset->getByName("balloon")->getId()) {
+Debugger::Debugger() : Shared::Debugger() {
g_debugger = this;
_collisionOverride = false;
@@ -60,6 +57,7 @@ Debugger::Debugger() : Shared::Debugger(),
registerCmd("reagents", WRAP_METHOD(Debugger, cmdReagents));
registerCmd("stats", WRAP_METHOD(Debugger, cmdStats));
registerCmd("summon", WRAP_METHOD(Debugger, cmdSummon));
+ registerCmd("transport", WRAP_METHOD(Debugger, cmdTransport));
registerCmd("up", WRAP_METHOD(Debugger, cmdUp));
registerCmd("down", WRAP_METHOD(Debugger, cmdDown));
registerCmd("virtue", WRAP_METHOD(Debugger, cmdVirtue));
@@ -114,6 +112,22 @@ void Debugger::summonCreature(const Common::String &name) {
print("\n%s not found\n", creatureName.c_str());
}
+Direction Debugger::directionFromName(const Common::String &dirStr) {
+ Common::String dir = dirStr;
+ dir.toLowercase();
+
+ if (dir == "up" || dir == "north")
+ return DIR_NORTH;
+ else if (dir == "down" || dir == "south")
+ return DIR_SOUTH;
+ else if (dir == "right" || dir == "east")
+ return DIR_EAST;
+ else if (dir == "left" || dir == "west")
+ return DIR_WEST;
+
+ return DIR_NONE;
+}
+
bool Debugger::cmdCollisions(int argc, const char **argv) {
_collisionOverride = !_collisionOverride;
@@ -396,15 +410,17 @@ bool Debugger::cmdTransport(int argc, const char **argv) {
return isActive();
}
+ _horse = g_context->_location->_map->_tileset->getByName("horse")->getId();
+ _ship = g_context->_location->_map->_tileset->getByName("ship")->getId();
+ _balloon = g_context->_location->_map->_tileset->getByName("balloon")->getId();
+
MapCoords coords = g_context->_location->_coords;
MapTile *choice;
Tile *tile;
- screenMessage("Create transport!\nWhich? ");
-
// Get the transport of choice
char transport;
- if (argc == 2) {
+ if (argc >= 2) {
transport = argv[1][0];
} else if (isActive()) {
print("transport <transport name>");
@@ -428,45 +444,51 @@ bool Debugger::cmdTransport(int argc, const char **argv) {
return isActive();
}
- if (choice) {
- ReadDirController readDir;
- tile = g_context->_location->_map->_tileset->get(choice->getId());
+ tile = g_context->_location->_map->_tileset->get(choice->getId());
+ Direction dir;
+ if (argc == 3) {
+ dir = directionFromName(argv[2]);
+ } else if (isActive()) {
+ dir = DIR_NONE;
+ } else {
screenMessage("%s\n", tile->getName().c_str());
// Get the direction in which to create the transport
+ ReadDirController readDir;
eventHandler->pushController(&readDir);
screenMessage("Dir: ");
- coords.move(readDir.waitFor(), g_context->_location->_map);
- if (coords != g_context->_location->_coords) {
- bool ok = false;
- MapTile *ground = g_context->_location->_map->tileAt(coords, WITHOUT_OBJECTS);
-
- screenMessage("%s\n", getDirectionName(readDir.getValue()));
-
- switch (transport) {
- case 's':
- ok = ground->getTileType()->isSailable();
- break;
- case 'h':
- ok = ground->getTileType()->isWalkable();
- break;
- case 'b':
- ok = ground->getTileType()->isWalkable();
- break;
- default:
- break;
- }
+ dir = readDir.waitFor();
+ }
- if (choice && ok) {
- g_context->_location->_map->addObject(*choice, *choice, coords);
- print("%s created!", tile->getName().c_str());
- } else if (!choice) {
- print("Invalid transport!");
- } else {
- print("Can't place %s there!", tile->getName().c_str());
- }
+ coords.move(dir, g_context->_location->_map);
+
+ if (coords != g_context->_location->_coords) {
+ bool ok = false;
+ MapTile *ground = g_context->_location->_map->tileAt(coords, WITHOUT_OBJECTS);
+
+ switch (transport) {
+ case 's':
+ ok = ground->getTileType()->isSailable();
+ break;
+ case 'h':
+ ok = ground->getTileType()->isWalkable();
+ break;
+ case 'b':
+ ok = ground->getTileType()->isWalkable();
+ break;
+ default:
+ break;
+ }
+
+ if (choice && ok) {
+ g_context->_location->_map->addObject(*choice, *choice, coords);
+ print("%s created!", tile->getName().c_str());
+ } else if (!choice) {
+ print("Invalid transport!");
+ } else {
+ print("Can't place %s there!", tile->getName().c_str());
}
}
@@ -544,17 +566,15 @@ bool Debugger::cmdWind(int argc, const char **argv) {
g_context->_windLock = !g_context->_windLock;
print("Wind direction is %slocked",
g_context->_windLock ? "" : "un");
- } else if (windDir == "up" || windDir == "north") {
- g_context->_windDirection = DIR_NORTH;
- } else if (windDir == "down" || windDir == "south") {
- g_context->_windDirection = DIR_SOUTH;
- } else if (windDir == "right" || windDir == "east") {
- g_context->_windDirection = DIR_EAST;
- } else if (windDir == "left" || windDir == "west") {
- g_context->_windDirection = DIR_WEST;
} else {
- print("Unknown direction");
- return isActive();
+ Direction dir = directionFromName(windDir);
+
+ if (dir == DIR_NONE) {
+ print("Unknown direction");
+ return isActive();
+ } else {
+ g_context->_windDirection = dir;
+ }
}
return false;
diff --git a/engines/ultima/ultima4/core/debugger.h b/engines/ultima/ultima4/core/debugger.h
index 71ed4a082d..3c934b4d12 100644
--- a/engines/ultima/ultima4/core/debugger.h
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -48,6 +48,11 @@ private:
* creature to be summoned, it calls gameSpawnCreature() to spawn it.
*/
void summonCreature(const Common::String &name);
+
+ /**
+ * Returns a direction from a given string
+ */
+ Direction directionFromName(const Common::String &dirStr);
private:
/**
* Collision detection on/off
More information about the Scummvm-git-logs
mailing list