From 5674bed27bb43f0313e4d0a67ad94d4e41e8719c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Nov 2014 07:28:35 +0100 Subject: ACCESS: Implement updateObstacles --- engines/access/amazon/amazon_scripts.cpp | 43 +++++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 2 +- 2 files changed, 40 insertions(+), 5 deletions(-) (limited to 'engines/access') diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 2c16938ea8..b6d4987caa 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1699,7 +1699,7 @@ void AmazonScripts::initRiver() { _game->_riverIndex = _game->_riverFlag; _game->_topList = RIVEROBJECTTBL[_game->_riverIndex]; - UPDATEOBSTACLES(); + updateObstacles(); riverSetPhysX(); _game->_canoeDir = 0; _game->_deathFlag = 0; @@ -1897,8 +1897,43 @@ void AmazonScripts::moveCanoe() { } } -void AmazonScripts::UPDATEOBSTACLES() { - warning("TODO: UPDATEOBSTACLES()"); +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; + break; + } + + if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) { + cur = _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; + + if (cur[0]._field3 >= _screenVertX + 319) + return; + + _game->_botList = cur; + } } void AmazonScripts::riverSetPhysX() { @@ -1992,7 +2027,7 @@ void AmazonScripts::RIVER() { return; } - UPDATEOBSTACLES(); + updateObstacles(); riverSetPhysX(); RIVERCOLLIDE(); if (_game->_hitSafe != 0) diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index ef7ead60c9..0f71e89e48 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -101,7 +101,7 @@ protected: bool riverJumpTest(); void riverSound(); void moveCanoe(); - void UPDATEOBSTACLES(); + void updateObstacles(); void riverSetPhysX(); void RIVERCOLLIDE(); void plotRiver(); -- cgit v1.2.3