mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
Fix: Improved the fix for militia manning tanks in revision 7557. Tank slots are not made invalid anymore. Instead the placement body type will be converted to a normal militia body and moved to a free slot next to the tank. There is a new function "FindNearestPassableSpot" for finding an accessible tile next to a starting grid.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7588 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -2907,5 +2907,40 @@ INT8 FindDirectionForClimbing( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel
|
||||
return DIRECTION_IRRELEVANT;
|
||||
}
|
||||
|
||||
INT32 FindNearestPassableSpot( INT32 sGridNo, UINT8 usSearchRadius )
|
||||
{
|
||||
INT32 sNearestSpot = NOWHERE;
|
||||
INT16 sMaxLeft, sMaxRight, sMaxUp, sMaxDown, sXOffset, sYOffset;
|
||||
INT32 sTestGridNo;
|
||||
INT32 iDist, iClosestDist = 10;
|
||||
|
||||
// determine maximum horizontal limits
|
||||
sMaxLeft = min( usSearchRadius, (sGridNo % MAXCOL));
|
||||
sMaxRight = min( usSearchRadius, MAXCOL - ((sGridNo % MAXCOL) + 1));
|
||||
|
||||
// determine maximum vertical limits
|
||||
sMaxUp = min( usSearchRadius, (sGridNo / MAXROW));
|
||||
sMaxDown = min( usSearchRadius, MAXROW - ((sGridNo / MAXROW) + 1));
|
||||
|
||||
// SET UP DOUBLE-LOOP TO STEP THROUGH POTENTIAL GRID #s
|
||||
for (sYOffset = -sMaxUp; sYOffset <= sMaxDown; sYOffset++)
|
||||
{
|
||||
for (sXOffset = -sMaxLeft; sXOffset <= sMaxRight; sXOffset++)
|
||||
{
|
||||
// calculate the next potential gridno
|
||||
sTestGridNo = sGridNo + sXOffset + (MAXCOL * sYOffset);
|
||||
// is this an empty tile (no structure on it) or is the structure passable?
|
||||
if (gpWorldLevelData[sTestGridNo].pStructureHead == NULL || FindStructure( sTestGridNo, STRUCTURE_PASSABLE ) != NULL)
|
||||
{
|
||||
iDist = PythSpacesAway( sGridNo, sTestGridNo );
|
||||
if (iDist < iClosestDist)
|
||||
{
|
||||
iClosestDist = iDist;
|
||||
sNearestSpot = sTestGridNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return( sNearestSpot );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user