//EntryPoints can't be placed on the top two gridnos in a map. So all we do in this case //is return the closest gridno. Returns TRUE if the mapindex changes. BOOLEAN ValidateEntryPointGridNo( INT32 *sGridNo ) { INT16 sXMapPos, sYMapPos; INT16 sWorldX, sWorldY; INT32 iNewMapX, iNewMapY; INT32 sTopLimit, sBottomLimit; if ( TileIsOutOfBounds( *sGridNo ) ) return FALSE; //entry point is non-existant ConvertGridNoToXY( *sGridNo, &sXMapPos, &sYMapPos ); sTopLimit = 80; sBottomLimit = gsBRY - gsTLY - 40; //Get screen coordinates for current gridno GetWorldXYAbsoluteScreenXY( sXMapPos, sYMapPos, &sWorldX, &sWorldY); if( sWorldY < sTopLimit ) { GetFromAbsoluteScreenXYWorldXY( &iNewMapX, &iNewMapY, sWorldX, sTopLimit ); } else if( sWorldY > sBottomLimit ) { GetFromAbsoluteScreenXYWorldXY( &iNewMapX, &iNewMapY, sWorldX, sBottomLimit ); } else { return FALSE; //already valid } *sGridNo = MAPROWCOLTOPOS( iNewMapY/10, iNewMapX/10 ); return TRUE; //modified }
// ubRadius in times of y or x cell sizes BOOLEAN GridNoOnScreenAndAround( const INT32& sGridNo, const UINT8& ubRadius ) { INT16 sNewCenterWorldX, sNewCenterWorldY; INT16 sWorldX; INT16 sWorldY; UINT16 usXDiff = ubRadius*CELL_X_SIZE; UINT16 usYDiff = ubRadius*CELL_Y_SIZE; ConvertGridNoToXY( sGridNo, &sNewCenterWorldX, &sNewCenterWorldY ); // Get screen coordinates for current position of soldier GetWorldXYAbsoluteScreenXY( (INT16)(sNewCenterWorldX), (INT16)(sNewCenterWorldY), &sWorldX, &sWorldY); if ( sWorldX >= ( gsTopLeftWorldX - usXDiff ) && sWorldX <= ( gsBottomRightWorldX + usXDiff ) && sWorldY >= ( gsTopLeftWorldY - usYDiff + gsVIEWPORT_WINDOW_START_Y ) && sWorldY <= ( gsBottomRightWorldY + usYDiff ) ) { return( TRUE ); } return( FALSE ); }