comparison engine/core/pathfinder/routepather/routepather.h @ 190:f970f7dab2dd

Allow routepather to re-plan when the plan becomes invalid: - one of the steps in the plan is blocked - the target of the plan is changed
author icelus@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 28 Feb 2009 12:15:04 +0000
parents 90005975cdbb
children 6362c6812580
comparison
equal deleted inserted replaced
189:3d0cc4545938 190:f970f7dab2dd
94 typedef std::list<Location> Path; 94 typedef std::list<Location> Path;
95 typedef PriorityQueue<Search*, int> SessionQueue; 95 typedef PriorityQueue<Search*, int> SessionQueue;
96 typedef std::list<int> SessionList; 96 typedef std::list<int> SessionList;
97 typedef std::map<int, Path> PathMap; 97 typedef std::map<int, Path> PathMap;
98 typedef std::map<Layer*, SearchSpace*> SearchSpaceMap; 98 typedef std::map<Layer*, SearchSpace*> SearchSpaceMap;
99 typedef std::map<int, Location> LocationMap;
99 /** Makes the instance follow the given path. 100 /** Makes the instance follow the given path.
100 * 101 *
101 * Calculates the next position the instance should move to given the 102 * Calculates the next position the instance should move to given the
102 * the instance's speed. 103 * the instance's speed.
103 * 104 *
104 * @param instance A pointer to the instance to move. 105 * @param instance A pointer to the instance to move.
105 * @param speed The speed to move the instance. 106 * @param speed The speed to move the instance.
106 * @param nextLocation An out variable which will store the instances next location. 107 * @param nextLocation An out variable which will store the instances next location.
107 * @param facingLocation An out variable which will store the instances facing location. 108 * @param facingLocation An out variable which will store the instances facing location.
109 * @return true if it was possible to follow the path, false if it was not
108 */ 110 */
109 void followPath(const Instance* instance, Path& path, double speed, Location& nextLocation, Location& facingLocation); 111 bool followPath(const Instance* instance, Path& path, double speed, Location& nextLocation, Location& facingLocation);
110 112
111 /** Adds a session id to the session map. 113 /** Adds a session id to the session map.
112 * 114 *
113 * Stores the given session id in the session map. 115 * Stores the given session id in the session map.
114 * 116 *
115 * @param sessionId The session id to store. 117 * @param sessionId The session id to store.
116 */ 118 */
117 void addSessionId(const int sessionId); 119 void addSessionId(const int sessionId);
118 120
119 121 /** Schedules a plan to be created for the given instance to reach the given
122 * target; the session id is where the plan should be stored
123 *
124 * @param instance is the instance to pathfind for
125 * @param target is where the instance is going
126 * @param session_id is which pathfinding slot to put the plan in
127 * @param priority is the priority of the request
128 */
129 void makePlan(const Instance *instance, const Location& target, int session_id, int priority);
130
131 /** make a new session id
132 @return the new session id
133 */
134 int makeSessionId();
135
136 /** are two locations equivalent from the perspective of pathing */
137 bool locationsEqual(const Location &a, const Location &b);
138
139 /** check whether it's safe to continue moving down the path
140 @param instance is the instance following the path
141 @param path is the path to step through
142 @return true if the path could be followed, false if blocked
143 */
144 bool testStep(const Instance *instance, Path& path);
145
120 /** Determines if the given session Id is valid. 146 /** Determines if the given session Id is valid.
121 * 147 *
122 * Searches the session list to determine if a search with the given session id 148 * Searches the session list to determine if a search with the given session id
123 * has been registered. 149 * has been registered.
124 * 150 *
143 SessionList m_registeredSessionIds; 169 SessionList m_registeredSessionIds;
144 170
145 //Calculated paths for the movement phase. 171 //Calculated paths for the movement phase.
146 PathMap m_paths; 172 PathMap m_paths;
147 173
174 //The endpoints for which those paths were calculated
175 LocationMap m_path_targets;
176
148 //A map of searchspaces. 177 //A map of searchspaces.
149 SearchSpaceMap m_searchspaces; 178 SearchSpaceMap m_searchspaces;
150 179
151 //The next free session id. 180 //The next free session id.
152 int m_nextFreeSessionId; 181 int m_nextFreeSessionId;