aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
authorstrangerke2011-05-25 23:36:50 +0200
committerstrangerke2011-05-25 23:39:28 +0200
commitc6ef39dcf20cecef3639d686fd188fc9c7118421 (patch)
tree5e56b5ae38b1063704622a1f592295bc3f37186e /engines/hugo
parentdceaa08e69f820b4901cc5b690c1c63487e8063d (diff)
downloadscummvm-rg350-c6ef39dcf20cecef3639d686fd188fc9c7118421.tar.gz
scummvm-rg350-c6ef39dcf20cecef3639d686fd188fc9c7118421.tar.bz2
scummvm-rg350-c6ef39dcf20cecef3639d686fd188fc9c7118421.zip
HUGO: Add 3 object related functions to the console
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/console.cpp64
-rw-r--r--engines/hugo/console.h3
-rw-r--r--engines/hugo/parser.h5
3 files changed, 66 insertions, 6 deletions
diff --git a/engines/hugo/console.cpp b/engines/hugo/console.cpp
index 5c7b5ce412..0a67b5cd0a 100644
--- a/engines/hugo/console.cpp
+++ b/engines/hugo/console.cpp
@@ -22,15 +22,20 @@
#include "hugo/console.h"
#include "hugo/hugo.h"
+#include "hugo/object.h"
+#include "hugo/parser.h"
#include "hugo/schedule.h"
#include "hugo/text.h"
namespace Hugo {
HugoConsole::HugoConsole(HugoEngine *vm) : GUI::Debugger(), _vm(vm) {
- DCmd_Register("listscreens", WRAP_METHOD(HugoConsole, Cmd_listScreens));
- DCmd_Register("gotoscreen", WRAP_METHOD(HugoConsole, Cmd_gotoScreen));
- DCmd_Register("Boundaries", WRAP_METHOD(HugoConsole, Cmd_boundaries));
+ DCmd_Register("listscreens", WRAP_METHOD(HugoConsole, Cmd_listScreens));
+ DCmd_Register("listobjects", WRAP_METHOD(HugoConsole, Cmd_listObjects));
+ DCmd_Register("getobject", WRAP_METHOD(HugoConsole, Cmd_getObject));
+ DCmd_Register("getallobjects", WRAP_METHOD(HugoConsole, Cmd_getAllObjects));
+ DCmd_Register("gotoscreen", WRAP_METHOD(HugoConsole, Cmd_gotoScreen));
+ DCmd_Register("Boundaries", WRAP_METHOD(HugoConsole, Cmd_boundaries));
}
HugoConsole::~HugoConsole() {
@@ -56,7 +61,7 @@ static int strToInt(const char *s) {
* This command loads up the specified screen number
*/
bool HugoConsole::Cmd_gotoScreen(int argc, const char **argv) {
- if (argc != 2) {
+ if ((argc != 2) || (strToInt(argv[1]) > _vm->_numScreens)){
DebugPrintf("Usage: %s <screen number>\n", argv[0]);
return true;
}
@@ -81,6 +86,57 @@ bool HugoConsole::Cmd_listScreens(int argc, const char **argv) {
}
/**
+ * This command lists all the objects available
+ */
+bool HugoConsole::Cmd_listObjects(int argc, const char **argv) {
+ if (argc != 1) {
+ DebugPrintf("Usage: %s\n", argv[0]);
+ return true;
+ }
+
+ DebugPrintf("Available objects for this game are:\n");
+ for (int i = 0; i < _vm->_object->_numObj; i++) {
+ if (_vm->_object->_objects[i].genericCmd & TAKE)
+ DebugPrintf("%2d - %s\n", i, _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2));
+ }
+ return true;
+}
+
+/**
+ * This command puts an object in the inventory
+ */
+bool HugoConsole::Cmd_getObject(int argc, const char **argv) {
+ if ((argc != 2) || (strToInt(argv[1]) > _vm->_object->_numObj)) {
+ DebugPrintf("Usage: %s <object number>\n", argv[0]);
+ return true;
+ }
+
+ if (_vm->_object->_objects[strToInt(argv[1])].genericCmd & TAKE)
+ _vm->_parser->takeObject(&_vm->_object->_objects[strToInt(argv[1])]);
+ else
+ DebugPrintf("Object not available\n");
+
+ return true;
+}
+
+/**
+ * This command puts all the available objects in the inventory
+ */
+bool HugoConsole::Cmd_getAllObjects(int argc, const char **argv) {
+ if (argc != 1) {
+ DebugPrintf("Usage: %s\n", argv[0]);
+ return true;
+ }
+
+ for (int i = 0; i < _vm->_object->_numObj; i++) {
+ if (_vm->_object->_objects[i].genericCmd & TAKE)
+ _vm->_parser->takeObject(&_vm->_object->_objects[i]);
+ }
+
+ return false;
+}
+
+/**
* This command shows and hides boundaries
*/
bool HugoConsole::Cmd_boundaries(int argc, const char **argv) {
diff --git a/engines/hugo/console.h b/engines/hugo/console.h
index 150bc2e4be..16317e83d5 100644
--- a/engines/hugo/console.h
+++ b/engines/hugo/console.h
@@ -37,6 +37,9 @@ public:
private:
HugoEngine *_vm;
bool Cmd_listScreens(int argc, const char **argv);
+ bool Cmd_listObjects(int argc, const char **argv);
+ bool Cmd_getObject(int argc, const char **argv);
+ bool Cmd_getAllObjects(int argc, const char **argv);
bool Cmd_gotoScreen(int argc, const char **argv);
bool Cmd_boundaries(int argc, const char **argv);
};
diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h
index 6ad2b38234..faa6dc2303 100644
--- a/engines/hugo/parser.h
+++ b/engines/hugo/parser.h
@@ -97,6 +97,7 @@ public:
virtual void lineHandler() = 0;
virtual void showInventory() const = 0;
+ virtual void takeObject(object_t *obj) = 0;
protected:
HugoEngine *_vm;
@@ -135,10 +136,10 @@ public:
virtual void lineHandler();
virtual void showInventory() const;
+ virtual void takeObject(object_t *obj);
protected:
- virtual void dropObject(object_t *obj);
- virtual void takeObject(object_t *obj);
+ virtual void dropObject(object_t *obj);
const char *findNextNoun(const char *noun) const;
bool isBackgroundWord_v1(const char *noun, const char *verb, objectList_t obj) const;