aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2010-01-03 15:08:26 +0000
committerFilippos Karapetis2010-01-03 15:08:26 +0000
commit2f23eb99ee75db397593fc0dc8f389fc1f3316ce (patch)
treeba205364f1f8559b4de78f41a10c12ea7977b17b /engines
parent454fb24c852b05dbd7b4fbcd3f74f902e1877aa8 (diff)
downloadscummvm-rg350-2f23eb99ee75db397593fc0dc8f389fc1f3316ce.tar.gz
scummvm-rg350-2f23eb99ee75db397593fc0dc8f389fc1f3316ce.tar.bz2
scummvm-rg350-2f23eb99ee75db397593fc0dc8f389fc1f3316ce.zip
The "room" command can now set the current room number, too (more straightforward than changing global var 13)
svn-id: r46925
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/console.cpp15
-rw-r--r--engines/sci/engine/state.cpp4
-rw-r--r--engines/sci/engine/state.h1
3 files changed, 18 insertions, 2 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 0e71131f0d..fcb0ab5340 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -327,7 +327,7 @@ bool Console::cmdHelp(int argc, const char **argv) {
DebugPrintf(" list_saves - List all saved games including filenames\n");
DebugPrintf(" restart_game - Restarts the game\n");
DebugPrintf(" version - Shows the resource and interpreter versions\n");
- DebugPrintf(" room - Shows the current room number\n");
+ DebugPrintf(" room - Gets or sets the current room number\n");
DebugPrintf(" exit - Exits the game\n");
DebugPrintf("\n");
DebugPrintf("Screen:\n");
@@ -630,7 +630,18 @@ bool Console::cmdDissectScript(int argc, const char **argv) {
}
bool Console::cmdRoomNumber(int argc, const char **argv) {
- DebugPrintf("Current room number is %d\n", _vm->_gamestate->currentRoomNumber());
+ // The room number is stored in global var 13
+ // The same functionality is provided by "vmvars g 13" (but this one is more straighforward)
+
+ if (argc != 2) {
+ DebugPrintf("Current room number is %d\n", _vm->_gamestate->currentRoomNumber());
+ DebugPrintf("Calling this command with the room number (in decimal or hexadecimal) changes the room\n");
+ } else {
+ Common::String roomNumberStr = argv[1];
+ int roomNumber = strtol(roomNumberStr.c_str(), NULL, roomNumberStr.hasSuffix("h") ? 16 : 10);
+ _vm->getEngineState()->setRoomNumber(roomNumber);
+ DebugPrintf("Room number changed to %d (%x in hex)\n", roomNumber, roomNumber);
+ }
return true;
}
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index a6b924b4a8..167fab5de9 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -120,6 +120,10 @@ uint16 EngineState::currentRoomNumber() const {
return script_000->_localsBlock->_locals[13].toUint16();
}
+void EngineState::setRoomNumber(uint16 roomNumber) {
+ script_000->_localsBlock->_locals[13] = make_reg(0, roomNumber);
+}
+
kLanguage EngineState::charToLanguage(const char c) const {
switch (c) {
case 'F':
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 54fb14c24e..ddfebddf19 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -226,6 +226,7 @@ public:
Script *script_000; /**< script 000, e.g. for globals */
uint16 currentRoomNumber() const;
+ void setRoomNumber(uint16 roomNumber);
/**
* Processes a multilanguage string based on the current language settings and