AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
PlayerTaxi Class Reference

#include "PlayerTaxi.h"

Public Member Functions

 PlayerTaxi ()
 
 ~PlayerTaxi ()=default
 
void InitTaxiNodesForLevel (uint32 race, uint32 chrClass, uint8 level)
 
bool LoadTaxiMask (std::string_view data)
 
bool IsTaximaskNodeKnown (uint32 nodeidx) const
 
bool SetTaximaskNode (uint32 nodeidx)
 
void AppendTaximaskTo (ByteBuffer &data, bool all)
 
bool LoadTaxiDestinationsFromString (std::string const &values, TeamId teamId)
 
std::string SaveTaxiDestinationsToString ()
 
void ClearTaxiDestinations ()
 
void AddTaxiDestination (uint32 dest)
 
uint32 GetTaxiSource () const
 
uint32 GetTaxiDestination () const
 
uint32 GetCurrentTaxiPath () const
 
uint32 NextTaxiDestination ()
 
std::deque< uint32 > const & GetPath () const
 
bool empty () const
 
FactionTemplateEntry const * GetFlightMasterFactionTemplate () const
 
void SetFlightMasterFactionTemplateId (uint32 factionTemplateId)
 

Private Attributes

TaxiMask m_taximask
 
std::deque< uint32m_TaxiDestinations
 
uint32 m_flightMasterFactionId
 

Friends

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

Detailed Description

Constructor & Destructor Documentation

◆ PlayerTaxi()

PlayerTaxi::PlayerTaxi ( )
inline
28: m_flightMasterFactionId(0) { m_taximask.fill(0); }
uint32 m_flightMasterFactionId
Definition: PlayerTaxi.h:82
TaxiMask m_taximask
Definition: PlayerTaxi.h:80

◆ ~PlayerTaxi()

PlayerTaxi::~PlayerTaxi ( )
default

Member Function Documentation

◆ AddTaxiDestination()

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

Referenced by Player::ActivateTaxiPathTo(), Player::LoadFromDB(), LoadTaxiDestinationsFromString(), and Player::ProcessDelayedOperations().

◆ AppendTaximaskTo()

void PlayerTaxi::AppendTaximaskTo ( ByteBuffer data,
bool  all 
)
117{
118 if (all)
119 {
120 for (uint8 i = 0; i < TaxiMaskSize; i++)
121 data << uint32(sTaxiNodesMask[i]); // all existed nodes
122 }
123 else
124 {
125 for (uint8 i = 0; i < TaxiMaskSize; i++)
126 data << uint32(m_taximask[i]); // known nodes
127 }
128}
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
static constexpr std::size_t TaxiMaskSize
Definition: DBCStructure.h:2247
TaxiMask sTaxiNodesMask
Definition: DBCStores.cpp:176

References m_taximask, sTaxiNodesMask, and TaxiMaskSize.

Referenced by WorldSession::SendTaxiMenu().

◆ ClearTaxiDestinations()

◆ empty()

bool PlayerTaxi::empty ( ) const
inline

◆ GetCurrentTaxiPath()

uint32 PlayerTaxi::GetCurrentTaxiPath ( ) const
214{
215 if (m_TaxiDestinations.size() < 2)
216 {
217 return 0;
218 }
219
220 uint32 path;
221 uint32 cost;
222
223 sObjectMgr->GetTaxiPath(m_TaxiDestinations[0], m_TaxiDestinations[1], path, cost);
224
225 return path;
226}
#define sObjectMgr
Definition: ObjectMgr.h:1635

References m_TaxiDestinations, and sObjectMgr.

Referenced by Player::ContinueTaxiFlight().

◆ GetFlightMasterFactionTemplate()

FactionTemplateEntry const * PlayerTaxi::GetFlightMasterFactionTemplate ( ) const
236{
238}
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)

References m_flightMasterFactionId, and sFactionTemplateStore.

Referenced by FlightPathMovementGenerator::LoadPath().

◆ GetPath()

std::deque< uint32 > const & PlayerTaxi::GetPath ( ) const
inline

◆ GetTaxiDestination()

uint32 PlayerTaxi::GetTaxiDestination ( ) const
inline

◆ GetTaxiSource()

uint32 PlayerTaxi::GetTaxiSource ( ) const
inline

◆ InitTaxiNodesForLevel()

