From 17fee15f2b890b833f02426fac6395c8d4b6885c Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Fri, 24 Jan 2020 20:35:14 +0000 Subject: [PATCH] GetIdOfMineForSector: use correct min/max values for bSectorZ. Minor code improvements. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8739 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/Strategic Mines.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Strategic/Strategic Mines.cpp b/Strategic/Strategic Mines.cpp index f4096cb1..03d7e8f2 100644 --- a/Strategic/Strategic Mines.cpp +++ b/Strategic/Strategic Mines.cpp @@ -529,7 +529,7 @@ INT32 GetAvailableWorkForceForMineForPlayer( INT8 bMineIndex ) */ // Flugente: if strategic disease is active, disease can affect out workforce, so the calculation gets slightly more complicated - iWorkForceSize *= GetWorkforceEffectivenessWithDisease( bTownId, OUR_TEAM ); + iWorkForceSize = (INT32)(iWorkForceSize * GetWorkforceEffectivenessWithDisease(bTownId, OUR_TEAM)); // now adjust for town size.. the number of sectors you control iWorkForceSize *= GetTownSectorsUnderControl( bTownId ); @@ -816,7 +816,7 @@ INT8 GetMineIndexForSector( INT16 sX, INT16 sY ) void GetMineSector( UINT8 ubMineIndex, INT16 * psX, INT16 * psY ) { - Assert( ( ubMineIndex >= 0 ) && ( ubMineIndex < MAX_NUMBER_OF_MINES ) ); + Assert(ubMineIndex < MAX_NUMBER_OF_MINES); //*psX = gMineLocation[ ubMineIndex ].sSectorX; //*psY = gMineLocation[ ubMineIndex ].sSectorY; @@ -1303,22 +1303,21 @@ BOOLEAN HasHisMineBeenProducingForPlayerForSomeTime( UINT8 ubMinerProfileId ) return( FALSE ); } -// gte the id of the mine for this sector x,y,z...-1 is invalid +// get the id of the mine for this sector x,y,z...-1 is invalid INT8 GetIdOfMineForSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) { INT8 bMineIndex = -1; - INT16 sSectorValue; - + //INT16 sSectorValue; // are we even on the right level? - if( ( bSectorZ < 0 ) && ( bSectorZ > 2 ) ) + if (bSectorZ < MINIMUM_VALID_Z_COORDINATE || bSectorZ > MAXIMUM_VALID_Z_COORDINATE) { // nope return( -1 ); } // now get the sectorvalue - sSectorValue = SECTOR( sSectorX, sSectorY ); + //sSectorValue = SECTOR( sSectorX, sSectorY ); // support surface if( bSectorZ == 0 ) @@ -1423,8 +1422,7 @@ BOOLEAN AreThereMinersInsideThisMine( UINT8 ubMineIndex ) { MINE_STATUS_TYPE *pMineStatus; - - Assert( ( ubMineIndex >= 0 ) && ( ubMineIndex < MAX_NUMBER_OF_MINES ) ); + Assert(ubMineIndex < MAX_NUMBER_OF_MINES); pMineStatus = &(gMineStatus[ ubMineIndex ]);