From 595b520f4aaff697b62d049928763eafab29f3c0 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Tue, 25 Jun 2019 02:04:53 +0530 Subject: HDB: Add checkEntOnScreen() and checkXYOnScreen() --- engines/hdb/map-loader.cpp | 8 ++++++++ engines/hdb/map-loader.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp index c8a31f5364..04a5ee6c2f 100644 --- a/engines/hdb/map-loader.cpp +++ b/engines/hdb/map-loader.cpp @@ -942,6 +942,14 @@ void Map::centerMapXY(int x, int y) { setMapXY(x, y); } +bool Map::checkEntOnScreen(AIEntity *e) { + return ((e->x > _mapX - 32) && (e->x < _mapX + kScreenXTiles * kTileWidth) && (e->y > _mapY - 32) && (e->y < kScreenYTiles * kTileHeight)); +} + +bool Map::checkXYOnScreen(int x, int y) { + return ((x > _mapX - 32) && (x < _mapX + kScreenXTiles * kTileWidth) && (y > _mapY - 32) && (y < kScreenYTiles * kTileHeight)); +} + bool Map::checkOneTileExistInRange(int tileIndex, int count) { for (int i = 0; i < _width*_height; i++) { if (_background[i] >= tileIndex && _background[i] < tileIndex + count) diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h index 69c82a8ee5..f94c2a77a2 100644 --- a/engines/hdb/map-loader.h +++ b/engines/hdb/map-loader.h @@ -101,6 +101,8 @@ public: void getMapXY(int *x, int *y); void setMapXY(int x, int y); void centerMapXY(int x, int y); + bool checkEntOnScreen(AIEntity *); + bool checkXYOnScreen(int x, int y); // Check if one of the tiles in a range exists in the map on either layer bool checkOneTileExistInRange(int tileIndex, int count); -- cgit v1.2.3