diff options
author | Eugene Sandulenko | 2016-01-04 00:42:10 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-01-04 00:42:10 +0100 |
commit | cc14b5f96fc6457e240d8c7c9a9c16422dc3586d (patch) | |
tree | 08d4e70cf0beae746a621dee01f84fc7033a877a | |
parent | 2c8922ed3094e20afa53861e95a0b5d97460feee (diff) | |
download | scummvm-rg350-cc14b5f96fc6457e240d8c7c9a9c16422dc3586d.tar.gz scummvm-rg350-cc14b5f96fc6457e240d8c7c9a9c16422dc3586d.tar.bz2 scummvm-rg350-cc14b5f96fc6457e240d8c7c9a9c16422dc3586d.zip |
WAGE: Implement handleMoveCommand()
-rw-r--r-- | engines/wage/script.cpp | 31 | ||||
-rw-r--r-- | engines/wage/world.cpp | 11 | ||||
-rw-r--r-- | engines/wage/world.h | 1 |
3 files changed, 42 insertions, 1 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 740d8ec164..c08b06be22 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -925,8 +925,37 @@ void Script::appendText(String str) { _callbacks->appendText(str); } +static const int directionsX[] = { 0, 0, 1, -1 }; +static const int directionsY[] = { -1, 1, 0, 0 }; + void Script::handleMoveCommand(Scene::Directions dir, const char *dirName) { - warning("STUB: handleMoveCommand"); + Scene *playerScene = _world->_player->_currentScene; + Common::String msg(playerScene->_messages[dir]); + + warning("Dir: %s msg: %s", dirName, msg.c_str()); + + if (!playerScene->_blocked[dir]) { + int destX = playerScene->_worldX + directionsX[dir]; + int destY = playerScene->_worldY + directionsY[dir]; + + Scene *scene = _world->getSceneAt(destX, destY); + + if (scene != NULL) { + if (msg.size() > 0) { + appendText(msg); + } + _world->move(_world->_player, scene); + return; + } + } + if (msg != NULL && msg.size() > 0) { + appendText(msg); + } else { + Common::String txt("You can't go "); + txt += dirName; + txt += "."; + appendText(txt); + } } void Script::handleLookCommand() { diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp index e7c37c17d5..f0d7c974a8 100644 --- a/engines/wage/world.cpp +++ b/engines/wage/world.cpp @@ -434,4 +434,15 @@ Scene *World::getRandomScene() { return _orderedScenes[1 + _engine->_rnd->getRandomNumber(_orderedScenes.size() - 1)]; } +Scene *World::getSceneAt(int x, int y) { + for (int i = 0; i < _orderedScenes.size(); i++) { + Scene *scene = _orderedScenes[i]; + + if (scene != _storageScene && scene->_worldX == x && scene->_worldY == y) { + return scene; + } + } + return NULL; +} + } // End of namespace Wage diff --git a/engines/wage/world.h b/engines/wage/world.h index ea003220f0..a4ca2fd66f 100644 --- a/engines/wage/world.h +++ b/engines/wage/world.h @@ -64,6 +64,7 @@ public: void move(Obj *obj, Scene *scene, bool skipSort = false); void move(Chr *chr, Scene *scene, bool skipSort = false); Scene *getRandomScene(); + Scene *getSceneAt(int x, int y); WageEngine *_engine; |