Mercurial > fife-parpg
comparison engine/core/pathfinder/routepather/routepathersearch.cpp @ 292:6362c6812580
combine routepathersearch and search class to clean up the code.
author | wenlin_fife@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 26 Jun 2009 18:04:57 +0000 |
parents | 90005975cdbb |
children | 66df2422a8b0 |
comparison
equal
deleted
inserted
replaced
291:89c71d202ab7 | 292:6362c6812580 |
---|---|
38 | 38 |
39 #include "routepathersearch.h" | 39 #include "routepathersearch.h" |
40 | 40 |
41 namespace FIFE { | 41 namespace FIFE { |
42 RoutePatherSearch::RoutePatherSearch(const int session_id, const Location& from, const Location& to, SearchSpace* searchSpace) | 42 RoutePatherSearch::RoutePatherSearch(const int session_id, const Location& from, const Location& to, SearchSpace* searchSpace) |
43 : Search(session_id, from, to, searchSpace), m_destCoordInt(0), m_startCoordInt(0), m_next(0) { | 43 : m_destCoordInt(0), m_startCoordInt(0), m_next(0), m_to(to), m_from(from), m_sessionId(session_id), m_searchspace(searchSpace) { |
44 m_startCoordInt = m_searchspace->convertCoordToInt(from.getLayerCoordinates()); | 44 m_startCoordInt = m_searchspace->convertCoordToInt(from.getLayerCoordinates()); |
45 int max_index = m_searchspace->getMaxIndex(); | 45 int max_index = m_searchspace->getMaxIndex(); |
46 m_destCoordInt = m_searchspace->convertCoordToInt(to.getLayerCoordinates()); | 46 m_destCoordInt = m_searchspace->convertCoordToInt(to.getLayerCoordinates()); |
47 m_sortedfrontier.pushElement(PriorityQueue<int, float>::value_type(m_startCoordInt, 0.0f)); | 47 m_sortedfrontier.pushElement(PriorityQueue<int, float>::value_type(m_startCoordInt, 0.0f)); |
48 m_spt.resize(max_index + 1, -1); | 48 m_spt.resize(max_index + 1, -1); |
49 m_sf.resize(max_index + 1, -1); | 49 m_sf.resize(max_index + 1, -1); |
50 m_gCosts.resize(max_index + 1, 0.0f); | 50 m_gCosts.resize(max_index + 1, 0.0f); |
51 m_heuristic = Heuristic::getHeuristic(searchSpace->getLayer()->getCellGrid()->getType()); | 51 m_heuristic = Heuristic::getHeuristic(searchSpace->getLayer()->getCellGrid()->getType()); |
52 // m_to = to; | |
53 // m_from = from; | |
54 // m_sessionId = session_id; | |
55 // m_searchspace = searchSpace; | |
52 } | 56 } |
53 | 57 |
54 void RoutePatherSearch::updateSearch() { | 58 void RoutePatherSearch::updateSearch() { |
55 if(m_sortedfrontier.empty()) { | 59 if(m_sortedfrontier.empty()) { |
56 setSearchStatus(search_status_failed); | 60 setSearchStatus(search_status_failed); |