Don't use extra precision when avoiding (or trying to avoid) obstacles, since it leads to integer overflow and pseudorandom decisions.

master
Cyp 2010-08-06 19:29:11 +02:00
parent 9998b89016
commit 6bc0682c06
1 changed files with 2 additions and 2 deletions

View File

@ -1435,8 +1435,8 @@ static void moveGetObstacleVector(DROID *psDroid, int32_t *pX, int32_t *pY)
*/
static uint16_t moveGetDirection(DROID *psDroid)
{
Position src = droidGetPrecisePosition(psDroid);
Position target = { (psDroid->sMove.targetX << EXTRA_BITS), (psDroid->sMove.targetY << EXTRA_BITS), 0 };
Position src = psDroid->pos; // Do not want precice precision here, would overflow.
Position target = {psDroid->sMove.targetX, psDroid->sMove.targetY, 0};
Position dest = Vector3i_Sub(target, src);
// Transporters don't need to avoid obstacles, but everyone else should