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

Astar::get_available_point_id Return 0 instead of 1 when empty #48958

Merged
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
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