Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
PlayerTaxi.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Player.h"
7#include "PlayerTaxi.h"
8
9// == PlayerTaxi ================================================
10
12{
13 memset(m_taximask, 0, sizeof(m_taximask));
14}
15
23
25{
26 // class specific initial known nodes
27 switch (chrClass)
28 {
30 {
31 for (uint8 i = 0; i < TaxiMaskSize; ++i)
33 break;
34 }
35 }
36}
37
39{
40 // race specific initial known nodes: capital and taxi hub masks
41 switch (Player::TeamForRace(race))
42 {
43 case ALLIANCE:
44 SetTaximaskNode(2); // Stormwind, Elwynn
45 SetTaximaskNode(582); // Goldshire, Elwynn
46 SetTaximaskNode(589); // Eastvale Logging Camp, Elwynn
47 SetTaximaskNode(6); // Ironforge, Dun Morogh
48 SetTaximaskNode(619); // Kharanos, Dun Morogh
49 SetTaximaskNode(620); // Gol'Bolar Quarry, Dun Morogh
50 SetTaximaskNode(26); // Lor'danel, Darkshore
51 SetTaximaskNode(456); // Dolanaar, Teldrassil
52 SetTaximaskNode(457); // Darnassus, Teldrassil
53 SetTaximaskNode(94); // The Exodar
54 SetTaximaskNode(624); // Azure Watch, Azuremyst Isle
55 SetTaximaskNode(49); // Moonglade
56 SetTaximaskNode(100); // Honor Hold, Hellfire Peninsula
57 break;
58 case HORDE:
59 SetTaximaskNode(23); // Orgrimmar, Durotar
60 SetTaximaskNode(536); // Sen'jin Village, Durotar
61 SetTaximaskNode(537); // Razor Hill, Durotar
62 SetTaximaskNode(11); // Undercity, Tirisfal
63 SetTaximaskNode(384); // The Bulwark, Tirisfal
64 SetTaximaskNode(460); // Brill, Tirisfal Glades
65 SetTaximaskNode(22); // Thunder Bluff, Mulgore
66 SetTaximaskNode(402); // Bloodhoof Village, Mulgore
67 SetTaximaskNode(82); // Silvermoon City
68 SetTaximaskNode(625); // Fairbreeze Village, Eversong Woods
69 SetTaximaskNode(631); // Falconwing Square, Eversong Woods
70 SetTaximaskNode(99); // Thrallmar, Hellfire Peninsula
71 break;
72 }
73 SetTaximaskNode(128); // Shattrath, Terokkar Forest
74 SetTaximaskNode(310); // Dalaran
76
78{
79 // new continent starting masks (It will be accessible only at new map)
80 switch (faction)
81 {
82 case ALLIANCE: SetTaximaskNode(100); break;
83 case HORDE: SetTaximaskNode(99); break;
84 }
85}
86
88{
89 // level dependent taxi hubs
90 if (level >= 68)
91 SetTaximaskNode(213); //Shattered Sun Staging Area
92}
93
94void PlayerTaxi::LoadTaxiMask(std::string const& data)
95{
96 Tokenizer tokens(data, ' ');
97
98 uint8 index = 0;
99 for (Tokenizer::const_iterator iter = tokens.begin(); index < TaxiMaskSize && iter != tokens.end(); ++iter, ++index)
100 {
101 // load and set bits only for existing taxi nodes
102 m_taximask[index] = sTaxiNodesMask[index] & uint32(atol(*iter));
103 }
104}
105
107{
108 if (all)
109 {
110 for (uint8 i = 0; i < TaxiMaskSize; ++i)
111 data << uint8(sTaxiNodesMask[i]); // all existed nodes
112 }
113 else
114 {
115 for (uint8 i = 0; i < TaxiMaskSize; ++i)
116 data << uint8(m_taximask[i]); // known nodes
117 }
118}
119
120bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, uint32 team)
121{
123
124 Tokenizer Tokenizer(values, ' ');
125
126 for (Tokenizer::const_iterator iter = Tokenizer.begin(); iter != Tokenizer.end(); ++iter)
127 {
128 uint32 node = uint32(atol(*iter));
129 AddTaxiDestination(node);
130 }
131
132 if (m_TaxiDestinations.empty())
133 return true;
134
135 // Check integrity
136 if (m_TaxiDestinations.size() < 2)
137 return false;
138
139 for (size_t i = 1; i < m_TaxiDestinations.size(); ++i)
140 {
141 uint32 cost;
142 uint32 path;
143 sObjectMgr->GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost);
144 if (!path)
145 return false;
146 }
147
148 // can't load taxi path without mount set (quest taxi path?)
149 if (!sObjectMgr->GetTaxiMountDisplayId(GetTaxiSource(), team, true))
150 return false;
151
152 return true;
153}
154
156{
157 if (m_TaxiDestinations.empty())
158 return "";
159
160 std::ostringstream ss;
161
162 for (size_t i = 0; i < m_TaxiDestinations.size(); ++i)
163 ss << m_TaxiDestinations[i] << ' ';
164
165 return ss.str();
166}
167
169{
170 if (m_TaxiDestinations.size() < 2)
171 return 0;
172
173 uint32 path;
174 uint32 cost;
175
176 sObjectMgr->GetTaxiPath(m_TaxiDestinations[0], m_TaxiDestinations[1], path, cost);
177
178 return path;
179}
180
181std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
182{
183 for (uint8 i = 0; i < TaxiMaskSize; ++i)
184 ss << uint32(taxi.m_taximask[i]) << ' ';
185 return ss;
186}
TaxiMask sTaxiNodesMask
TaxiMask sOldContinentsNodesMask
#define TaxiMaskSize
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define sObjectMgr
Definition ObjectMgr.h:1617
std::ostringstream & operator<<(std::ostringstream &ss, PlayerTaxi const &taxi)
@ CLASS_DEATH_KNIGHT
@ ALLIANCE
@ HORDE
static uint32 TeamForRace(uint8 race)
Definition Player.cpp:7072
std::string SaveTaxiDestinationsToString()
void InitTaxiNodesForRace(uint32 race)
void AddTaxiDestination(uint32 dest)
Definition PlayerTaxi.h:52
void InitTaxiNodes(uint32 race, uint32 chrClass, uint8 level)
bool SetTaximaskNode(uint32 nodeidx)
Definition PlayerTaxi.h:30
std::deque< uint32 > m_TaxiDestinations
Definition PlayerTaxi.h:78
uint32 GetTaxiSource() const
Definition PlayerTaxi.h:56
void InitTaxiNodesForClass(uint32 chrClass)
bool LoadTaxiDestinationsFromString(std::string const &values, uint32 team)
void LoadTaxiMask(std::string const &data)
void InitTaxiNodesForLvl(uint8 level)
void AppendTaximaskTo(ByteBuffer &data, bool all)
void ClearTaxiDestinations()
Definition PlayerTaxi.h:48
TaxiMask m_taximask
Definition PlayerTaxi.h:77
uint32 GetCurrentTaxiPath() const
void InitTaxiNodesForFaction(uint32 faction)
StorageType::const_iterator const_iterator
Definition Util.h:35
const_iterator end() const
Definition Util.h:44
const_iterator begin() const
Definition Util.h:43