TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PlayerTaxi Class Reference

#include <PlayerTaxi.h>

Public Member Functions

 PlayerTaxi ()
 
 ~PlayerTaxi ()
 
void InitTaxiNodesForLevel (uint32 race, uint32 chrClass, uint8 level)
 
void LoadTaxiMask (std::string const &data)
 
bool IsTaximaskNodeKnown (uint32 nodeidx) const
 
bool SetTaximaskNode (uint32 nodeidx)
 
void AppendTaximaskTo (WorldPackets::Taxi::ShowTaxiNodes &data, bool all)
 
TaxiMask constGetTaxiMask () const
 
bool LoadTaxiDestinationsFromString (std::string const &values, uint32 team)
 
std::string SaveTaxiDestinationsToString ()
 
void ClearTaxiDestinations ()
 
void AddTaxiDestination (uint32 dest)
 
void SetTaxiDestination (std::vector< uint32 > &nodes)
 
uint32 GetTaxiSource () const
 
uint32 GetTaxiDestination () const
 
uint32 GetCurrentTaxiPath () const
 
uint32 NextTaxiDestination ()
 
bool RequestEarlyLanding ()
 
std::deque< uint32 > constGetPath () const
 
bool empty () const
 

Private Attributes

TaxiMask m_taximask
 
std::deque< uint32m_TaxiDestinations
 

Friends

std::ostringstream & operator<< (std::ostringstream &ss, PlayerTaxi const &taxi)
 

Constructor & Destructor Documentation

PlayerTaxi::PlayerTaxi ( )
inline
12 { m_taximask.fill(0); }
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
PlayerTaxi::~PlayerTaxi ( )
inline
13 { }

Member Function Documentation

void PlayerTaxi::AddTaxiDestination ( uint32  dest)
inline
44 { m_TaxiDestinations.push_back(dest); }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61

+ Here is the caller graph for this function:

void PlayerTaxi::AppendTaximaskTo ( WorldPackets::Taxi::ShowTaxiNodes data,
bool  all 
)
92 {
93  if (all)
94  data.Nodes = &sTaxiNodesMask; // all existed nodes
95  else
96  data.Nodes = &m_taximask; // known nodes
97 }
TaxiMask sTaxiNodesMask
Definition: DB2Stores.cpp:134
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
bool all(float x)
Definition: g3dmath.h:431
TaxiMask const * Nodes
Definition: TaxiPackets.h:64
void PlayerTaxi::ClearTaxiDestinations ( )
inline
43 { m_TaxiDestinations.clear(); }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61

+ Here is the caller graph for this function:

