From 851c2d6f70649f048d9723d3012354fcda8594f8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 24 Jan 2016 20:58:18 +0100 Subject: [PATCH] WAGE: Implement getValidMoveDirections() --- engines/wage/combat.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp index 96235d7da110..9002fa97219b 100644 --- a/engines/wage/combat.cpp +++ b/engines/wage/combat.cpp @@ -285,10 +285,26 @@ void WageEngine::performTake(Chr *npc, Obj *obj) { _world->move(obj, npc); } +static const int directionsX[] = { 0, 0, 1, -1 }; +static const int directionsY[] = { -1, 1, 0, 0 }; + int WageEngine::getValidMoveDirections(Chr *npc) { - warning("STUB: getValidMoveDirections()"); + int directions = 0; + Scene *currentScene = npc->_currentScene; + for (int dir = 0; dir < 4; dir++) { + if (!currentScene->_blocked[dir]) { + int destX = currentScene->_worldX + directionsX[dir]; + int destY = currentScene->_worldY + directionsY[dir]; - return 0; + Scene *scene = _world->getSceneAt(destX, destY); + + if (scene != NULL && scene->_chrs.size() == 0) { + directions |= (1 << dir); + } + } + } + + return directions; } void WageEngine::regen() { @@ -331,9 +347,6 @@ void WageEngine::takeObj(Obj *obj) { } } -static const int directionsX[] = { 0, 0, 1, -1 }; -static const int directionsY[] = { -1, 1, 0, 0 }; - bool WageEngine::handleMoveCommand(Directions dir, const char *dirName) { Scene *playerScene = _world->_player->_currentScene; const char *msg = playerScene->_messages[dir].c_str();