Mercurial > fife-parpg
annotate engine/core/pathfinder/routepather/routepather.cpp @ 697:ecaa4d98f05f tip
Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
* Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring.
* GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass.
* The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class.
* The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged.
* Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Sat, 18 Jun 2011 00:28:40 -1000 |
parents | 8afb9b443f66 |
children |
rev | line source |
---|---|
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 /*************************************************************************** |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 * Copyright (C) 2005-2008 by the FIFE team * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 * http://www.fifengine.de * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 * This file is part of FIFE. * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
6 * FIFE is free software; you can redistribute it and/or * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
8 * License as published by the Free Software Foundation; either * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
14 * Lesser General Public License for more details. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
17 * License along with this library; if not, write to the * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 * Free Software Foundation, Inc., * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 ***************************************************************************/ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 // Standard C++ library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 #include <cassert> |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 // 3rd party library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 // FIFE includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 // These includes are split up in two parts, separated by one empty line |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 // First block: files included from the FIFE root src directory |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 // Second block: files included from the same folder |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 #include "model/metamodel/grids/cellgrid.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 #include "model/structures/instance.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 #include "model/structures/layer.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 #include "pathfinder/searchspace.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 #include "routepather.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 #include "routepathersearch.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 namespace FIFE { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 void RoutePather::setMap(Map* map) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 if(!map) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 m_map = map; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
48 int RoutePather::makeSessionId() { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
49 return m_nextFreeSessionId++; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
50 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
51 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
52 void RoutePather::makePlan(const Instance *instance, const Location& target, int session_id, int priority) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 SearchSpace* searchspace = getSearchSpace(target.getLayer()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 if(!searchspace) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 searchspace = new SearchSpace(target.getLayer()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 addSearchSpace(searchspace); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 if(searchspace->isInSearchSpace(target)) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 RoutePatherSearch* newSearch = new RoutePatherSearch(session_id, instance->getLocation(), target, searchspace); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 m_sessions.pushElement(SessionQueue::value_type(newSearch, priority)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 addSessionId(session_id); |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
62 m_path_targets.insert(LocationMap::value_type(session_id,target)); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
63 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
64 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
65 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
66 bool RoutePather::locationsEqual(const Location &a, const Location &b) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
67 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
68 const ModelCoordinate a_coord = a.getLayerCoordinates(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
69 const ModelCoordinate b_coord = b.getLayerCoordinates(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
70 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
71 return a_coord == b_coord; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
72 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
73 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
74 bool RoutePather::testStep(const Instance *instance, Path& path) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
75 Location instanceLoc = instance->getLocation(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
76 if(!path.empty() && |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
77 !locationsEqual(path.front(), instanceLoc) && |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
78 instanceLoc.getLayer()->cellContainsBlockingInstance(path.front().getLayerCoordinates())) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
79 const bool last_step = path.front() == path.back(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
80 path.clear(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
81 return last_step; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
82 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
83 return true; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
84 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
85 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
86 int RoutePather::getNextLocation(const Instance* instance, const Location& target, |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
87 double distance_to_travel, Location& nextLocation, |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
88 Location& facingLocation, int session_id, int priority) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
89 assert(instance); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
90 assert(instance->getLocation().getLayer() == target.getLayer()); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
91 bool plan_needed = true; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
92 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
93 if(session_id != -1) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
94 plan_needed = false; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
95 PathMap::iterator path_itor = m_paths.find(session_id); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
96 if(path_itor != m_paths.end()) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
97 LocationMap::iterator location_itor = m_path_targets.find(session_id); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
98 assert(location_itor != m_path_targets.end()); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
99 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
100 if(path_itor->second.empty()) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
101 m_paths.erase(path_itor); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
102 m_path_targets.erase(location_itor); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
103 return -1; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
104 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
105 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
106 if(!followPath(instance, path_itor->second, distance_to_travel, nextLocation, facingLocation) |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
107 || !locationsEqual(location_itor->second, target)) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
108 m_paths.erase(path_itor); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
109 m_path_targets.erase(location_itor); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
110 plan_needed = true; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
111 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
112 } else if(!sessionIdValid(session_id)) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
113 //Session id is invalid. |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
114 return -1; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
115 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
116 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
117 if(plan_needed) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
118 if(session_id == -1) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
119 session_id = makeSessionId(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
120 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
121 makePlan(instance, target, session_id, priority); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 return session_id; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
125 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
126 void RoutePather::update() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 int ticksleft = m_maxticks; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 while(ticksleft >= 0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 if(m_sessions.empty()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 break; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 } |
310
8afb9b443f66
merged the pathfinding branch to trunk
wenlin_fife@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
300
diff
changeset
|
132 RoutePatherSearch* priority_session = m_sessions.getPriorityElement().first; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 if(!sessionIdValid(priority_session->getSessionId())) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
134 delete priority_session; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 m_sessions.popElement(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 continue; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
137 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
138 priority_session->updateSearch(); |
310
8afb9b443f66
merged the pathfinding branch to trunk
wenlin_fife@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
300
diff
changeset
|
139 if(priority_session->getSearchStatus() == RoutePatherSearch::search_status_complete) { |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
140 const int session_id = priority_session->getSessionId(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
141 Path newPath = priority_session->calcPath(); |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
142 newPath.erase(newPath.begin()); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
143 m_paths.insert(PathMap::value_type(session_id, newPath)); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
144 invalidateSessionId(session_id); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
145 delete priority_session; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
146 m_sessions.popElement(); |
310
8afb9b443f66
merged the pathfinding branch to trunk
wenlin_fife@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
300
diff
changeset
|
147 } else if(priority_session->getSearchStatus() == RoutePatherSearch::search_status_failed) { |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
148 const int session_id = priority_session->getSessionId(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
149 invalidateSessionId(session_id); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
150 delete priority_session; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
151 m_sessions.popElement(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
152 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
153 --ticksleft; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
154 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
155 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
156 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
157 bool RoutePather::followPath(const Instance* instance, Path& path, double speed, Location& nextLocation, Location& facingLocation) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
158 Location instanceLoc = instance->getLocation(); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
159 if(!testStep(instance, path)) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
160 return false; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
161 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
162 |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
163 if(path.empty()) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
164 return true; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
165 } |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
166 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
167 ExactModelCoordinate instancePos = instanceLoc.getMapCoordinates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
168 ExactModelCoordinate facingPos = path.front().getMapCoordinates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
169 facingPos.x = facingPos.x + (facingPos.x - instancePos.x); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
170 facingPos.y = facingPos.y + (facingPos.y - instancePos.y); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
171 facingLocation = path.front(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
172 facingLocation.setMapCoordinates(facingPos); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
173 ExactModelCoordinate targetPos = path.front().getMapCoordinates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
174 CellGrid* grid = instanceLoc.getLayer()->getCellGrid(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
175 double dx = (targetPos.x - instancePos.x) * grid->getXScale(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
176 double dy = (targetPos.y - instancePos.y) * grid->getYScale(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
177 double distance = sqrt(dx * dx + dy * dy); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
178 bool pop = false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 if(speed > distance) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 speed = distance; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
181 pop = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
182 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
183 if(distance != 0) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
184 instancePos.x += (dx / distance) * speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 instancePos.y += (dy / distance) * speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
186 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
187 pop = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
188 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
189 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
190 nextLocation.setMapCoordinates(instancePos); |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
191 if(pop) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
192 path.pop_front(); |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
193 if(!testStep(instance, path)) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
194 return false; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
195 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
196 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
197 return true; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
198 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
199 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
200 bool RoutePather::cancelSession(const int session_id) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
201 if(session_id >= 0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 PathMap::iterator i = m_paths.find(session_id); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 if(i != m_paths.end()) { |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
204 LocationMap::iterator j = m_path_targets.find(session_id); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
205 assert(j != m_path_targets.end()); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
206 m_paths.erase(i); |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
207 m_path_targets.erase(j); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 return true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
209 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
210 invalidateSessionId(session_id); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
211 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
212 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
213 return false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
214 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
215 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
216 void RoutePather::addSessionId(const int sessionId) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 m_registeredSessionIds.push_back(sessionId); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
219 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
220 bool RoutePather::sessionIdValid(const int sessionId) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 for(SessionList::const_iterator i = m_registeredSessionIds.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
222 i != m_registeredSessionIds.end(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 ++i) { |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
224 if((*i) == sessionId) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
225 return true; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
226 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
227 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
228 return false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
229 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
230 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
231 bool RoutePather::invalidateSessionId(const int sessionId) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
232 for(SessionList::iterator i = m_registeredSessionIds.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
233 i != m_registeredSessionIds.end(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
234 ++i) { |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
235 if((*i) == sessionId) { |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
236 m_registeredSessionIds.erase(i); |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
237 return true; |
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
238 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
239 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
240 return false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
242 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 bool RoutePather::addSearchSpace(SearchSpace* search_space) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 std::pair<SearchSpaceMap::iterator, bool> res = m_searchspaces.insert(SearchSpaceMap::value_type(search_space->getLayer(), search_space)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
246 return res.second; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 } |
190
f970f7dab2dd
Allow routepather to re-plan when the plan becomes invalid:
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
248 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 SearchSpace* RoutePather::getSearchSpace(Layer * const layer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 SearchSpaceMap::iterator i = m_searchspaces.find(layer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 if(i == m_searchspaces.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 return 0; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
254 return i->second; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
255 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
256 } |