From 5381f5d56b24ed65e1a4eef32e4e749fb4f85022 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 5 Oct 2011 14:37:34 -0400 Subject: PEGASUS: Implement basic jump console command --- engines/pegasus/console.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'engines/pegasus/console.cpp') diff --git a/engines/pegasus/console.cpp b/engines/pegasus/console.cpp index 2c1a761ddf..e6738bc83f 100644 --- a/engines/pegasus/console.cpp +++ b/engines/pegasus/console.cpp @@ -24,12 +24,18 @@ */ #include "pegasus/console.h" +#include "pegasus/interface.h" #include "pegasus/pegasus.h" +#include "pegasus/neighborhood/neighborhood.h" namespace Pegasus { PegasusConsole::PegasusConsole(PegasusEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("die", WRAP_METHOD(PegasusConsole, Cmd_Die)); + + // These functions are non-demo specific + if (!_vm->isDemo()) + DCmd_Register("jump", WRAP_METHOD(PegasusConsole, Cmd_Jump)); } PegasusConsole::~PegasusConsole() { @@ -59,4 +65,40 @@ bool PegasusConsole::Cmd_Die(int argc, const char **argv) { return false; } +bool PegasusConsole::Cmd_Jump(int argc, const char **argv) { + if (!g_interface) { + // TODO + DebugPrintf("Cannot jump without interface set up\n"); + return true; + } + + // TODO: Default room/direction for each neighborhood + + if (argc < 4) { + DebugPrintf("Usage: jump \n"); + return true; + } + + tNeighborhoodID neighborhood = (tNeighborhoodID)atoi(argv[1]); + tRoomID room = (tRoomID)atoi(argv[2]); + tDirectionConstant direction = (tDirectionConstant)atoi(argv[3]); + + if (neighborhood < kCaldoriaID || neighborhood > kNoradDeltaID || neighborhood == kFinalTSAID) { + DebugPrintf("Invalid neighborhood %d", neighborhood); + return true; + } + + // No real way to check room validity at this point + + if (direction > kWest) { + DebugPrintf("Invalid direction %d", direction); + return true; + } + + // Here we go! + // TODO: Can't clear menu since the engine is paused + _vm->jumpToNewEnvironment(neighborhood, room, direction); + return false; +} + } // End of namespace Pegasus -- cgit v1.2.3