Skip to content

Commit

Permalink
Merge pull request #48958 from kleonc/astar-get_available_point_id-st…
Browse files Browse the repository at this point in the history
…art-from-zero

Astar::get_available_point_id Return 0 instead of 1 when empty
  • Loading branch information
akien-mga authored Aug 1, 2021
2 parents 8465ecc + 17324db commit e5411a8
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions core/math/a_star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@
#include "scene/scene_string_names.h"

int AStar::get_available_point_id() const {
if (points.is_empty()) {
return 1;
}

// calculate our new next available point id if bigger than before or next id already contained in set of points.
if (points.has(last_free_id)) {
int cur_new_id = last_free_id;
int cur_new_id = last_free_id + 1;
while (points.has(cur_new_id)) {
cur_new_id++;
}
int &non_const = const_cast<int &>(last_free_id);
non_const = cur_new_id;
const_cast<int &>(last_free_id) = cur_new_id;
}

return last_free_id;
Expand Down

0 comments on commit e5411a8

Please sign in to comment.