From ebd1e97d376fe35fb36510af694935e87e333881 Mon Sep 17 00:00:00 2001 From: lalien Date: Thu, 20 Sep 2007 14:35:33 +0000 Subject: [PATCH] - removed variables that are not used - some fixes on soldier direction calculations git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1403 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- .../Map Screen Interface Map Inventory.cpp | 2 +- Strategic/Reinforcement.cpp | 2 +- Tactical/Handle Items.cpp | 4 ++-- Tactical/Handle UI.cpp | 6 ++--- Tactical/Overhead.cpp | 22 +++++++++---------- Tactical/PATHAI.cpp | 4 ++-- Tactical/Points.cpp | 8 +++---- Tactical/Soldier Control.cpp | 2 +- Tactical/fov.cpp | 5 ++++- TacticalAI/FindLocations.cpp | 7 +++--- TacticalAI/Movement.cpp | 6 ++--- 11 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index 5c4c87cb..9cba815d 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -1452,7 +1452,7 @@ void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot ) fMapInventoryItem = FALSE; if ( _KeyDown ( 89 )) //Lalien: sell all items of this type on Alt+Y { - for( UINT32 iNumber = 0; iNumber < iTotalNumberOfSlots ; ++iNumber) + for( INT32 iNumber = 0; iNumber < iTotalNumberOfSlots ; ++iNumber) { if ( pInventoryPoolList[ iNumber ].o.usItem == gItemPointer.usItem ) { diff --git a/Strategic/Reinforcement.cpp b/Strategic/Reinforcement.cpp index e9399a42..ff0821af 100644 --- a/Strategic/Reinforcement.cpp +++ b/Strategic/Reinforcement.cpp @@ -247,7 +247,7 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY ) UINT16 pusMoveDir[4][3]; UINT8 ubDirNumber = 0, ubIndex; GROUP *pGroup; - ENEMYGROUP *pEnemyGroup; + //ENEMYGROUP *pEnemyGroup; SECTORINFO *pThisSector, *pSector; if( !gGameExternalOptions.gfAllowReinforcements ) diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 5eb13b00..1290dee6 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -623,7 +623,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa //TRY PUNCHING if ( Item[ usHandItem ].usItemClass == IC_PUNCH ) { - INT16 sCnt; + //INT16 sCnt; INT16 sSpot; UINT8 ubGuyThere; INT16 sGotLocation = NOWHERE; @@ -631,7 +631,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bLevel, UINT16 usHa sAdjustedGridNo = NOWHERE; ubDirection = 0xff; - for ( sCnt = 0; sCnt < NUM_WORLD_DIRECTIONS; sCnt++ ) + for ( INT8 sCnt = 0; sCnt < NUM_WORLD_DIRECTIONS; sCnt++ ) { sSpot = NewGridNo( pSoldier->sGridNo, DirectionInc( sCnt ) ); diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index d524ef3b..f3e77f34 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -6319,8 +6319,8 @@ BOOLEAN ValidQuickExchangePosition( ) BOOLEAN IsValidJumpLocation( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN fCheckForPath ) { INT16 sFourGrids[4], sDistance=0, sSpot, sIntSpot; - INT16 sDirs[4] = { NORTH, EAST, SOUTH, WEST }; - INT32 cnt; + INT8 sDirs[4] = { NORTH, EAST, SOUTH, WEST }; + //INT32 cnt; UINT8 ubGuyThere; UINT8 ubMovementCost; INT32 iDoorGridNo; @@ -6333,7 +6333,7 @@ BOOLEAN IsValidJumpLocation( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN fChec } // Loop through positions... - for (cnt = 0; cnt < 4; cnt++) + for (INT8 cnt = 0; cnt < 4; cnt++) { // MOVE OUT TWO DIRECTIONS sIntSpot = NewGridNo( sGridNo, DirectionInc( sDirs[ cnt ] ) ); diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 051ba50a..ef30c798 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -4586,8 +4586,8 @@ INT16 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pubDirect // fDoor determines whether special door-handling code should be used (for interacting with doors) INT16 sFourGrids[4], sDistance=0; - INT16 sDirs[4] = { NORTH, EAST, SOUTH, WEST }; - INT32 cnt; + INT8 sDirs[4] = { NORTH, EAST, SOUTH, WEST }; + //INT32 cnt; INT16 sClosest=NOWHERE, sSpot, sOkTest; INT16 sCloseGridNo=NOWHERE; UINT32 uiMercFlags; @@ -4717,15 +4717,15 @@ INT16 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pubDirect if ( sDistance < sClosest ) { - sClosest = sDistance; - sCloseGridNo = (INT16)sGridNo; + sClosest = sDistance; + sCloseGridNo = sGridNo; } } } } - for (cnt = 0; cnt < 4; cnt++) + for (INT8 cnt = 0; cnt < 4; cnt++) { // MOVE OUT TWO DIRECTIONS sFourGrids[cnt] = sSpot = NewGridNo( sGridNo, DirectionInc( sDirs[ cnt ] ) ); @@ -4874,8 +4874,8 @@ INT16 FindNextToAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pub // fDoor determines whether special door-handling code should be used (for interacting with doors) INT16 sFourGrids[4], sDistance=0; - INT16 sDirs[4] = { NORTH, EAST, SOUTH, WEST }; - INT32 cnt; + INT8 sDirs[4] = { NORTH, EAST, SOUTH, WEST }; + //INT32 cnt; INT16 sClosest=WORLD_MAX, sSpot, sSpot2, sOkTest; INT16 sCloseGridNo=NOWHERE; UINT32 uiMercFlags; @@ -4952,7 +4952,7 @@ INT16 FindNextToAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pub } - for (cnt = 0; cnt < 4; cnt++) + for (INT8 cnt = 0; cnt < 4; cnt++) { // MOVE OUT TWO DIRECTIONS sFourGrids[cnt] = sSpot = NewGridNo( sGridNo, DirectionInc( sDirs[ cnt ] ) ); @@ -5131,13 +5131,13 @@ INT16 FindNextToAdjacentGridEx( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 *pub INT16 FindAdjacentPunchTarget( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pTargetSoldier, INT16 * psAdjustedTargetGridNo, UINT8 * pubDirection ) { - INT16 cnt; + //INT16 cnt; INT16 sSpot; UINT8 ubGuyThere; - for ( cnt = 0; cnt < NUM_WORLD_DIRECTIONS; cnt++ ) + for ( INT8 cnt = 0; cnt < NUM_WORLD_DIRECTIONS; cnt++ ) { - sSpot = (INT16)NewGridNo( pSoldier->sGridNo, DirectionInc( cnt ) ); + sSpot = NewGridNo( pSoldier->sGridNo, DirectionInc( cnt ) ); if ( DoorTravelCost( pSoldier, sSpot, gubWorldMovementCosts[ sSpot ][ cnt ][ pSoldier->bLevel ], FALSE, NULL ) >= TRAVELCOST_BLOCKED ) { diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index d9344d94..073f755e 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -2300,7 +2300,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl // We should reduce points for starting to run if first tile is a fence... - sTestGridno = NewGridNo(pSold->sGridNo,(INT16) DirectionInc( (UINT16)guiPathingData[0])); + sTestGridno = NewGridNo(pSold->sGridNo, DirectionInc( guiPathingData[0])); if ( gubWorldMovementCosts[ sTestGridno ][ (INT8)guiPathingData[0] ][ pSold->bLevel] == TRAVELCOST_FENCE ) { if ( usMovementMode == RUNNING && pSold->usAnimState != RUNNING ) @@ -2354,7 +2354,7 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl // what is the next gridno in the path? sOldGrid = sTempGrid; - sTempGrid = NewGridNo(sTempGrid,(INT16) DirectionInc( (UINT16)guiPathingData[iCnt])); + sTempGrid = NewGridNo(sTempGrid, DirectionInc( guiPathingData[iCnt])); // Get switch value... sSwitchValue = gubWorldMovementCosts[ sTempGrid ][ (INT8)guiPathingData[iCnt] ][ pSold->bLevel]; diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index 6132c260..7f209093 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1484,7 +1484,7 @@ UINT8 MinAPsToPunch(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAddTurningCost INT8 MinPtsToMove(SOLDIERTYPE *pSoldier) { // look around all 8 directions and return lowest terrain cost - INT32 cnt; + INT8 cnt; INT16 sLowest=127; INT16 sGridno,sCost; @@ -1495,10 +1495,10 @@ INT8 MinPtsToMove(SOLDIERTYPE *pSoldier) for (cnt=0; cnt <= 7; cnt++) { - sGridno = NewGridNo(pSoldier->sGridNo,DirectionInc((INT16) cnt)); + sGridno = NewGridNo(pSoldier->sGridNo, DirectionInc( cnt )); if (sGridno != pSoldier->sGridNo) { - if ( (sCost=ActionPointCost( pSoldier, sGridno, (UINT8)cnt , pSoldier->usUIMovementMode ) ) < sLowest ) + if ( (sCost=ActionPointCost( pSoldier, sGridno, cnt , pSoldier->usUIMovementMode ) ) < sLowest ) { sLowest = sCost; } @@ -1513,7 +1513,7 @@ INT8 PtsToMoveDirection(SOLDIERTYPE *pSoldier, INT8 bDirection ) INT8 bOverTerrainType; UINT16 usMoveModeToUse; - sGridno = NewGridNo( pSoldier->sGridNo, DirectionInc((INT16) bDirection ) ); + sGridno = NewGridNo( pSoldier->sGridNo, DirectionInc( bDirection ) ); usMoveModeToUse = pSoldier->usUIMovementMode; diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 77ca338b..8d91974f 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -2367,7 +2367,7 @@ BOOLEAN EVENT_InitNewSoldierAnim( SOLDIERTYPE *pSoldier, UINT16 usNewState, UINT uiOldAnimFlags = gAnimControl[ pSoldier->usAnimState ].uiFlags; uiNewAnimFlags = gAnimControl[ usNewState ].uiFlags; - usNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)DirectionInc( pSoldier->usPathingData[ pSoldier->usPathIndex ] ) ); + usNewGridNo = NewGridNo( pSoldier->sGridNo, DirectionInc( pSoldier->usPathingData[ pSoldier->usPathIndex ] ) ); // CHECKING IF WE HAVE A HIT FINISH BUT NO DEATH IS DONE WITH A SPECIAL ANI CODE diff --git a/Tactical/fov.cpp b/Tactical/fov.cpp index 531bdd3c..084e75dc 100644 --- a/Tactical/fov.cpp +++ b/Tactical/fov.cpp @@ -369,8 +369,11 @@ void RevealRoofsAndItems(SOLDIERTYPE *pSoldier, UINT32 itemsToo, BOOLEAN fShowLo BuildSightDir(dir,(UINT32 *)&Dir[0],(UINT32 *)&Dir[1],(UINT32 *)&Dir[2],(UINT32 *)&Dir[3],(UINT32 *)&Dir[4]); + for (cnt = 0; cnt < 5; cnt++) - Inc[cnt] = DirectionInc( (INT16)Dir[cnt]); + { + Inc[cnt] = DirectionInc( Dir[cnt] ); + } // create gridno increment for NOVIEW - in other words, no increment! Inc[5] = 0; diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index 575816c4..7ea79b3c 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -194,9 +194,9 @@ INT8 CalcBestCTGT( SOLDIERTYPE *pSoldier, UINT8 ubOppID, INT16 sOppGridNo, INT8 // using only ints for maximum execution speed here // CJC: Well, so much for THAT idea! - INT16 sCentralGridNo, sAdjSpot, sNorthGridNo, sSouthGridNo, sDir, sCheckSpot, sOKTest; - + INT16 sCentralGridNo, sAdjSpot, sNorthGridNo, sSouthGridNo, sCheckSpot, sOKTest; INT8 bThisCTGT, bBestCTGT = 0; + UINT8 sDir = 0; sCheckSpot = -1; @@ -209,7 +209,8 @@ INT8 CalcBestCTGT( SOLDIERTYPE *pSoldier, UINT8 ubOppID, INT16 sOppGridNo, INT8 sSouthGridNo = NewGridNo( sCentralGridNo, DirectionInc(SOUTH) ); // look into all 8 adjacent tiles & determine where the cover is the worst - for (sDir = 1; sDir <= 8; sDir++) + // Lalien: shouldn't this start at 0 than? + for (sDir = 0; sDir < NUM_WORLD_DIRECTIONS; sDir++) { // get the gridno of the adjacent spot lying in that direction sAdjSpot = NewGridNo( sCentralGridNo, DirectionInc( sDir ) ); diff --git a/TacticalAI/Movement.cpp b/TacticalAI/Movement.cpp index 7d6cf80a..40902765 100644 --- a/TacticalAI/Movement.cpp +++ b/TacticalAI/Movement.cpp @@ -574,7 +574,7 @@ INT16 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT16 sDesGrid, IN ubDirChecked[ubDirection] = TRUE; // determine the gridno 1 tile away from current friend in this direction - sTempDest = NewGridNo(sDesGrid,DirectionInc( (INT16)(ubDirection + 1) )); + sTempDest = NewGridNo(sDesGrid, DirectionInc( ubDirection + 1 ) ); // if that's out of bounds, ignore it & check next direction if (sTempDest == sDesGrid) @@ -625,8 +625,8 @@ INT16 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT16 sDesGrid, IN { // what is the next gridno in the path? - //sTempDest = NewGridNo( sGoToGrid,DirectionInc( (INT16) (pSoldier->usPathingData[sLoop] + 1) ) ); - sTempDest = NewGridNo( sGoToGrid,DirectionInc( (INT16) (pSoldier->usPathingData[sLoop]) ) ); + //sTempDest = NewGridNo( sGoToGrid,DirectionInc( (pSoldier->usPathingData[sLoop] + 1) ) ); + sTempDest = NewGridNo( sGoToGrid, DirectionInc( pSoldier->usPathingData[sLoop] ) ); //NumMessage("sTempDest = ",sTempDest); // this should NEVER be out of bounds