From 6559b7181900e8b174d92ff9b32759495c566bfb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 6 Jul 2019 16:40:19 +0200 Subject: HDB: Fix removeBGTileAnimation() and removeFGTileAnimation() implementations --- engines/hdb/map.cpp | 82 ++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 48 deletions(-) (limited to 'engines/hdb') diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp index be1cfe6632..b6e6774665 100644 --- a/engines/hdb/map.cpp +++ b/engines/hdb/map.cpp @@ -984,61 +984,47 @@ void Map::addFGTileAnimation(int x, int y) { } void Map::removeBGTileAnimation(int x, int y) { - int i = y * _width + x; + uint idx = y * _width + x; - Tile *tile = g_hdb->_gfx->getTile(_background[i]); - if (!tile) - return; - uint32 flags = tile->_flags; + for (uint i = 0; i < _listBGAnimFast.size(); i++) + if (_listBGAnimFast[i] == idx) { + _listBGAnimFast.remove_at(i); + return; + } - if (flags & kFlagAnimFast) { - for (Common::Array::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++) - if ((uint)i == (*it)) { - _listBGAnimFast.erase(it); - break; - } - } else if (flags & kFlagAnimSlow) { - for (Common::Array::iterator it = _listBGAnimSlow.begin(); it != _listBGAnimSlow.end(); it++) - if ((uint)i == (*it)) { - _listBGAnimSlow.erase(it); - break; - } - } else if (flags & kFlagAnimMedium) { - for (Common::Array::iterator it = _listBGAnimMedium.begin(); it != _listBGAnimMedium.end(); it++) - if ((uint)i == (*it)) { - _listBGAnimMedium.erase(it); - break; - } - } + for (uint i = 0; i < _listBGAnimSlow.size(); i++) + if (_listBGAnimSlow[i] == idx) { + _listBGAnimSlow.remove_at(i); + return; + } + + for (uint i = 0; i < _listBGAnimMedium.size(); i++) + if (_listBGAnimMedium[i] == idx) { + _listBGAnimMedium.remove_at(i); + return; + } } void Map::removeFGTileAnimation(int x, int y) { - int i = y * _width + x; + uint idx = y * _width + x; - Tile *tile = g_hdb->_gfx->getTile(_foreground[i]); - if (!tile) - return; - uint32 flags = tile->_flags; + for (uint i = 0; i < _listFGAnimFast.size(); i++) + if (_listFGAnimFast[i] == idx) { + _listFGAnimFast.remove_at(i); + return; + } - if (flags & kFlagAnimFast) { - for (Common::Array::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++) - if ((uint)i == (*it)) { - _listFGAnimFast.erase(it); - break; - } - } else if (flags & kFlagAnimSlow) { - for (Common::Array::iterator it = _listFGAnimSlow.begin(); it != _listFGAnimSlow.end(); it++) - if ((uint)i == (*it)) { - _listFGAnimSlow.erase(it); - break; - } - } else if (flags & kFlagAnimMedium) { - for (Common::Array::iterator it = _listFGAnimMedium.begin(); it != _listFGAnimMedium.end(); it++) - if ((uint)i == (*it)) { - _listFGAnimMedium.erase(it); - break; - } - } + for (uint i = 0; i < _listFGAnimSlow.size(); i++) + if (_listFGAnimSlow[i] == idx) { + _listFGAnimSlow.remove_at(i); + return; + } + + for (uint i = 0; i < _listFGAnimMedium.size(); i++) + if (_listFGAnimMedium[i] == idx) { + _listFGAnimMedium.remove_at(i); + return; + } } void Map::getMapXY(int *x, int *y) { -- cgit v1.2.3