aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2014-04-29 00:20:04 +0300
committerEugene Sandulenko2014-04-29 00:20:04 +0300
commit6c2a7f0ca3df2dcce4d1050a3d93c883a8faad52 (patch)
tree332592f61263182604666a4a1d07627f38e0f078
parentf74c46e93efa23db094599e9307caf80ebf5bcda (diff)
parentad842e61da920952e1583c7d88e252fac43e4f6c (diff)
downloadscummvm-rg350-6c2a7f0ca3df2dcce4d1050a3d93c883a8faad52.tar.gz
scummvm-rg350-6c2a7f0ca3df2dcce4d1050a3d93c883a8faad52.tar.bz2
scummvm-rg350-6c2a7f0ca3df2dcce4d1050a3d93c883a8faad52.zip
Merge pull request #443 from lukaslw/first_branch
DRACI: Opening inventory during movements and actions.
-rw-r--r--engines/draci/game.cpp20
-rw-r--r--engines/draci/game.h1
-rw-r--r--engines/draci/walking.cpp10
-rw-r--r--engines/draci/walking.h5
4 files changed, 31 insertions, 5 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 3a335f249a..4893b0fe34 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..6914898ec1 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() {
@@ -452,6 +452,12 @@ void WalkingState::callback() {
const GPL2Program &originalCallback = *_callback;
_callback = NULL;
_vm->_script->runWrapper(originalCallback, _callbackOffset, true, false);
+ _callbackLast = NULL;
+ _callbackOffset = NULL;
+}
+
+void WalkingState::callbackLast() {
+ setCallback(_callbackLast, _callbackOffsetLast);
}
bool WalkingState::continueWalkingOrClearPath() {
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