Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #5215 #5205 and hopefully many other cases of stuck units
See comment in code.
Note that this is a significant change that should fix a lot of stuck units but can also have nasty side effects
  • Loading branch information
ashdnazg committed May 3, 2016
1 parent e579234 commit 5c6bc5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion rts/Sim/MoveTypes/GroundMoveType.cpp
Expand Up @@ -564,7 +564,13 @@ void CGroundMoveType::ChangeSpeed(float newWantedSpeed, bool wantReverse, bool f
// the pathfinders do NOT check the entire footprint to determine
// passability wrt. terrain (only wrt. structures), so we look at
// the center square ONLY for our current speedmod
const float groundSpeedMod = CMoveMath::GetPosSpeedMod(*md, owner->pos, flatFrontDir);
float groundSpeedMod = CMoveMath::GetPosSpeedMod(*md, owner->pos, flatFrontDir);

// the pathfinders don't check the speedmod of the square our unit is currently on
// so if we got stuck on a nonpassable square and can't move try to see if we're
// trying to release ourselves towards a passable square
if (groundSpeedMod == 0.0f)
groundSpeedMod = CMoveMath::GetPosSpeedMod(*md, owner->pos + flatFrontDir * SQUARE_SIZE, flatFrontDir);

const float curGoalDistSq = (owner->pos - goalPos).SqLength2D();
const float minGoalDistSq = Square(BrakingDistance(currentSpeed, decRate));
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/MoveTypes/MoveMath/GroundMoveMath.cpp
Expand Up @@ -33,7 +33,7 @@ float CMoveMath::GroundSpeedMod(const MoveDef& moveDef, float height, float slop
// Directional speed is now equal to regular except when:
// 1) Climbing out of places which are below max depth.
// 2) Climbing hills is slower.

float speedMod = 0.0f;

if (slope > moveDef.maxSlope)
Expand Down

0 comments on commit 5c6bc5d

Please sign in to comment.