| 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 |
#ifndef FIFE_PATHFINDER_ROUTEPATHERSEARCH |
| 23 |
#define FIFE_PATHFINDER_ROUTEPATHERSEARCH |
| 24 |
|
| 25 |
// Standard C++ library includes |
| 26 |
|
| 27 |
// 3rd party library includes |
| 28 |
|
| 29 |
// FIFE includes |
| 30 |
// These includes are split up in two parts, separated by one empty line |
| 31 |
// First block: files included from the FIFE root src directory |
| 32 |
// Second block: files included from the same folder |
| 33 |
#include "util/structures/priorityqueue.h" |
| 34 |
|
| 35 |
namespace FIFE { |
| 36 |
|
| 37 |
class CellCache; |
| 38 |
class Route; |
| 39 |
|
| 40 |
/** RoutePatherSearch using A* |
| 41 |
* |
| 42 |
*/ |
| 43 |
class RoutePatherSearch { |
| 44 |
public: |
| 45 |
/** Constructor |
| 46 |
* |
| 47 |
* @param route A pointer to the route for which a path should be searched. |
| 48 |
* @param sessionId A integer containing the session id for this search. |
| 49 |
*/ |
| 50 |
RoutePatherSearch(Route* route, const int32_t sessionId); |
| 51 |
|
| 52 |
virtual ~RoutePatherSearch(); |
| 53 |
|
| 54 |
/** An enumeration of the different status the search can be in. |
| 55 |
* |
| 56 |
*/ |
| 57 |
enum SearchStatus { |
| 58 |
search_status_failed, |
| 59 |
search_status_complete, |
| 60 |
search_status_incomplete |
| 61 |
}; |
| 62 |
|
| 63 |
/** Updates the search. |
| 64 |
* |
| 65 |
* Each update checks all neighbors of the last checked coordinate and selects the most favorable. |
| 66 |
*/ |
| 67 |
virtual void updateSearch() = 0; |
| 68 |
|
| 69 |
/** Calculates final path. |
| 70 |
* |
| 71 |
* If the search is successful then a path is created. |
| 72 |
*/ |
| 73 |
virtual void calcPath() = 0; |
| 74 |
|
| 75 |
/** Retrieves the session id. |
| 76 |
* |
| 77 |
* @return The searches session id in the pather. |
| 78 |
*/ |
| 79 |
int32_t getSessionId() const; |
| 80 |
|
| 81 |
/** A small function which returns the current status of the search. |
| 82 |
* |
| 83 |
* @return An integer value representing the status, which is enumerated by this class. |
| 84 |
*/ |
| 85 |
int32_t getSearchStatus() const; |
| 86 |
|
| 87 |
/** Returns the associated route for this search. |
| 88 |
* |
| 89 |
* @return A pointer to the route. |
| 90 |
*/ |
| 91 |
Route* getRoute(); |
| 92 |
|
| 93 |
protected: |
| 94 |
/** Sets the current status of the search. |
| 95 |
* |
| 96 |
* @param status The status to set. |
| 97 |
* @see SearchStatus |
| 98 |
*/ |
| 99 |
void setSearchStatus(const SearchStatus status); |
| 100 |
|
| 101 |
//! Pointer to route |
| 102 |
Route* m_route; |
| 103 |
|
| 104 |
//! Indicates if the search should use special costs. |
| 105 |
bool m_specialCost; |
| 106 |
|
| 107 |
//! Indicates if the route is for a multi cell object. |
| 108 |
bool m_multicell; |
| 109 |
|
| 110 |
//! Indicates if dynamic blockers should be ignored. |
| 111 |
bool m_ignoreDynamicBlockers; |
| 112 |
|
| 113 |
//! Blockers from a multi cell object which should be ignored. |
| 114 |
std::vector<Cell*> m_ignoredBlockers; |
| 115 |
|
| 116 |
private: |
| 117 |
//! An integer containing the session id for this search. |
| 118 |
int32_t m_sessionId; |
| 119 |
|
| 120 |
//! An enumeration of the searches current status. |
| 121 |
SearchStatus m_status; |
| 122 |
}; |
| 123 |
} |
| 124 |
#endif |