diff options
author | Strangerke | 2019-09-06 00:44:01 +0200 |
---|---|---|
committer | Strangerke | 2019-09-06 00:44:01 +0200 |
commit | 27e852e17a4fe2a3e7bb66f661e651be86c6cf3b (patch) | |
tree | 128c0d1d8a7080d630908bf3facdcb1883bc7ec8 | |
parent | 9ed4c340a230df61bb92891b00dc7bb3a9814d2b (diff) | |
download | scummvm-rg350-27e852e17a4fe2a3e7bb66f661e651be86c6cf3b.tar.gz scummvm-rg350-27e852e17a4fe2a3e7bb66f661e651be86c6cf3b.tar.bz2 scummvm-rg350-27e852e17a4fe2a3e7bb66f661e651be86c6cf3b.zip |
HDB: Simplify some code by using CLIP()
-rw-r--r-- | engines/hdb/map.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp index ad1e63aa5c..a0eedcb58c 100644 --- a/engines/hdb/map.cpp +++ b/engines/hdb/map.cpp @@ -1140,18 +1140,8 @@ void Map::getMapXY(int *x, int *y) { } void Map::setMapXY(int x, int y) { - if (x < 0) - x = 0; - else if (x > (_width * kTileWidth - g_hdb->_screenDrawWidth)) - x = _width * kTileWidth - g_hdb->_screenDrawWidth; - - if (y < 0) - y = 0; - else if (y > (_height * kTileHeight - g_hdb->_screenDrawHeight)) - y = _height * kTileHeight - g_hdb->_screenDrawHeight; - - _mapX = x; - _mapY = y; + _mapX = CLIP(x, 0, _width * kTileWidth - g_hdb->_screenDrawWidth); + _mapY = CLIP(y, 0, _height * kTileHeight - g_hdb->_screenDrawHeight); } // Sets _mapX and _mapY and tries to center the map around X, Y @@ -1196,16 +1186,9 @@ void Map::centerMapXY(int x, int y) { break; } } - - if (x < minx) - x = minx; - else if (x > maxx) - x = maxx; - - if (y < miny) - y = miny; - else if (y > maxy) - y = maxy; + + x = CLIP(x, minx, maxx); + y = CLIP(y, miny, maxy); x -= (g_hdb->_screenDrawWidth / 2); y -= (g_hdb->_screenDrawHeight / 2); |