FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
routepathersearch.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2019 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 // Standard C++ library includes
23 #include <algorithm>
24 
25 // 3rd party library includes
26 
27 // FIFE includes
28 // These includes are split up in two parts, separated by one empty line
29 // First block: files included from the FIFE root src directory
30 // Second block: files included from the same folder
32 #include "model/structures/layer.h"
34 #include "model/structures/cell.h"
35 #include "pathfinder/route.h"
36 #include "util/math/fife_math.h"
37 
38 #include "routepathersearch.h"
39 
40 namespace FIFE {
41  RoutePatherSearch::RoutePatherSearch(Route* route, const int32_t sessionId):
42  m_route(route),
43  m_multicell(route->isMultiCell()),
44  m_sessionId(sessionId),
45  m_status(search_status_incomplete) {
46 
48  m_specialCost = route->getCostId() != "";
50  if (m_multicell) {
51  Location loc = route->getStartNode();
52  std::vector<ModelCoordinate> coords = route->getOccupiedArea();
53  std::vector<ModelCoordinate>::const_iterator co_it = coords.begin();
54  for (; co_it != coords.end(); ++co_it) {
55  Cell* cell = loc.getLayer()->getCellCache()->getCell(*co_it);
56  if (cell) {
57  m_ignoredBlockers.push_back(cell);
58  }
59  }
60  }
61  }
62 
64  }
65 
67  return m_sessionId;
68  }
69 
71  return m_status;
72  }
73 
75  return m_route;
76  }
77 
79  m_status = status;
80  }
81 }
int32_t getSearchStatus() const
A small function which returns the current status of the search.
Route * getRoute()
Returns the associated route for this search.
void setSearchStatus(const SearchStatus status)
Sets the current status of the search.
Layer * getLayer() const
Gets the layer where this location is pointing to.
Definition: location.cpp:83
const Location & getStartNode()
Returns the start location.
Definition: route.cpp:78
void setRouteStatus(RouteStatusInfo status)
Sets route status.
Definition: route.cpp:57
RoutePatherSearch(Route *route, const int32_t sessionId)
Constructor.
bool m_specialCost
Indicates if the search should use special costs.
SearchStatus
An enumeration of the different status the search can be in.
CellCache * getCellCache()
Returns the CellCache of this layer.
Definition: layer.cpp:573
A basic route.
Definition: route.h:64
Cell * getCell(const ModelCoordinate &mc)
Returns cell on this coordinate.
Definition: cellcache.cpp:704
std::vector< Cell * > m_ignoredBlockers
Blockers from a multi cell object which should be ignored.
bool m_ignoreDynamicBlockers
Indicates if dynamic blockers should be ignored.
bool isDynamicBlockerIgnored()
Gets if the route ignores dynamic blocker.
Definition: route.cpp:298
SearchStatus m_status
An enumeration of the searches current status.
A basic cell on a CellCache.
Definition: cell.h:123
int32_t getSessionId() const
Retrieves the session id.
const std::vector< ModelCoordinate > & getOccupiedArea()
Returns occupied coordinates for multi cell object.
Definition: route.cpp:258
const std::string & getCostId()
Returns cost identifier which is used for pathfinding.
Definition: route.cpp:243
bool m_multicell
Indicates if the route is for a multi cell object.
int32_t m_sessionId
An integer containing the session id for this search.
Route * m_route
Pointer to route.