Fix usage of uninitialized waypoint array variables in ConfusedMovementGenerator<T>::Initialize and revert 9b1c565510+ad8ce5245e that covered up this problem without fixing it and introduced a faulty LOS calculation.

With thanks to Lynx3d and click, and Aokromes and ritchy for testing.

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-06-19 17:26:12 +02:00
parent 706c0568a5
commit 8c8986b2bc
4 changed files with 17 additions and 31 deletions
@@ -51,15 +51,13 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx)
{
const float wanderX = wander_distance*rand_norm() - wander_distance/2;
const float wanderY = wander_distance*rand_norm() - wander_distance/2;
i_waypoints[idx][0] = x + wanderX;
i_waypoints[idx][1] = y + wanderY;
const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f);
if (isInLoS)
{
const float wanderX = wander_distance*rand_norm() - wander_distance/2;
const float wanderY = wander_distance*rand_norm() - wander_distance/2;
i_waypoints[idx][0] = x + wanderX;
i_waypoints[idx][1] = y + wanderY;
}
else
if (!isInLoS)
{
i_waypoints[idx][0] = x;
i_waypoints[idx][1] = y;