TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TaxiPathGraph.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TAXIPATHGRAPH_HPP
19 #define TAXIPATHGRAPH_HPP
20 
21 #include "Position.h"
22 #include "Define.h"
23 #include <boost/graph/adjacency_list.hpp>
24 
25 class Player;
26 struct TaxiNodesEntry;
27 
29 {
30 public:
31  static TaxiPathGraph& Instance();
32 
33  void Initialize();
34  std::size_t GetCompleteNodeRoute(TaxiNodesEntry const* from, TaxiNodesEntry const* to, Player const* player, std::vector<uint32>& shortestPath);
35 
36 private:
37  struct EdgeCost
38  {
41  uint32 EvaluateDistance(Player const* player) const;
42  };
43  typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::property<boost::vertex_index_t, uint32>, boost::property<boost::edge_weight_t, EdgeCost>> Graph;
44  typedef boost::property_map<Graph, boost::edge_weight_t>::type WeightMap;
45  typedef Graph::vertex_descriptor vertex_descriptor;
46  typedef Graph::edge_descriptor edge_descriptor;
47  typedef std::pair<uint32, uint32> edge;
48 
51 
52  void AddVerticeAndEdgeFromNodeInfo(TaxiNodesEntry const* from, TaxiNodesEntry const* to, uint32 pathId, std::vector<std::pair<edge, EdgeCost>>& edges);
53  vertex_descriptor GetVertexIDFromNodeID(TaxiNodesEntry const* node);
54  uint32 GetNodeIDFromVertexID(vertex_descriptor vertexID);
55  vertex_descriptor CreateVertexFromFromNodeInfoIfNeeded(TaxiNodesEntry const* node);
56  std::size_t GetVertexCount();
57 
58  Graph m_graph;
59  std::vector<TaxiNodesEntry const*> m_vertices;
60 
61  TaxiPathGraph(TaxiPathGraph const&) = delete;
62  TaxiPathGraph& operator=(TaxiPathGraph const&) = delete;
63 };
64 
65 #define sTaxiPathGraph TaxiPathGraph::Instance()
66 
67 #endif /* TAXIPATHGRAPH_HPP */
~TaxiPathGraph()
Definition: TaxiPathGraph.h:50
std::pair< uint32, uint32 > edge
Definition: TaxiPathGraph.h:47
Definition: TaxiPathGraph.h:37
Definition: TaxiPathGraph.h:28
boost::property_map< Graph, boost::edge_weight_t >::type WeightMap
Definition: TaxiPathGraph.h:44
TaxiPathGraph()
Definition: TaxiPathGraph.h:49
std::vector< TaxiNodesEntry const * > m_vertices
Definition: TaxiPathGraph.h:59
Graph::vertex_descriptor vertex_descriptor
Definition: TaxiPathGraph.h:45
Vector2int16 & operator=(const Any &a)
uint32 Distance
Definition: TaxiPathGraph.h:40
uint32_t uint32
Definition: Define.h:150
static void Initialize(PCASC_SALSA20 pState, LPBYTE pbKey, DWORD cbKeyLength, LPBYTE pbVector)
Definition: CascDecrypt.cpp:81
TaxiNodesEntry const * To
Definition: TaxiPathGraph.h:39
#define TC_GAME_API
Definition: Define.h:134
Definition: DB2Structure.h:1324
Graph::edge_descriptor edge_descriptor
Definition: TaxiPathGraph.h:46
boost::adjacency_list< boost::listS, boost::vecS, boost::directedS, boost::property< boost::vertex_index_t, uint32 >, boost::property< boost::edge_weight_t, EdgeCost > > Graph
Definition: TaxiPathGraph.h:43
Graph m_graph
Definition: TaxiPathGraph.h:58