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:
silversurfer
2014-10-18 15:26:03 +00:00
parent e000abcc57
commit f05cdc3286
3 changed files with 56 additions and 8 deletions
+35
View File
@@ -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 );
}