aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorlukaslw2014-03-06 04:20:47 +0100
committerlukaslw2014-04-28 21:42:10 +0200
commitb3de0843a9cd66e133a33b467da1f6ba1a572db9 (patch)
treeb9372a2c6cef2f4e9cbaa66e9731feac6df5e6df /engines/draci
parentf74c46e93efa23db094599e9307caf80ebf5bcda (diff)
downloadscummvm-rg350-b3de0843a9cd66e133a33b467da1f6ba1a572db9.tar.gz
scummvm-rg350-b3de0843a9cd66e133a33b467da1f6ba1a572db9.tar.bz2
scummvm-rg350-b3de0843a9cd66e133a33b467da1f6ba1a572db9.zip
DRACI: Opening inventory during movements and actions.
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/game.cpp20
-rw-r--r--engines/draci/game.h1
-rw-r--r--engines/draci/walking.cpp8
-rw-r--r--engines/draci/walking.h5
4 files changed, 29 insertions, 5 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 3a335f249a..b98593c8a4 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -891,9 +891,6 @@ void Game::putItem(GameItem *item, int position) {
void Game::inventoryInit() {
// Pause all "background" animations
_vm->_anims->pauseAnimations();
- if (_walkingState.isActive()) {
- walkHero(_hero.x, _hero.y, kDirectionLast);
- }
// Draw the inventory and the current items
inventoryDraw();
@@ -904,6 +901,13 @@ void Game::inventoryInit() {
// Set the appropriate loop status
setLoopStatus(kStatusInventory);
+ if (_walkingState.isActive()) {
+ _walkingState.stopWalking();
+ walkHero(_hero.x, _hero.y, kDirectionLast);
+ } else {
+ _lastTarget = _hero;
+ }
+
// Don't return from the inventory mode immediately if the mouse is out.
_mouseChangeTick = kMouseDoNotSwitch;
}
@@ -922,6 +926,10 @@ void Game::inventoryDone() {
}
}
+ // Start moving to last target
+ walkHero(_lastTarget.x, _lastTarget.y, kDirectionLast);
+ _walkingState.callbackLast();
+
// Reset item under cursor
_itemUnderCursor = NULL;
@@ -1208,6 +1216,12 @@ void Game::walkHero(int x, int y, SightDirection dir) {
debug(1, "Unreachable point [%d,%d]", target.x, target.y);
return;
}
+
+ // Save point of player's last target.
+ if(_loopStatus != kStatusInventory) {
+ _lastTarget = target;
+ }
+
_walkingMap.obliquePath(shortestPath, &obliquePath);
debugC(2, kDraciWalkingDebugLevel, "Walking path lengths: shortest=%d oblique=%d", shortestPath.size(), obliquePath.size());
if (_vm->_showWalkingMap) {
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 638c979d61..53a472a552 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -356,6 +356,7 @@ private:
Common::Point _hero;
Common::Point _heroLoading;
+ Common::Point _lastTarget;
int *_variables;
Person *_persons;
diff --git a/engines/draci/walking.cpp b/engines/draci/walking.cpp
index 1467ecee35..1670c9a029 100644
--- a/engines/draci/walking.cpp
+++ b/engines/draci/walking.cpp
@@ -439,8 +439,8 @@ void WalkingState::startWalking(const Common::Point &p1, const Common::Point &p2
}
void WalkingState::setCallback(const GPL2Program *program, uint16 offset) {
- _callback = program;
- _callbackOffset = offset;
+ _callback = _callbackLast = program;
+ _callbackOffset = _callbackOffsetLast = offset;
}
void WalkingState::callback() {
@@ -454,6 +454,10 @@ void WalkingState::callback() {
_vm->_script->runWrapper(originalCallback, _callbackOffset, true, false);
}
+void WalkingState::callbackLast() {
+ setCallback(_callbackLast, _callbackOffsetLast);
+}
+
bool WalkingState::continueWalkingOrClearPath() {
const bool stillWalking = continueWalking();
if (!stillWalking) {
diff --git a/engines/draci/walking.h b/engines/draci/walking.h
index ee2b48d083..fcdef3830e 100644
--- a/engines/draci/walking.h
+++ b/engines/draci/walking.h
@@ -110,6 +110,8 @@ public:
_lastAnimPhase = 0;
_turningFinished = 0;
_callbackOffset = 0;
+ _callbackOffsetLast = 0;
+ _callbackLast = 0;
stopWalking();
}
@@ -124,6 +126,7 @@ public:
void setCallback(const GPL2Program *program, uint16 offset);
void callback();
+ void callbackLast();
bool isActive() const { return _path.size() > 0; }
@@ -157,7 +160,9 @@ private:
bool _turningFinished;
const GPL2Program *_callback;
+ const GPL2Program *_callbackLast;
uint16 _callbackOffset;
+ uint16 _callbackOffsetLast;
// Initiates turning of the dragon into the direction for the next
// segment / after walking. Returns false when there is nothing left