void PlayerTaxi::InitTaxiNodesForLevel ( uint32  race,
uint32  chrClass,
uint8  level 
)
24{
25 // class specific initial known nodes
26 switch (chrClass)
27 {
29 {
30 for (uint8 i = 0; i < TaxiMaskSize; ++i)
32 break;
33 }
34 }
35
36 // race specific initial known nodes: capital and taxi hub masks
37 switch (race)
38 {
39 case RACE_HUMAN:
41 break; // Human
42 case RACE_ORC:
44 break; // Orc
45 case RACE_DWARF:
47 break; // Dwarf
48 case RACE_NIGHTELF:
51 break; // Night Elf
54 break;// Undead
55 case RACE_TAUREN:
57 break; // Tauren
58 case RACE_GNOME:
60 break; // Gnome
61 case RACE_TROLL:
63 break; // Troll
64 case RACE_BLOODELF:
66 break; // Blood Elf
67 case RACE_DRAENEI:
69 break; // Draenei
70 }
71
72 // new continent starting masks (It will be accessible only at new map)
73 switch (Player::TeamIdForRace(race))
74 {
75 case TEAM_ALLIANCE:
76 SetTaximaskNode(100);
77 break;
78 case TEAM_HORDE:
80 break;
81 default:
82 break;
83 }
84 // level dependent taxi hubs
85 if (level >= 68)
86 SetTaximaskNode(213); //Shattered Sun Staging Area
87}
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:146
@ RACE_TROLL
Definition: SharedDefines.h:78
@ RACE_UNDEAD_PLAYER
Definition: SharedDefines.h:75
@ RACE_ORC
Definition: SharedDefines.h:72
@ RACE_DRAENEI
Definition: SharedDefines.h:81
@ RACE_NIGHTELF
Definition: SharedDefines.h:74
@ RACE_BLOODELF
Definition: SharedDefines.h:80
@ RACE_DWARF
Definition: SharedDefines.h:73
@ RACE_GNOME
Definition: SharedDefines.h:77
@ RACE_HUMAN
Definition: SharedDefines.h:71
@ RACE_TAUREN
Definition: SharedDefines.h:76
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
TaxiMask sOldContinentsNodesMask
Definition: DBCStores.cpp:177
static TeamId TeamIdForRace(uint8 race)
Definition: Player.cpp:5861
bool SetTaximaskNode(uint32 nodeidx)
Definition: PlayerTaxi.h:42

References CLASS_DEATH_KNIGHT, m_taximask, RACE_BLOODELF, RACE_DRAENEI, RACE_DWARF, RACE_GNOME, RACE_HUMAN, RACE_NIGHTELF, RACE_ORC, RACE_TAUREN, RACE_TROLL, RACE_UNDEAD_PLAYER, SetTaximaskNode(), sOldContinentsNodesMask, TaxiMaskSize, TEAM_ALLIANCE, TEAM_HORDE, and Player::TeamIdForRace().

Referenced by Player::InitTaxiNodesForLevel().

◆ IsTaximaskNodeKnown()

bool PlayerTaxi::IsTaximaskNodeKnown ( uint32  nodeidx) const
inline
36 {
37 uint8 field = uint8((nodeidx - 1) / 32);
38 uint32 submask = 1 << ((nodeidx - 1) % 32);
39 return (m_taximask[field] & submask) == submask;
40 }

Referenced by Player::SendTaxiNodeStatusMultiple(), and WorldSession::SendTaxiStatus().

◆ LoadTaxiDestinationsFromString()

bool PlayerTaxi::LoadTaxiDestinationsFromString ( std::string const &  values,
TeamId  teamId 
)
131{
133
134 std::vector<std::string_view> tokens = Acore::Tokenize(values, ' ', false);
135 auto itr = tokens.begin();
136 if (itr != tokens.end())
137 {
138 if (Optional<uint32> faction = Acore::StringTo<uint32>(*itr))
139 {
140 m_flightMasterFactionId = *faction;
141 }
142 else
143 {
144 return false;
145 }
146 }
147 else
148 return false;
149
150 while ((++itr) != tokens.end())
151 {
152 if (Optional<uint32> node = Acore::StringTo<uint32>(*itr))
153 {
154 AddTaxiDestination(*node);
155 }
156 else
157 {
158 return false;
159 }
160 }
161
162 if (m_TaxiDestinations.empty())
163 {
164 return true;
165 }
166
167 // Check integrity
168 if (m_TaxiDestinations.size() < 2)
169 {
170 return false;
171 }
172
173 for (std::size_t i = 1; i < m_TaxiDestinations.size(); ++i)
174 {
175 uint32 cost;
176 uint32 path;
177 sObjectMgr->GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost);
178 if (!path)
179 {
180 return false;
181 }
182 }
183
184 // can't load taxi path without mount set (quest taxi path?)
185 if (!sObjectMgr->GetTaxiMountDisplayId(GetTaxiSource(), teamId, true))
186 {
187 return false;
188 }
189
190 return true;
191}
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition: Tokenize.cpp:20
void AddTaxiDestination(uint32 dest)
Definition: PlayerTaxi.h:62
uint32 GetTaxiSource() const
Definition: PlayerTaxi.h:63
void ClearTaxiDestinations()
Definition: PlayerTaxi.h:61

