From b1b98417ce2974cd22b4b7a0a9e097937c583b64 Mon Sep 17 00:00:00 2001 From: Wanne Date: Mon, 9 Jul 2012 08:11:27 +0000 Subject: [PATCH] - convert outofbounds check to inline macro. (This gets called a lot in render map. The Visual Studio profiler highlighted this one though probably not a real optimization.) (by tazpn) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5367 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/Isometric Utils.cpp | 14 -------------- TileEngine/Isometric Utils.h | 7 ++++++- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/TileEngine/Isometric Utils.cpp b/TileEngine/Isometric Utils.cpp index c47835e54..6c3e06221 100644 --- a/TileEngine/Isometric Utils.cpp +++ b/TileEngine/Isometric Utils.cpp @@ -874,20 +874,6 @@ INT32 OutOfBounds(INT32 sGridNo, INT32 sProposedGridNo) return(FALSE); } -//Lalien: This function should be used to check if the tile is not inside map array, -// it will return FALSE if the tile index is NOWHERE (-1) too. -// If the tile index has some special meaning ("-1" = does not exist) the check for NOWHERE should be used -BOOLEAN TileIsOutOfBounds(INT32 sGridNo) -{ - if( (sGridNo < 0) || (sGridNo >= MAX_MAP_POS) ) - { - return TRUE; - } - - return FALSE; -} - - INT32 NewGridNo(INT32 sGridNo, INT16 sDirInc) { INT32 sProposedGridNo = sGridNo + sDirInc; diff --git a/TileEngine/Isometric Utils.h b/TileEngine/Isometric Utils.h index bae7aa989..26467607f 100644 --- a/TileEngine/Isometric Utils.h +++ b/TileEngine/Isometric Utils.h @@ -49,8 +49,13 @@ void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); INT32 NewGridNo(INT32 sGridNo, INT16 sDirInc); INT16 DirectionInc(UINT8 ubDirection); INT32 OutOfBounds(INT32 sGridNo, INT32 sProposedGridNo); -BOOLEAN TileIsOutOfBounds(INT32 sGridNo); +//Lalien: This function should be used to check if the tile is not inside map array, +// it will return FALSE if the tile index is NOWHERE (-1) too. +// If the tile index has some special meaning ("-1" = does not exist) the check for NOWHERE should be used +// +// tazpn: inline this routine due to high call count +#define TileIsOutOfBounds(sGridNo) (( (sGridNo < 0) || (sGridNo >= MAX_MAP_POS) ) ? TRUE : FALSE) // Functions BOOLEAN GetMouseCell( INT32 *piMouseMapPos );