Debian Codegraph @

engine/core/pathfinder/routepather/routepathersearch.cpp

raw
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
31 #include "model/metamodel/grids/cellgrid.h"
32 #include "model/structures/layer.h"
33 #include "model/structures/cellcache.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
47 m_route->setRouteStatus(ROUTE_SEARCHING);
48 m_specialCost = route->getCostId() != "";
49 m_ignoreDynamicBlockers = route->isDynamicBlockerIgnored();
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
63 RoutePatherSearch::~RoutePatherSearch() {
64 }
65
66 int32_t RoutePatherSearch::getSessionId() const {
67 return m_sessionId;
68 }
69
70 int32_t RoutePatherSearch::getSearchStatus() const {
71 return m_status;
72 }
73
74 Route* RoutePatherSearch::getRoute() {
75 return m_route;
76 }
77
78 void RoutePatherSearch::setSearchStatus(const SearchStatus status) {
79 m_status = status;
80 }
81 }