From 8cf389aaf748c77aecda0b3a3773c45053b0f231 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 25 Oct 2024 13:02:38 +0200 Subject: implement all ALGA features --- PathfindingContext.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'PathfindingContext.cpp') diff --git a/PathfindingContext.cpp b/PathfindingContext.cpp index 95ac3b1..49d1dc8 100644 --- a/PathfindingContext.cpp +++ b/PathfindingContext.cpp @@ -10,29 +10,29 @@ using namespace std; PathfindingContext::PathfindingContext(Museum & m) : museum(m) { - this->solvers.push_back(unique_ptr(new DijkstraPathfinder(m))); - this->solvers.push_back(unique_ptr(new BreadthFirstPathfinder(m))); + this->solvers.push_back(unique_ptr(new DijkstraPathfinder(m))); + this->solvers.push_back(unique_ptr(new BreadthFirstPathfinder(m))); } void PathfindingContext::cycle_solver() { - this->solver_index = (this->solver_index + 1) % this->solvers.size(); + this->solver_index = (this->solver_index + 1) % this->solvers.size(); this->update(); } Pathfinder & PathfindingContext::get_solver() { - return *this->solvers[this->solver_index]; + return *this->solvers[this->solver_index]; } void PathfindingContext::set_start(const XY & point) { - if (this->empty_point(point)) return; + if (this->empty_point(point)) return; this->start_point = point; - this->update(); + this->update(); } void PathfindingContext::set_end(const XY & point) { - if (this->empty_point(point)) return; + if (this->empty_point(point)) return; this->end_point = point; - this->update(); + this->update(); } bool PathfindingContext::empty_point(const XY & point) { @@ -50,20 +50,20 @@ bool PathfindingContext::empty_point(const XY & point) { } void PathfindingContext::update() { - bool valid = true; - if (this->empty_point(this->start_point)) { - this->start_point = { -1, -1 }; - valid = false; - } - if (this->empty_point(this->end_point)) { - this->end_point = { -1, -1 }; - valid = false; - } - if (!valid) return; + bool valid = true; + if (this->empty_point(this->start_point)) { + this->start_point = { -1, -1 }; + valid = false; + } + if (this->empty_point(this->end_point)) { + this->end_point = { -1, -1 }; + valid = false; + } + if (!valid) return; - ToggleMuseumPauseCommand(this->museum, true).execute(); - Pathfinder & solver = this->get_solver(); - solver.find_between(this->start_point, this->end_point); + ToggleMuseumPauseCommand(this->museum, true).execute(); + Pathfinder & solver = this->get_solver(); + solver.find_between(this->start_point, this->end_point); } void PathfindingContext::register_weight(const string & type, unsigned int weight) { -- cgit v1.2.3