aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/nebular/game_nebular.cpp76
-rw-r--r--engines/mads/phantom/game_phantom.cpp2
-rw-r--r--engines/mads/player.cpp82
-rw-r--r--engines/mads/player.h24
4 files changed, 114 insertions, 70 deletions
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index c4b7f57281..9c0acf1a47 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -827,51 +827,49 @@ void GameNebular::step() {
if (_player._visible && _player._stepEnabled && !_player._moving &&
(_player._facing == _player._turnToFacing)) {
if (_scene._frameStartTime >= (uint32)_globals[kWalkerTiming]) {
- if (!_player._stopWalkerIndex) {
- int randomVal = _vm->getRandomNumber(29999);
- if (_globals[kSexOfRex] == REX_MALE) {
- switch (_player._facing) {
- case FACING_SOUTHWEST:
- case FACING_SOUTHEAST:
- case FACING_NORTHWEST:
- case FACING_NORTHEAST:
- if (randomVal < 200) {
- _player.addWalker(-1, 0);
+ int randomVal = _vm->getRandomNumber(29999);
+ if (_globals[kSexOfRex] == REX_MALE) {
+ switch (_player._facing) {
+ case FACING_SOUTHWEST:
+ case FACING_SOUTHEAST:
+ case FACING_NORTHWEST:
+ case FACING_NORTHEAST:
+ if (randomVal < 200) {
+ _player.addWalker(-1, 0);
+ _player.addWalker(1, 0);
+ }
+ break;
+
+ case FACING_WEST:
+ case FACING_EAST:
+ if (randomVal < 500) {
+ for (int count = 0; count < 10; ++count) {
_player.addWalker(1, 0);
}
- break;
-
- case FACING_WEST:
- case FACING_EAST:
- if (randomVal < 500) {
- for (int count = 0; count < 10; ++count) {
- _player.addWalker(1, 0);
- }
+ }
+ break;
+
+ case FACING_SOUTH:
+ if (randomVal < 500) {
+ for (int count = 0; count < 10; ++count) {
+ _player.addWalker((randomVal < 250) ? 1 : 2, 0);
}
- break;
-
- case FACING_SOUTH:
- if (randomVal < 500) {
- for (int count = 0; count < 10; ++count) {
- _player.addWalker((randomVal < 250) ? 1 : 2, 0);
- }
- } else if (randomVal < 750) {
- for (int count = 0; count < 5; ++count) {
- _player.addWalker(1, 0);
- }
-
- _player.addWalker(0, 0);
- _player.addWalker(0, 0);
-
- for (int count = 0; count < 5; ++count) {
- _player.addWalker(2, 0);
- }
+ } else if (randomVal < 750) {
+ for (int count = 0; count < 5; ++count) {
+ _player.addWalker(1, 0);
}
- break;
- default:
- break;
+ _player.addWalker(0, 0);
+ _player.addWalker(0, 0);
+
+ for (int count = 0; count < 5; ++count) {
+ _player.addWalker(2, 0);
+ }
}
+ break;
+
+ default:
+ break;
}
}
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
index 27849cce1e..3ec3052ad5 100644
--- a/engines/mads/phantom/game_phantom.cpp
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -747,7 +747,7 @@ void GamePhantom::step() {
&& (_player._stepEnabled || (_vm->_gameConv->_running >= 0))
&& !_player._moving && (_player._facing == _player._turnToFacing)
&& (_scene._frameStartTime >= (uint32)_globals[kWalkerTiming])) {
- if (!_player._stopWalkerIndex)
+ if (_player._stopWalkers.empty())
stopWalker();
_globals[kWalkerTiming] += 6;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 09a961825e..7d9a4fd8df 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -32,6 +32,34 @@ const int Player::_directionListIndexes[32] = {
0, 7, 4, 3, 6, 0, 2, 5, 0, 1, 9, 4, 1, 2, 7, 9, 3, 8, 9, 6, 7, 2, 3, 6, 1, 7, 9, 4, 7, 8, 0, 0
};
+/*------------------------------------------------------------------------*/
+
+void StopWalkerEntry::synchronize(Common::Serializer &s) {
+ s.syncAsSint16LE(_stack);
+ s.syncAsSint16LE(_trigger);
+}
+
+/*------------------------------------------------------------------------*/
+
+void StopWalkers::synchronize(Common::Serializer &s) {
+ StopWalkerEntry rec;
+ int count = size();
+ s.syncAsUint16LE(count);
+
+ if (s.isLoading()) {
+ clear();
+ for (int idx = 0; idx < count; ++idx) {
+ rec.synchronize(s);
+ push(rec);
+ }
+ } else {
+ for (int idx = 0; idx < count; ++idx)
+ (*this)[idx].synchronize(s);
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
Player::Player(MADSEngine *vm)
: _vm(vm) {
_action = nullptr;
@@ -69,7 +97,6 @@ Player::Player(MADSEngine *vm)
_upcomingTrigger = 0;
_trigger = 0;
_frameListIndex = 0;
- _stopWalkerIndex = 0;
_totalDistance = 0;
_distAccum = 0;
_pixelAccum = 0;
@@ -84,8 +111,6 @@ Player::Player(MADSEngine *vm)
_enableAtTarget = false;
_walkTrigger = 0;
- Common::fill(&_stopWalkerList[0], &_stopWalkerList[12], 0);
- Common::fill(&_stopWalkerTrigger[0], &_stopWalkerTrigger[12], 0);
Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
}
@@ -256,15 +281,16 @@ void Player::updateFrame() {
if (!spriteSet._charInfo->_numEntries) {
_frameNumber = 1;
} else {
- _frameListIndex = _stopWalkerList[_stopWalkerIndex];
+ _frameListIndex = _stopWalkers.empty() ? 0 : _stopWalkers.top()._stack;
if (!_visible) {
_upcomingTrigger = 0;
} else {
- _upcomingTrigger = _stopWalkerTrigger[_stopWalkerIndex];
-
- if (_stopWalkerIndex > 0)
- --_stopWalkerIndex;
+ if (_stopWalkers.empty()) {
+ _upcomingTrigger = 0;
+ } else {
+ _upcomingTrigger = _stopWalkers.pop()._trigger;
+ }
}
// Set the player frame number
@@ -284,11 +310,20 @@ void Player::updateFrame() {
}
void Player::activateTrigger() {
- // TODO: Finish this!
- // TODO: Also sync _walkTrigger, if necessary
+ Game &game = *_vm->_game;
+ MADSAction &action = game._scene._action;
+ _commandsAllowed |= _enableAtTarget;
+ _enableAtTarget = false;
+
if (_walkTrigger) {
- _vm->_game->_trigger = _walkTrigger;
+ game._trigger = _walkTrigger;
+ game._triggerMode = SEQUENCE_TRIGGER_DAEMON;
+
+ if (game._triggerMode != SEQUENCE_TRIGGER_DAEMON) {
+ action._activeAction = _walkTriggerAction;
+ }
+
_walkTrigger = 0;
}
}
@@ -376,9 +411,7 @@ void Player::update() {
}
void Player::clearStopList() {
- _stopWalkerList[0] = 0;
- _stopWalkerTrigger[0] = 0;
- _stopWalkerIndex = 0;
+ _stopWalkers.clear();
_upcomingTrigger = 0;
_trigger = 0;
}
@@ -701,14 +734,10 @@ void Player::addWalker(int walker, int trigger) {
SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
assert(spriteSet._charInfo);
- if (walker < spriteSet._charInfo->_numEntries && _stopWalkerIndex < 11) {
- ++_stopWalkerIndex;
- _stopWalkerList[_stopWalkerIndex] = walker;
- _stopWalkerTrigger[_stopWalkerIndex] = trigger;
- }
+ if (walker < spriteSet._charInfo->_numEntries)
+ _stopWalkers.push(StopWalkerEntry(walker, trigger));
}
-
/**
* Releases any sprites used by the player
*/
@@ -770,13 +799,10 @@ void Player::synchronize(Common::Serializer &s) {
s.syncAsSint16LE(_currentDepth);
s.syncAsSint16LE(_currentScale);
s.syncAsSint16LE(_frameListIndex);
+ _stopWalkers.synchronize(s);
+ _walkTriggerAction.synchronize(s);
+ s.syncAsUint16LE(_walkTriggerDest);
- for (int i = 0; i < 12; ++i) {
- s.syncAsSint16LE(_stopWalkerList[i]);
- s.syncAsSint16LE(_stopWalkerTrigger[i]);
- }
-
- s.syncAsSint16LE(_stopWalkerIndex);
s.syncAsSint16LE(_upcomingTrigger);
s.syncAsSint16LE(_trigger);
s.syncAsSint16LE(_scalingVelocity);
@@ -826,8 +852,10 @@ void Player::firstWalk(Common::Point fromPos, Facing fromFacing, Common::Point d
}
void Player::setWalkTrigger(int val) {
+ Scene &scene = _vm->_game->_scene;
_walkTrigger = val;
- warning("TODO: Player::setWalkTrigger");
+ _walkTriggerDest = _vm->_game->_triggerSetupMode;
+ _walkTriggerAction = scene._action._activeAction;
}
void Player::resetFacing(Facing facing) {
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 55000047fb..04b86b76b4 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -45,6 +45,23 @@ enum Facing {
FACING_NONE = 5, FACING_DUMMY = 0
};
+struct StopWalkerEntry {
+ int _stack;
+ int _trigger;
+
+ StopWalkerEntry() : _stack(0), _trigger(0) {}
+ StopWalkerEntry(int stack, int trigger) : _stack(stack), _trigger(trigger) {}
+
+ void synchronize(Common::Serializer &s);
+};
+
+class StopWalkers : public Common::FixedStack<StopWalkerEntry, 12> {
+public:
+ StopWalkers() : Common::FixedStack<StopWalkerEntry, 12>() {}
+
+ void synchronize(Common::Serializer &s);
+};
+
class Player {
private:
static const int _directionListIndexes[32];
@@ -58,8 +75,6 @@ private:
int _distAccum;
int _pixelAccum;
int _deltaDistance;
- int _stopWalkerList[12];
- int _stopWalkerTrigger[12];
int _totalDistance;
void clearStopList();
@@ -138,12 +153,15 @@ public:
bool _readyToWalk;
bool _commandsAllowed;
bool _enableAtTarget;
- int _stopWalkerIndex;
int _centerOfGravity;
int _currentDepth;
int _currentScale;
Common::String _spritesPrefix;
+
int _walkTrigger;
+ TriggerMode _walkTriggerDest;
+ ActionDetails _walkTriggerAction;
+ StopWalkers _stopWalkers;
public:
Player(MADSEngine *vm);