aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/map.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index e309b57333..9f62fb8bbb 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -868,10 +868,14 @@ void Map::draw() {
int maxTileX = (_mapTileXOff >= -8) ? g_hdb->_map->_screenXTiles - 1 : g_hdb->_map->_screenXTiles;
int maxTileY = (!_mapTileYOff) ? g_hdb->_map->_screenYTiles - 1 : g_hdb->_map->_screenYTiles;
- if (matrixY + (maxTileY - 1)*_width > _height * _width) {
+ if (matrixY + (maxTileY - 1) * _width > _height * _width) {
return;
}
+ // Sometimes we're 1 beyond the map, so avoid it
+ if (_mapTileX + maxTileX - 1 >= _width)
+ maxTileX--;
+
_numForegrounds = _numGratings = 0;
for (int j = 0; j < maxTileY; j++) {
@@ -886,7 +890,11 @@ void Map::draw() {
// Draw if not a sky tile
if (!g_hdb->_gfx->isSky(tileIndex)) {
- g_hdb->_gfx->getTile(tileIndex)->draw(screenX, screenY);
+ Tile *tile = g_hdb->_gfx->getTile(tileIndex);
+ if (tile)
+ tile->draw(screenX, screenY);
+ else
+ warning("Cannot find tile with index %d at %d,%d", tileIndex, _mapTileX + i, _mapTileY + j);
}
// Draw Foreground Tile