From 60b4c33a9c5643322f093b62e2df8985705bbbb6 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Fri, 21 Jun 2019 08:34:36 +0530 Subject: HDB: Add NULL check to BG/FG tile animation --- engines/hdb/map-loader.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp index 249c52a9f4..dfbd1a82ce 100644 --- a/engines/hdb/map-loader.cpp +++ b/engines/hdb/map-loader.cpp @@ -717,7 +717,10 @@ void Map::addBGTileAnimation(int x, int y) { int i = y * _width + x; - uint32 flags = g_hdb->_drawMan->getTile(_background[i])->_flags; + Tile *tile = g_hdb->_drawMan->getTile(_background[i]); + if (!tile) + return; + uint32 flags = tile->_flags; // BACKGROUND if (flags & kFlagAnimFast) { @@ -733,7 +736,10 @@ void Map::addFGTileAnimation(int x, int y) { int i = y * _width + x; - uint32 flags = g_hdb->_drawMan->getTile(_foreground[i])->_flags; + Tile *tile = g_hdb->_drawMan->getTile(_foreground[i]); + if (!tile) + return; + uint32 flags = tile->_flags; // FOREGROUND if (flags & kFlagAnimFast) { @@ -748,7 +754,10 @@ void Map::addFGTileAnimation(int x, int y) { void Map::removeBGTileAnimation(int x, int y) { int i = y * _width + x; - uint32 flags = g_hdb->_drawMan->getTile(_background[i])->_flags; + Tile *tile = g_hdb->_drawMan->getTile(_background[i]); + if (!tile) + return; + uint32 flags = tile->_flags; if (flags & kFlagAnimFast) { for(Common::Array::iterator it = _listBGAnimFast.begin(); it!=_listBGAnimFast.end(); it++) @@ -774,7 +783,10 @@ void Map::removeBGTileAnimation(int x, int y) { void Map::removeFGTileAnimation(int x, int y) { int i = y * _width + x; - uint32 flags = g_hdb->_drawMan->getTile(_foreground[i])->_flags; + Tile *tile = g_hdb->_drawMan->getTile(_foreground[i]); + if (!tile) + return; + uint32 flags = tile->_flags; if (flags & kFlagAnimFast) { for(Common::Array::iterator it = _listFGAnimFast.begin(); it!=_listFGAnimFast.end(); it++) -- cgit v1.2.3