diff options
author | Paul Gilbert | 2014-11-28 11:40:33 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-12-12 22:50:15 -0500 |
commit | bfbce8c6a6ac00423b47f3c3ce0f3b9a32e497ae (patch) | |
tree | f977aab19921337bc34040d7326bafc4bd35877d /engines/access/amazon | |
parent | 62a7619017c676c229ba72b295a4ceae19d3f0c7 (diff) | |
download | scummvm-rg350-bfbce8c6a6ac00423b47f3c3ce0f3b9a32e497ae.tar.gz scummvm-rg350-bfbce8c6a6ac00423b47f3c3ce0f3b9a32e497ae.tar.bz2 scummvm-rg350-bfbce8c6a6ac00423b47f3c3ce0f3b9a32e497ae.zip |
ACCESS: Cleanup of updateObstacles
Diffstat (limited to 'engines/access/amazon')
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 2 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.h | 2 | ||||
-rw-r--r-- | engines/access/amazon/amazon_scripts.cpp | 65 |
3 files changed, 32 insertions, 37 deletions
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index f4cf83e150..4237982b4d 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -44,7 +44,7 @@ AccessEngine(syst, gameDesc), _canoeLane = 0; _canoeYPos = 0; _hitCount = 0; - _saveRiver = 0; + _saveRiver = false; _hitSafe = 0; _oldTitleChapter = _chapter = 0; _updateChapter = -1; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 435e1722b2..4c4b304514 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -150,7 +150,7 @@ public: int _canoeLane; int _canoeYPos; int _hitCount; - int _saveRiver; + bool _saveRiver; int _hitSafe; int _chapter; int _riverIndex; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index cde1ff8324..7cae5fd0ef 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1408,12 +1408,14 @@ void AmazonScripts::initRiver() { _vm->_destIn = &_vm->_buffer2; _vm->_room->roomMenu(); - if (_game->_saveRiver == 1) { + if (_game->_saveRiver) { + // Restoring a savegame, so set properties from saved fields _vm->_screen->_scrollRow = _vm->_rScrollRow; _vm->_screen->_scrollCol = _vm->_rScrollCol; _vm->_screen->_scrollX = _vm->_rScrollX; _vm->_screen->_scrollY = _vm->_rScrollY; } else { + // Set initial scene state _vm->_screen->_scrollRow = 0; _vm->_screen->_scrollCol = 140; _vm->_screen->_scrollX = 0; @@ -1423,11 +1425,14 @@ void AmazonScripts::initRiver() { _vm->_room->buildScreen(); _vm->copyBF2Vid(); _vm->_screen->forceFadeIn(); - if (_game->_saveRiver == 1) { + + if (_game->_saveRiver) { + // Restore draw rects from savegame _vm->_oldRects.resize(_vm->_rOldRectCount); _vm->_newRects.resize(_vm->_rNewRectCount); // KEYFLG = _vm->_rKeyFlag } else { + // Reset draw rects _vm->_oldRects.clear(); _vm->_newRects.clear(); // KEYFLG = 0 @@ -1441,7 +1446,7 @@ void AmazonScripts::initRiver() { _game->_canoeFrame = 0; _game->_mapPtr = (const byte *)MAPTBL[_game->_riverFlag] + 1; - if (_game->_saveRiver == 1) { + if (_game->_saveRiver) { _game->_mapPtr--; _game->_mapPtr += _game->_mapOffset; } else { @@ -1468,7 +1473,7 @@ void AmazonScripts::initRiver() { ++_game->_timers[12]._flag; _game->_maxHits = 2 - _game->_riverFlag; - _game->_saveRiver = 0; + _game->_saveRiver = false; } void AmazonScripts::resetPositions() { @@ -1579,7 +1584,7 @@ void AmazonScripts::moveCanoe() { printString(BAR_MESSAGE); } else { // Clicked on the Disc icon - _game->_saveRiver = 1; + _game->_saveRiver = true; _game->_rScrollRow = screen._scrollRow; _game->_rScrollCol = screen._scrollCol; _game->_rScrollX = screen._scrollX; @@ -1590,7 +1595,7 @@ void AmazonScripts::moveCanoe() { _vm->_room->handleCommand(9); if (_vm->_room->_function != FN_CLEAR1) { - _game->_saveRiver = 0; + _game->_saveRiver = false; _vm->_room->buildScreen(); _vm->copyBF2Vid(); } @@ -1626,42 +1631,32 @@ void AmazonScripts::moveCanoe2() { } void AmazonScripts::updateObstacles() { - RiverStruct *cur = _game->_topList; - while (true) { - int val = cur[0]._field1 + cur[0]._field3 - 1; - if (val < _screenVertX) { - cur = _game->_topList; - cur--; - _game->_botList = cur; - return; - } - - if (cur[0]._field3 < _screenVertX + 319) { - _game->_topList = _game->_botList = cur; + RiverStruct *cur; + for (cur = _game->_topList; cur < RIVEROBJECTTBL[_game->_riverIndex + 1]; ++cur) { + int val = cur->_field1 + cur->_field3 - 1; + if (val < _screenVertX) break; - } - if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) { - cur = _game->_topList; - cur--; + if (cur->_field3 < (_game->_screenVirtX + 319)) { + _game->_topList = cur; _game->_botList = cur; - return; - } - } - while (true) { - if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) - return; - ++cur; - int val = cur[0]._field1 + cur[0]._field3 - 1; - if (val < _screenVertX) - return; + while (cur < RIVEROBJECTTBL[_game->_riverIndex + 1]) { + ++cur; + val = cur->_field1 + cur->_field3 - 1; + if (val < _screenVertX || (cur->_field3 >= (_game->_screenVirtX + 319))) + break; - if (cur[0]._field3 >= _screenVertX + 319) - return; + _game->_botList = cur; + } - _game->_botList = cur; + return; + } } + + cur = _game->_topList; + cur--; + _game->_botList = cur; } void AmazonScripts::riverSetPhysX() { |