Skip to content

Commit 9c6aa3c

Browse files
authored
Merge pull request #224 from Architector4/patch-3
Actor - use fallbacks in GetMovePathEnd()
2 parents b5ad2d0 + c512334 commit 9c6aa3c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Source/Entities/Actor.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,19 @@ namespace RTE {
445445
/// @param m_MovePath.push_back(newCoordinate The new coordinate to add to the end of the MovePath.
446446
void AddToMovePathEnd(Vector newCoordinate) { m_MovePath.push_back(newCoordinate); }
447447

448-
/// Gets the last position in this Actor's move path.
449-
/// @return The last position in this Actor's move path.
450-
Vector GetMovePathEnd() const { return m_MovePath.back(); }
448+
/// Gets the last position in this Actor's move path, or otherwise the current move target.
449+
/// @return The last position in this Actor's move path, or otherwise the current move target.
450+
Vector GetMovePathEnd() const {
451+
if (!m_MovePath.empty()) {
452+
return m_MovePath.back();
453+
}
454+
// In case move path is empty, check our own path request.
455+
if (m_PathRequest) {
456+
return const_cast<Vector&>(m_PathRequest->targetPos);
457+
}
458+
// In case *that* is empty, just return the move target.
459+
return m_MoveTarget;
460+
}
451461

452462
/// Removes a coordinate from the beginning of the MovePath, meaning the
453463
/// one closest to this Actor.

0 commit comments

Comments
 (0)