diff --git a/libopenage/pathfinding/cost_field.cpp b/libopenage/pathfinding/cost_field.cpp index 6c29e24f59..92afea4b9b 100644 --- a/libopenage/pathfinding/cost_field.cpp +++ b/libopenage/pathfinding/cost_field.cpp @@ -57,24 +57,25 @@ void CostField::set_costs(std::vector &&cells, const time::time_t &valid } bool CostField::stamp(size_t idx, cost_t cost, const time::time_t &stamped_at) { - if (this->cost_stamps.contains(idx)) return false; + if (this->cost_stamps[idx].has_value()) return false; cost_t original_cost = this->get_cost(idx); - this->cost_stamps[idx].original_cost = original_cost; - this->cost_stamps[idx].stamp_time = stamped_at; + this->cost_stamps[idx]->original_cost = original_cost; + this->cost_stamps[idx]->stamp_time = stamped_at; this->set_cost(idx, cost, stamped_at); return true; } bool CostField::unstamp(size_t idx, const time::time_t &unstamped_at) { - if (!this->cost_stamps.contains(idx)) return false; - if (unstamped_at < this->cost_stamps[idx].stamp_time) return false; + if (!this->cost_stamps[idx].has_value()) return false; + if (unstamped_at < this->cost_stamps[idx]->stamp_time) return false; - cost_t original_cost = cost_stamps[idx].original_cost; + cost_t original_cost = cost_stamps[idx]->original_cost; this->set_cost(idx, original_cost, unstamped_at); - return this->cost_stamps.erase(idx) != 0; + this->cost_stamps[idx].reset(); + return true; } bool CostField::is_dirty(const time::time_t &time) const { diff --git a/libopenage/pathfinding/cost_field.h b/libopenage/pathfinding/cost_field.h index 3750ed0680..b00a49f6fb 100644 --- a/libopenage/pathfinding/cost_field.h +++ b/libopenage/pathfinding/cost_field.h @@ -4,6 +4,7 @@ #include #include +#include #include "pathfinding/types.h" #include "time/time.h"