diff --git a/client/goto.cpp b/client/goto.cpp index 65111b1143..11ecb4c9fc 100644 --- a/client/goto.cpp +++ b/client/goto.cpp @@ -99,7 +99,7 @@ bool is_valid_goto_destination(const struct tile *ptile) /** Inserts a waypoint at the end of the current goto line. */ -bool goto_add_waypoint() +void goto_add_waypoint() { for (auto &[_, finder] : goto_finders) { // Patrol always uses a waypoint @@ -114,7 +114,6 @@ bool goto_add_waypoint() finder.push_waypoint(goto_destination); } } - return true; } /** @@ -123,20 +122,21 @@ bool goto_add_waypoint() */ bool goto_pop_waypoint() { + bool popped = false; for (auto &[_, finder] : goto_finders) { // Patrol always uses a waypoint if (hover_state == HOVER_PATROL) { finder.pop_waypoint(); } - finder.pop_waypoint(); + popped |= finder.pop_waypoint(); // Patrol always uses a waypoint if (hover_state == HOVER_PATROL) { finder.push_waypoint(goto_destination); } } - return true; + return popped; } /** diff --git a/client/goto.h b/client/goto.h index 85d2357838..435ef86e44 100644 --- a/client/goto.h +++ b/client/goto.h @@ -37,7 +37,7 @@ void goto_unit_killed(struct unit *punit); bool goto_is_active(); bool goto_tile_state(const struct tile *ptile, enum goto_tile_state *state, int *turns, bool *waypoint); -bool goto_add_waypoint(); +void goto_add_waypoint(); bool goto_pop_waypoint(); bool is_valid_goto_destination(const struct tile *ptile); diff --git a/common/path_finder.cpp b/common/path_finder.cpp index b3a5f80c28..fb50941b00 100644 --- a/common/path_finder.cpp +++ b/common/path_finder.cpp @@ -653,11 +653,11 @@ void path_finder::push_waypoint(const tile *location) * * \see push_waypoint */ -void path_finder::pop_waypoint() +bool path_finder::pop_waypoint() { // Nothing to to. if (m_d->waypoints.empty()) { - return; + return false; } m_d->waypoints.pop_back(); @@ -668,6 +668,8 @@ void path_finder::pop_waypoint() m_d->queue.pop(); } m_d->insert_initial_vertex(); + + return true; } /** * Notifies the path finder that some unit died or changed state. In many diff --git a/common/path_finder.h b/common/path_finder.h index 613b63d864..b09bf49e02 100644 --- a/common/path_finder.h +++ b/common/path_finder.h @@ -111,7 +111,7 @@ class path_finder { inline path_finder &operator=(path_finder &&other); void push_waypoint(const tile *location); - void pop_waypoint(); + bool pop_waypoint(); void unit_changed(const unit &unit);