Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with waypoint updates #1907

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions rts/Sim/MoveTypes/GroundMoveType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ CR_REG_METADATA(CGroundMoveType, (
CR_MEMBER(atGoal),
CR_MEMBER(atEndOfPath),
CR_MEMBER(wantRepath),
CR_MEMBER(moveFailed),

CR_MEMBER(reversing),
CR_MEMBER(idling),
Expand Down Expand Up @@ -891,8 +890,8 @@ void CGroundMoveType::StartMovingRaw(const float3 moveGoalPos, float moveGoalRad
MoveTypes::CheckCollisionQuery collisionQuery(owner->moveDef, moveGoalPos);
extraRadius = deltaRadius * (1 - owner->moveDef->TestMoveSquare(collisionQuery, moveGoalPos, ZeroVector, true, true));

currWayPoint = goalPos;
nextWayPoint = goalPos;
earlyCurrWayPoint = currWayPoint = goalPos;
earlyNextWayPoint = nextWayPoint = goalPos;

atGoal = (moveGoalPos.SqDistance2D(owner->pos) < Square(goalRadius + extraRadius));
atEndOfPath = false;
Expand Down Expand Up @@ -991,7 +990,7 @@ void CGroundMoveType::StopMoving(bool callScript, bool hardStop, bool cancelRaw)
LOG_L(L_DEBUG, "[%s] stopping engine for unit %i", __func__, owner->id);

if (!atGoal)
goalPos = (currWayPoint = Here());
earlyCurrWayPoint = (goalPos = (currWayPoint = Here()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's becoming a fairly long chain of assignments. It's fine though and probably still more readable than the alternatives.


// this gets called under a variety of conditions (see MobileCAI)
// the most common case is a CMD_STOP being issued which means no
Expand Down Expand Up @@ -2062,13 +2061,12 @@ unsigned int CGroundMoveType::GetNewPath()
atEndOfPath = false;
lastWaypoint = false;

currWayPoint = pathManager->NextWayPoint(owner, newPathID, 0, owner->pos, std::max(WAYPOINT_RADIUS, currentSpeed * 1.05f), true);
nextWayPoint = pathManager->NextWayPoint(owner, newPathID, 0, currWayPoint, std::max(WAYPOINT_RADIUS, currentSpeed * 1.05f), true);
earlyCurrWayPoint = currWayPoint = pathManager->NextWayPoint(owner, newPathID, 0, owner->pos, std::max(WAYPOINT_RADIUS, currentSpeed * 1.05f), true);
earlyNextWayPoint = nextWayPoint = pathManager->NextWayPoint(owner, newPathID, 0, currWayPoint, std::max(WAYPOINT_RADIUS, currentSpeed * 1.05f), true);

pathController.SetRealGoalPosition(newPathID, goalPos);
pathController.SetTempGoalPosition(newPathID, currWayPoint);
} else {
// moveFailed = true;
Fail(false);
}

Expand Down Expand Up @@ -3287,7 +3285,7 @@ bool CGroundMoveType::UpdateDirectControl()
float turnSign = 0.0f;

currWayPoint = owner->frontdir * XZVector * mix(100.0f, -100.0f, wantReverse);
currWayPoint = (owner->pos + currWayPoint).cClampInBounds();
earlyCurrWayPoint = currWayPoint = (owner->pos + currWayPoint).cClampInBounds();

if (unitCon.forward || unitCon.back) {
ChangeSpeed((maxSpeed * unitCon.forward) + (maxReverseSpeed * unitCon.back), wantReverse, true);
Expand Down
5 changes: 0 additions & 5 deletions rts/Sim/MoveTypes/GroundMoveType.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ class CGroundMoveType : public AMoveType
float GetGroundHeight(const float3&) const;

void SyncWaypoints() {
if (moveFailed){
Fail(false);
moveFailed = false;
}
// Synced vars trigger a checksum update on change, which is expensive so we should check
// that there has been a change before triggering an update to the checksum.
if (!currWayPoint.bitExactEquals(earlyCurrWayPoint))
Expand Down Expand Up @@ -296,7 +292,6 @@ class CGroundMoveType : public AMoveType
bool atGoal = true;
bool atEndOfPath = true;
bool wantRepath = false;
bool moveFailed = false;
bool lastWaypoint = false;

bool reversing = false;
Expand Down