Astar::get_available_point_id Start from 0

(cherry picked from commit 17324db4ca)
This commit is contained in:
kleonc 2021-05-22 11:44:34 +02:00 committed by Rémi Verschelde
parent 38d47c051a
commit 507fcf2a82
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -35,18 +35,12 @@
#include "scene/scene_string_names.h"
int AStar::get_available_point_id() const {
if (points.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;