References AddTaxiDestination(), ClearTaxiDestinations(), GetTaxiSource(), m_flightMasterFactionId, m_TaxiDestinations, sObjectMgr, and Acore::Tokenize().

Referenced by Player::LoadFromDB().

◆ LoadTaxiMask()

bool PlayerTaxi::LoadTaxiMask ( std::string_view  data)
90{
91 bool warn = false;
92 std::vector<std::string_view> tokens = Acore::Tokenize(data, ' ', false);
93
94 for (uint8 index = 0; (index < TaxiMaskSize) && (index < tokens.size()); ++index)
95 {
96 if (Optional<uint32> mask = Acore::StringTo<uint32>(tokens[index]))
97 {
98 // load and set bits only for existing taxi nodes
99 m_taximask[index] = sTaxiNodesMask[index] & *mask;
100
101 if (m_taximask[index] != *mask)
102 {
103 warn = true;
104 }
105 }
106 else
107 {
108 m_taximask[index] = 0;
109 warn = true;
110 }
111 }
112
113 return !warn;
114}

References m_taximask, sTaxiNodesMask, TaxiMaskSize, and Acore::Tokenize().

Referenced by Player::LoadFromDB().

◆ NextTaxiDestination()

uint32 PlayerTaxi::NextTaxiDestination ( )
inline
67 {
68 m_TaxiDestinations.pop_front();
69 return GetTaxiDestination();
70 }
uint32 GetTaxiDestination() const
Definition: PlayerTaxi.h:64

Referenced by FlightPathMovementGenerator::DoUpdate().

◆ SaveTaxiDestinationsToString()

std::string PlayerTaxi::SaveTaxiDestinationsToString ( )
194{
195 if (m_TaxiDestinations.empty())
196 {
197 return "";
198 }
199
200 ASSERT(m_TaxiDestinations.size() >= 2);
201
202 std::ostringstream ss;
203 ss << m_flightMasterFactionId << ' ';
204
205 for (std::size_t i = 0; i < m_TaxiDestinations.size(); ++i)
206 {
207 ss << m_TaxiDestinations[i] << ' ';
208 }
209
210 return ss.str();
211}
#define ASSERT
Definition: Errors.h:68

References ASSERT, m_flightMasterFactionId, and m_TaxiDestinations.

Referenced by Player::_SaveCharacter().

◆ SetFlightMasterFactionTemplateId()

void PlayerTaxi::SetFlightMasterFactionTemplateId ( uint32  factionTemplateId)
inline
75{ m_flightMasterFactionId = factionTemplateId; }

Referenced by Player::ActivateTaxiPathTo().

◆ SetTaximaskNode()

bool PlayerTaxi::SetTaximaskNode ( uint32  nodeidx)
inline
43 {
44 uint8 field = uint8((nodeidx - 1) / 32);
45 uint32 submask = 1 << ((nodeidx - 1) % 32);
46 if ((m_taximask[field] & submask) != submask)
47 {
48 m_taximask[field] |= submask;
49 return true;
50 }
51 else
52 return false;
53 }

Referenced by InitTaxiNodesForLevel().

Friends And Related Function Documentation

◆ operator<<

std::ostringstream & operator<< ( std::ostringstream &  ss,
PlayerTaxi const &  taxi 
)
friend
229{
230 for (uint8 i = 0; i < TaxiMaskSize; ++i)
231 ss << taxi.m_taximask[i] << ' ';
232 return ss;
233}

Member Data Documentation

◆ m_flightMasterFactionId

uint32 PlayerTaxi::m_flightMasterFactionId
private

◆ m_TaxiDestinations

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

◆ m_taximask

TaxiMask PlayerTaxi::m_taximask
private