diff options
author | Willem Jan Palenstijn | 2015-07-22 22:37:40 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-07-22 22:43:42 +0200 |
commit | 6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch) | |
tree | 503d50902bad2d800165593039d08d5ccf0c98ab /engines/mads/player.cpp | |
parent | 5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff) | |
parent | 4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff) | |
download | scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2 scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip |
Merge branch 'master' into mm
Conflicts:
engines/access/access.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/martian/martian_game.cpp
engines/access/player.cpp
engines/access/player.h
engines/access/resources.cpp
engines/access/screen.cpp
engines/access/screen.h
engines/access/sound.cpp
engines/access/sound.h
Diffstat (limited to 'engines/mads/player.cpp')
-rw-r--r-- | engines/mads/player.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp index bde313af8d..bb747f4b52 100644 --- a/engines/mads/player.cpp +++ b/engines/mads/player.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -235,12 +235,18 @@ void Player::selectSeries() { void Player::updateFrame() { // WORKAROUND: Prevent character info being referenced when not present - if ((_spritesStart + _spritesIdx) < 0 || !_spriteSetsPresent[_spritesStart + _spritesIdx]) + int idx = _spritesStart + _spritesIdx; + if (idx < 0 || (idx < PLAYER_SPRITES_FILE_COUNT && !_spriteSetsPresent[idx])) return; Scene &scene = _vm->_game->_scene; - SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx]; - assert(spriteSet._charInfo); + assert(scene._sprites[idx] != nullptr); + SpriteAsset &spriteSet = *scene._sprites[idx]; + + // WORKAROUND: Certain cutscenes set up player sprites that don't have any + // character info. In such cases, simply ignore player updates + if (!spriteSet._charInfo) + return; if (!spriteSet._charInfo->_numEntries) { _frameNumber = 1; @@ -509,12 +515,12 @@ void Player::idle() { return; } - if ((_spritesStart + _spritesIdx) < 0 || !_spriteSetsPresent[_spritesStart + _spritesIdx]) + int idx = _spritesStart + _spritesIdx; + if (idx < 0 || (idx < PLAYER_SPRITES_FILE_COUNT && !_spriteSetsPresent[idx])) return; - SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx]; - assert(spriteSet._charInfo); - if (spriteSet._charInfo->_numEntries == 0) + SpriteAsset &spriteSet = *scene._sprites[idx]; + if (spriteSet._charInfo == nullptr || spriteSet._charInfo->_numEntries == 0) // No entries, so exit immediately return; @@ -528,11 +534,11 @@ void Player::idle() { _frameNumber += direction; _forceRefresh = true; - if (spriteSet._charInfo->_stopFrames[frameIndex] < _frameNumber) { + if (_frameNumber > spriteSet._charInfo->_stopFrames[frameIndex]) { _trigger = _upcomingTrigger; updateFrame(); } - if (spriteSet._charInfo->_startFrames[frameIndex] < _frameNumber) { + if (_frameNumber < spriteSet._charInfo->_startFrames[frameIndex]) { _trigger = _upcomingTrigger; updateFrame(); } @@ -658,7 +664,7 @@ void Player::startMovement() { _deltaDistance = (majorChange == 0) ? 0 : _totalDistance / majorChange; if (_playerPos.x > _targetPos.x) - _pixelAccum = MAX(_posChange.x, _posChange.y); + _pixelAccum = MIN(_posChange.x, _posChange.y); else _pixelAccum = 0; @@ -703,7 +709,7 @@ void Player::releasePlayerSprites() { _spritesLoaded = false; _spritesChanged = true; - if (scene._sprites._assetCount > 0) { + if (scene._sprites.size() > 0) { warning("Player::releasePlayerSprites(): leftover sprites remain, clearing list"); scene._sprites.clear(); } @@ -779,14 +785,14 @@ void Player::removePlayerSprites() { int heroSpriteId = _spritesStart; for (int i = 0; i < 8; i++) { if (_spriteSetsPresent[i]) { - scene._sprites.remove(heroSpriteId++); + delete scene._sprites[heroSpriteId]; + scene._sprites[heroSpriteId] = nullptr; _spriteSetsPresent[i] = false; + ++heroSpriteId; } } - if (scene._activeAnimation != nullptr) - scene._activeAnimation->resetSpriteSetsCount(); - + scene._spriteSlots.clear(); scene._spriteSlots.fullRefresh(); _visible = false; } |