bool PlayerTaxi::empty ( ) const
inline
56 { return m_TaxiDestinations.empty(); }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
uint32 PlayerTaxi::GetCurrentTaxiPath ( ) const
148 {
149  if (m_TaxiDestinations.size() < 2)
150  return 0;
151 
152  uint32 path;
153  uint32 cost;
154 
155  sObjectMgr->GetTaxiPath(m_TaxiDestinations[0], m_TaxiDestinations[1], path, cost);
156 
157  return path;
158 }
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32_t uint32
Definition: Define.h:150
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
std::deque<uint32> const& PlayerTaxi::GetPath ( ) const
inline
55 { return m_TaxiDestinations; }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
uint32 PlayerTaxi::GetTaxiDestination ( ) const
inline
47 { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
TaxiMask const& PlayerTaxi::GetTaxiMask ( ) const
inline
37 { return m_taximask; }
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
uint32 PlayerTaxi::GetTaxiSource ( ) const
inline
46 { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61

+ Here is the caller graph for this function:

void PlayerTaxi::InitTaxiNodesForLevel ( uint32  race,
uint32  chrClass,
uint8  level 
)
8 {
9  // class specific initial known nodes
10  TaxiMask const& factionMask = Player::TeamForRace(race) == HORDE ? sHordeTaxiNodesMask : sAllianceTaxiNodesMask;
11  switch (chrClass)
12  {
13  case CLASS_DEATH_KNIGHT:
14  {
15  for (uint8 i = 0; i < TaxiMaskSize; ++i)
16  m_taximask[i] |= sOldContinentsNodesMask[i] & factionMask[i];
17  break;
18  }
19  }
20 
21  // race specific initial known nodes: capital and taxi hub masks
22  switch (race)
23  {
24  case RACE_HUMAN:
25  case RACE_DWARF:
26  case RACE_NIGHTELF:
27  case RACE_GNOME:
28  case RACE_DRAENEI:
29  case RACE_WORGEN:
31  SetTaximaskNode(2); // Stormwind, Elwynn
32  SetTaximaskNode(6); // Ironforge, Dun Morogh
33  SetTaximaskNode(26); // Lor'danel, Darkshore
34  SetTaximaskNode(27); // Rut'theran Village, Teldrassil
35  SetTaximaskNode(49); // Moonglade (Alliance)
36  SetTaximaskNode(94); // The Exodar
37  SetTaximaskNode(456); // Dolanaar, Teldrassil
38  SetTaximaskNode(457); // Darnassus, Teldrassil
39  SetTaximaskNode(582); // Goldshire, Elwynn
40  SetTaximaskNode(589); // Eastvale Logging Camp, Elwynn
41  SetTaximaskNode(619); // Kharanos, Dun Morogh
42  SetTaximaskNode(620); // Gol'Bolar Quarry, Dun Morogh
43  SetTaximaskNode(624); // Azure Watch, Azuremyst Isle
44  break;
45  case RACE_ORC:
46  case RACE_UNDEAD_PLAYER:
47  case RACE_TAUREN:
48  case RACE_TROLL:
49  case RACE_BLOODELF:
50  case RACE_GOBLIN:
52  SetTaximaskNode(11); // Undercity, Tirisfal
53  SetTaximaskNode(22); // Thunder Bluff, Mulgore
54  SetTaximaskNode(23); // Orgrimmar, Durotar
55  SetTaximaskNode(69); // Moonglade (Horde)
56  SetTaximaskNode(82); // Silvermoon City
57  SetTaximaskNode(384); // The Bulwark, Tirisfal
58  SetTaximaskNode(402); // Bloodhoof Village, Mulgore
59  SetTaximaskNode(460); // Brill, Tirisfal Glades
60  SetTaximaskNode(536); // Sen'jin Village, Durotar
61  SetTaximaskNode(537); // Razor Hill, Durotar
62  SetTaximaskNode(625); // Fairbreeze Village, Eversong Woods
63  SetTaximaskNode(631); // Falconwing Square, Eversong Woods
64  break;
65  }
66 
67  // new continent starting masks (It will be accessible only at new map)
68  switch (Player::TeamForRace(race))
69  {
70  case ALLIANCE: SetTaximaskNode(100); break;
71  case HORDE: SetTaximaskNode(99); break;
72  }
73 
74  // level dependent taxi hubs
75  if (level >= 68)
76  SetTaximaskNode(213); //Shattered Sun Staging Area
77 }
Definition: SharedDefines.h:110
TaxiMask sOldContinentsNodesMask
Definition: DB2Stores.cpp:135
bool SetTaximaskNode(uint32 nodeidx)
Definition: PlayerTaxi.h:24
Definition: SharedDefines.h:172
Definition: SharedDefines.h:105
#define TaxiMaskSize
Definition: DB2Structure.h:1452
Definition: SharedDefines.h:126
TaxiMask sHordeTaxiNodesMask
Definition: DB2Stores.cpp:136
Definition: SharedDefines.h:112
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
Definition: SharedDefines.h:108
Definition: SharedDefines.h:107
Definition: SharedDefines.h:1000
Definition: SharedDefines.h:106
Definition: SharedDefines.h:104
TaxiMask sAllianceTaxiNodesMask
Definition: DB2Stores.cpp:137
Definition: SharedDefines.h:123
Definition: SharedDefines.h:102
std::array< uint8, TaxiMaskSize > TaxiMask
Definition: DB2Structure.h:1453
Definition: SharedDefines.h:999
Definition: SharedDefines.h:103
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:109
Definition: SharedDefines.h:127
Definition: SharedDefines.h:111

+ Here is the call graph for this function:

bool PlayerTaxi::IsTaximaskNodeKnown ( uint32  nodeidx) const
inline
19  {
20  uint8 field = uint8((nodeidx - 1) / 8);
21  uint32 submask = 1 << ((nodeidx-1) % 8);
22  return (m_taximask[field] & submask) == submask;
23  }
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
uint32_t uint32
Definition: Define.h:150
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152

+ Here is the caller graph for this function:

bool PlayerTaxi::LoadTaxiDestinationsFromString ( std::string const values,
uint32  team 
)
100 {
102 
103  Tokenizer tokens(values, ' ');
104 
105  for (Tokenizer::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter)
106  {
107  uint32 node = atoul(*iter);
108  AddTaxiDestination(node);
109  }
110 
111  if (m_TaxiDestinations.empty())
112  return true;
113 
114  // Check integrity
115  if (m_TaxiDestinations.size() < 2)
116  return false;
117 
118  for (size_t i = 1; i < m_TaxiDestinations.size(); ++i)
119  {
120  uint32 cost;
121  uint32 path;
122  sObjectMgr->GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost);
123  if (!path)
124  return false;
125  }
126 
127  // can't load taxi path without mount set (quest taxi path?)
128  if (!sObjectMgr->GetTaxiMountDisplayId(GetTaxiSource(), team, true))
129  return false;
130 
131  return true;
132 }
Definition: Util.h:45
uint32 GetTaxiSource() const
Definition: PlayerTaxi.h:46
void AddTaxiDestination(uint32 dest)
Definition: PlayerTaxi.h:44
#define sObjectMgr
Definition: ObjectMgr.h:1567
void ClearTaxiDestinations()
Definition: PlayerTaxi.h:43
StorageType::const_iterator const_iterator
Definition: Util.h:52
unsigned long atoul(char const *str)
Definition: Common.h:90
uint32_t uint32
Definition: Define.h:150
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61

+ Here is the call graph for this function:

void PlayerTaxi::LoadTaxiMask ( std::string const data)
80 {
81  Tokenizer tokens(data, ' ');
82 
83  uint8 index = 0;
84  for (Tokenizer::const_iterator iter = tokens.begin(); index < TaxiMaskSize && iter != tokens.end(); ++iter, ++index)
85  {
86  // load and set bits only for existing taxi nodes
87  m_taximask[index] = sTaxiNodesMask[index] & atoul(*iter);
88  }
89 }
#define TaxiMaskSize
Definition: DB2Structure.h:1452
TaxiMask sTaxiNodesMask
Definition: DB2Stores.cpp:134
Definition: Util.h:45
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
StorageType::const_iterator const_iterator
Definition: Util.h:52
unsigned long atoul(char const *str)
Definition: Common.h:90
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

uint32 PlayerTaxi::NextTaxiDestination ( )
inline
50  {
51  m_TaxiDestinations.pop_front();
52  return GetTaxiDestination();
53  }
uint32 GetTaxiDestination() const
Definition: PlayerTaxi.h:47
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
bool PlayerTaxi::RequestEarlyLanding ( )
168 {
169  if (m_TaxiDestinations.size() <= 2)
170  return false;
171 
172  // start from first destination - m_TaxiDestinations[0] is the current starting node
173  for (std::deque<uint32>::iterator it = ++m_TaxiDestinations.begin(); it != m_TaxiDestinations.end(); ++it)
174  {
175  if (IsTaximaskNodeKnown(*it))
176  {
177  if (++it == m_TaxiDestinations.end())
178  return false; // if we are left with only 1 known node on the path don't change the spline, its our final destination anyway
179 
180  m_TaxiDestinations.erase(it, m_TaxiDestinations.end());
181  return true;
182  }
183  }
184 
185  return false;
186 }
bool IsTaximaskNodeKnown(uint32 nodeidx) const
Definition: PlayerTaxi.h:18
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61

+ Here is the call graph for this function:

std::string PlayerTaxi::SaveTaxiDestinationsToString ( )
135 {
136  if (m_TaxiDestinations.empty())
137  return "";
138 
139  std::ostringstream ss;
140 
141  for (size_t i = 0; i < m_TaxiDestinations.size(); ++i)
142  ss << m_TaxiDestinations[i] << ' ';
143 
144  return ss.str();
145 }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
void PlayerTaxi::SetTaxiDestination ( std::vector< uint32 > &  nodes)
inline
45 { m_TaxiDestinations.clear(); m_TaxiDestinations.insert(m_TaxiDestinations.begin(), nodes.begin(), nodes.end()); }
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:61
bool PlayerTaxi::SetTaximaskNode ( uint32  nodeidx)
inline
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  }
TaxiMask m_taximask
Definition: PlayerTaxi.h:60
uint32_t uint32
Definition: Define.h:150
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152

+ Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostringstream& operator<< ( std::ostringstream &  ss,
PlayerTaxi const taxi 
)
friend
161 {
162  for (uint8 i = 0; i < TaxiMaskSize; ++i)
163  ss << uint32(taxi.m_taximask[i]) << ' ';
164  return ss;
165 }
#define TaxiMaskSize
Definition: DB2Structure.h:1452
uint8_t uint8
Definition: Define.h:152
uint32_t uint32
Definition: g3dmath.h:168

Member Data Documentation

std::deque<uint32> PlayerTaxi::m_TaxiDestinations
private
TaxiMask PlayerTaxi::m_taximask
private

The documentation for this class was generated from the following files: