When picking a tile based on a given start coordinate, make sure the result coordinate is on

the same continent as the start coordinate. This hopefully fixes ticket:1385


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9112 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2010-01-10 22:07:59 +00:00 committed by Git SVN Gateway
parent b1f7e8ba17
commit 35c3ef9d35
1 changed files with 9 additions and 5 deletions

View File

@ -3646,10 +3646,10 @@ BOOL pickATileGen(UDWORD *x, UDWORD *y, UBYTE numIterations,
BOOL pickATileGenThreat(UDWORD *x, UDWORD *y, UBYTE numIterations, SDWORD threatRange,
SDWORD player, BOOL (*function)(UDWORD x, UDWORD y))
{
SDWORD i,j;
SDWORD startX,endX,startY,endY;
UDWORD passes;
SDWORD i, j;
SDWORD startX, endX, startY, endY;
UDWORD passes;
Vector2i origin = { *x, *y };
ASSERT_OR_RETURN(false, *x<mapWidth,"x coordinate is off-map for pickATileGen" );
ASSERT_OR_RETURN(false, *y<mapHeight,"y coordinate is off-map for pickATileGen" );
@ -3673,8 +3673,12 @@ UDWORD passes;
/* Test only perimeter as internal tested previous iteration */
if(i==startX || i==endX || j==startY || j==endY)
{
Vector2i newPos = { i, j };
/* Good enough? */
if(function(i,j) && ((threatRange <=0) || (!ThreatInRange(player, threatRange, world_coord(i), world_coord(j), false)))) //TODO: vtols check really not needed?
if (function(i, j)
&& fpathCheck(origin, newPos, PROPULSION_TYPE_WHEELED)
&& ((threatRange <= 0) || (!ThreatInRange(player, threatRange, world_coord(i), world_coord(j), false))))
{
/* Set exit conditions and get out NOW */
*x = i; *y = j;