TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PlayerTaxi.h
Go to the documentation of this file.
1 #ifndef __PLAYERTAXI_H__
2 #define __PLAYERTAXI_H__
3 
4 #include "DB2Stores.h"
5 #include "Define.h"
6 #include "WorldSession.h"
7 #include <map>
8 
10 {
11  public:
12  PlayerTaxi() { m_taximask.fill(0); }
14  // Nodes
15  void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);
16  void LoadTaxiMask(std::string const& data);
17 
18  bool IsTaximaskNodeKnown(uint32 nodeidx) const
19  {
20  uint8 field = uint8((nodeidx - 1) / 8);
21  uint32 submask = 1 << ((nodeidx-1) % 8);
22  return (m_taximask[field] & submask) == submask;
23  }
24  bool SetTaximaskNode(uint32 nodeidx)
25  {
26  uint8 field = uint8((nodeidx - 1) / 8);
27  uint32 submask = 1 << ((nodeidx- 1) % 8);
28  if ((m_taximask[field] & submask) != submask)
29  {
30  m_taximask[field] |= submask;
31  return true;
32  }
33  else
34  return false;
35  }
36  void AppendTaximaskTo(WorldPackets::Taxi::ShowTaxiNodes& data, bool all);
37  TaxiMask const& GetTaxiMask() const { return m_taximask; }
38 
39  // Destinations
40  bool LoadTaxiDestinationsFromString(std::string const& values, uint32 team);
41  std::string SaveTaxiDestinationsToString();
42 
43  void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
44  void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
45  void SetTaxiDestination(std::vector<uint32>& nodes) { m_TaxiDestinations.clear(); m_TaxiDestinations.insert(m_TaxiDestinations.begin(), nodes.begin(), nodes.end()); }
46  uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
47  uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
48  uint32 GetCurrentTaxiPath() const;
50  {
51  m_TaxiDestinations.pop_front();
52  return GetTaxiDestination();
53  }
54  bool RequestEarlyLanding();
55  std::deque<uint32> const& GetPath() const { return m_TaxiDestinations; }
56  bool empty() const { return m_TaxiDestinations.empty(); }
57 
58  friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
59  private:
61  std::deque<uint32> m_TaxiDestinations;
62 };
63 
64 std::ostringstream& operator << (std::ostringstream& ss, PlayerTaxi const& taxi);
65 
66 #endif
uint32 NextTaxiDestination()
Definition: PlayerTaxi.h:49
std::deque< uint32 > const & GetPath() const
Definition: PlayerTaxi.h:55
bool SetTaximaskNode(uint32 nodeidx)
Definition: PlayerTaxi.h:24
~PlayerTaxi()
Definition: PlayerTaxi.h:13
uint32 GetTaxiSource() const
Definition: PlayerTaxi.h:46
void AddTaxiDestination(uint32 dest)
Definition: PlayerTaxi.h:44
TaxiMask const & GetTaxiMask() const
Definition: PlayerTaxi.h:37
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
bool empty() const
Definition: PlayerTaxi.h:56
Definition: TaxiPackets.h:56
bool all(float x)
Definition: g3dmath.h:431
void ClearTaxiDestinations()
Definition: PlayerTaxi.h:43
void SetTaxiDestination(std::vector< uint32 > &nodes)
Definition: PlayerTaxi.h:45
std::ostringstream & operator<<(std::ostringstream &ss, PlayerTaxi const &taxi)
Definition: PlayerTaxi.cpp:160
uint32 GetTaxiDestination() const
Definition: PlayerTaxi.h:47
uint32_t uint32
Definition: Define.h:150
bool IsTaximaskNodeKnown(uint32 nodeidx) const
Definition: PlayerTaxi.h:18
std::array< uint8, TaxiMaskSize > TaxiMask
Definition: DB2Structure.h:1453
uint8_t uint8
Definition: g3dmath.h:164
Definition: PlayerTaxi.h:9
#define TC_GAME_API
Definition: Define.h:134
uint8_t uint8
Definition: Define.h:152
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
PlayerTaxi()
Definition: PlayerTaxi.h:12