diff options
Diffstat (limited to 'PathfindingContext.cpp')
-rw-r--r-- | PathfindingContext.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
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<Pathfinder>(new DijkstraPathfinder(m))); - this->solvers.push_back(unique_ptr<Pathfinder>(new BreadthFirstPathfinder(m))); + this->solvers.push_back(unique_ptr<Pathfinder>(new DijkstraPathfinder(m))); + this->solvers.push_back(unique_ptr<Pathfinder>(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) { |