diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 65f8f0e4..19482fa5 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -1778,7 +1778,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT16 usHa else { // See if we can get there to stab - sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE); + sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE, true); } if ( sActionGridNo != NOWHERE ) diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index cd0dc3f5..ef10f5b3 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -4528,7 +4528,7 @@ INT8 DrawUIMovementPath( SOLDIERTYPE *pSoldier, INT32 usMapPos, UINT32 uiFlags ) else { // See if we can get there to stab - sActionGridNo = FindAdjacentGridEx(pSoldier, usMapPos, &ubDirection, &sAdjustedGridNo, TRUE, FALSE); + sActionGridNo = FindAdjacentGridEx(pSoldier, usMapPos, &ubDirection, &sAdjustedGridNo, TRUE, FALSE, true); } } else diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index ead70ed5..3a713ee4 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -5444,7 +5444,7 @@ BOOLEAN TeamMemberNear(INT8 bTeam, INT32 sGridNo, INT32 iRange) return(FALSE); } -INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor ) +INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor, bool allow_diagonal ) { // psAdjustedGridNo gets the original gridno or the new one if updated // It will ONLY be updated IF we were over a merc, ( it's updated to their gridno ) @@ -5453,7 +5453,7 @@ INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirect // in that location, because we could be passed a gridno based on the overlap of soldier's graphic // fDoor determines whether special door-handling code should be used (for interacting with doors) INT32 sGridNoProne = -1; - INT32 sFourGrids[4], sDistance=0; + INT32 sDistance=0; static const UINT8 sDirs[4] = { NORTH, EAST, SOUTH, WEST }; INT32 sClosest = -1, sSpot; INT32 sCloseGridNo = NOWHERE; @@ -5594,12 +5594,11 @@ INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirect } } - for (INT8 cnt = 0; cnt < 4; ++cnt) + for (INT8 cnt = 0; cnt < (allow_diagonal ? NUM_WORLD_DIRECTIONS : 4); ++cnt) { - // MOVE OUT TWO DIRECTIONS - sFourGrids[cnt] = sSpot = NewGridNo( sGridNo, DirectionInc( sDirs[ cnt ] ) ); - - ubTestDirection = sDirs[ cnt ]; + ubTestDirection = (allow_diagonal ? cnt : sDirs[cnt]); + // MOVE OUT TWO DIRECTIONS + sSpot = NewGridNo( sGridNo, DirectionInc(ubTestDirection) ); // For switches, ALLOW them to walk through walls to reach it.... if ( pDoor && pDoor->fFlags & STRUCTURE_SWITCH ) @@ -5675,12 +5674,11 @@ INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirect } if (sGridNoProne != -1) { - for (INT8 cnt = 0; cnt < 4; ++cnt) + for (INT8 cnt = 0; cnt < (allow_diagonal ? NUM_WORLD_DIRECTIONS : 4); ++cnt) { + ubTestDirection = (allow_diagonal ? cnt : sDirs[cnt]); // MOVE OUT TWO DIRECTIONS - sFourGrids[cnt] = sSpot = NewGridNo(sGridNoProne, DirectionInc(sDirs[cnt])); - - ubTestDirection = sDirs[cnt]; + sSpot = NewGridNo(sGridNoProne, DirectionInc(ubTestDirection)); // For switches, ALLOW them to walk through walls to reach it.... if (pDoor && pDoor->fFlags & STRUCTURE_SWITCH) diff --git a/Tactical/Overhead.h b/Tactical/Overhead.h index e0739fff..2b88c7ee 100644 --- a/Tactical/Overhead.h +++ b/Tactical/Overhead.h @@ -255,7 +255,7 @@ UINT32 EnterTacticalDemoMode(); BOOLEAN UIOKMoveDestination( SOLDIERTYPE *pSoldier, INT32 usMapPos ); -INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor ); +INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor , bool allow_diagonal = false); INT32 FindNextToAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor ); diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index ca9961d8..f5966476 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1937,7 +1937,7 @@ INT16 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTur else { // See if we can get there to stab - sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE); + sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE, true); } if (!TileIsOutOfBounds(sActionGridNo))