Fixes global init order bug that caused OOS between OS X and other platforms, fixes #3499. May improve pathfinding behavior in some cases, please test!
This was SVN commit r17132.
This commit is contained in:
parent
32dafe707d
commit
4043c56518
@ -38,8 +38,6 @@
|
||||
#include "ps/CLogger.h"
|
||||
#include "simulation2/helpers/Pathfinding.h"
|
||||
|
||||
const fixed Pathfinding::NAVCELL_SIZE = fixed::FromInt(TERRAIN_TILE_SIZE) / Pathfinding::NAVCELLS_PER_TILE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CTerrain constructor
|
||||
CTerrain::CTerrain()
|
||||
|
@ -102,8 +102,6 @@ static const fixed CHECK_TARGET_MOVEMENT_MIN_COS = fixed::FromInt(866)/1000;
|
||||
static const CColor OVERLAY_COLOR_LONG_PATH(1, 1, 1, 1);
|
||||
static const CColor OVERLAY_COLOR_SHORT_PATH(1, 0, 0, 1);
|
||||
|
||||
static const entity_pos_t g_GoalDelta = Pathfinding::NAVCELL_SIZE; // for extending the goal outwards/inwards a little bit
|
||||
|
||||
struct SUnitMotionPlanning
|
||||
{
|
||||
WaypointPath nextStepShortPath; // if !nextStepClean, store a short path for the next step here
|
||||
@ -1425,14 +1423,14 @@ bool CCmpUnitMotion::MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos
|
||||
// Too close to target - move outwards to a circle
|
||||
// that's slightly larger than the min range
|
||||
goal.type = PathGoal::INVERTED_CIRCLE;
|
||||
goal.hw = minRange + g_GoalDelta;
|
||||
goal.hw = minRange + Pathfinding::GOAL_DELTA;
|
||||
}
|
||||
else if (maxRange >= entity_pos_t::Zero() && distance > maxRange)
|
||||
{
|
||||
// Too far from target - move inwards to a circle
|
||||
// that's slightly smaller than the max range
|
||||
goal.type = PathGoal::CIRCLE;
|
||||
goal.hw = maxRange - g_GoalDelta;
|
||||
goal.hw = maxRange - Pathfinding::GOAL_DELTA;
|
||||
|
||||
// If maxRange was abnormally small,
|
||||
// collapse the circle into a point
|
||||
@ -1594,7 +1592,7 @@ bool CCmpUnitMotion::MoveToTargetRange(entity_id_t target, entity_pos_t minRange
|
||||
|
||||
// TODO: maybe we should do the ShouldTreatTargetAsCircle thing here?
|
||||
|
||||
entity_pos_t goalDistance = minRange + g_GoalDelta;
|
||||
entity_pos_t goalDistance = minRange + Pathfinding::GOAL_DELTA;
|
||||
|
||||
goal.type = PathGoal::INVERTED_SQUARE;
|
||||
goal.u = obstruction.u;
|
||||
@ -1634,7 +1632,7 @@ bool CCmpUnitMotion::MoveToTargetRange(entity_id_t target, entity_pos_t minRange
|
||||
return false;
|
||||
}
|
||||
|
||||
entity_pos_t goalDistance = maxRange - g_GoalDelta;
|
||||
entity_pos_t goalDistance = maxRange - Pathfinding::GOAL_DELTA;
|
||||
|
||||
goal.type = PathGoal::CIRCLE;
|
||||
goal.hw = circleRadius + goalDistance;
|
||||
@ -1644,7 +1642,7 @@ bool CCmpUnitMotion::MoveToTargetRange(entity_id_t target, entity_pos_t minRange
|
||||
// The target is large relative to our range, so treat it as a square and
|
||||
// get close enough that the diagonals come within range
|
||||
|
||||
entity_pos_t goalDistance = (maxRange - g_GoalDelta)*2 / 3; // multiply by slightly less than 1/sqrt(2)
|
||||
entity_pos_t goalDistance = (maxRange - Pathfinding::GOAL_DELTA)*2 / 3; // multiply by slightly less than 1/sqrt(2)
|
||||
|
||||
goal.type = PathGoal::SQUARE;
|
||||
goal.u = obstruction.u;
|
||||
|
@ -119,10 +119,17 @@ namespace Pathfinding
|
||||
/**
|
||||
* Size of a navcell in metres ( = TERRAIN_TILE_SIZE / NAVCELLS_PER_TILE)
|
||||
*/
|
||||
extern const fixed NAVCELL_SIZE;
|
||||
const fixed NAVCELL_SIZE = fixed::FromInt((int)TERRAIN_TILE_SIZE) / Pathfinding::NAVCELLS_PER_TILE;
|
||||
const int NAVCELL_SIZE_INT = 1;
|
||||
const int NAVCELL_SIZE_LOG2 = 0;
|
||||
|
||||
/**
|
||||
* For extending the goal outwards/inwards a little bit
|
||||
* NOTE: keep next to the definition of NAVCELL_SIZE to avoid init order problems
|
||||
* between translation units.
|
||||
*/
|
||||
const entity_pos_t GOAL_DELTA = NAVCELL_SIZE;
|
||||
|
||||
/**
|
||||
* Compute the navcell indexes on the grid nearest to a given point
|
||||
* w, h are the grid dimensions, i.e. the number of navcells per side
|
||||
|
Loading…
Reference in New Issue
Block a user