TrinityCore
PlayerTaxi.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
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 PlayerTaxi_h__
19#define PlayerTaxi_h__
20
21#include "DBCEnums.h"
22#include "Define.h"
23#include <deque>
24#include <iosfwd>
25#include <string>
26
28namespace WorldPackets
29{
30 namespace Taxi
31 {
32 class ShowTaxiNodes;
33 }
34}
35
37{
38 public:
39 PlayerTaxi() : m_flightMasterFactionId(0) { }
41 // Nodes
42 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);
43 bool LoadTaxiMask(std::string const& data);
44
45 bool IsTaximaskNodeKnown(uint32 nodeidx) const
46 {
47 uint32 field = uint32((nodeidx - 1) / 8);
48 uint32 submask = 1 << ((nodeidx-1) % 8);
49 return (m_taximask[field] & submask) == submask;
50 }
51 bool SetTaximaskNode(uint32 nodeidx)
52 {
53 uint32 field = uint32((nodeidx - 1) / 8);
54 uint32 submask = 1 << ((nodeidx- 1) % 8);
55 if ((m_taximask[field] & submask) != submask)
56 {
57 m_taximask[field] |= submask;
58 return true;
59 }
60 else
61 return false;
62 }
63 void AppendTaximaskTo(WorldPackets::Taxi::ShowTaxiNodes& data, bool all);
64 TaxiMask const& GetTaxiMask() const { return m_taximask; }
65
66 // Destinations
67 [[nodiscard]] bool LoadTaxiDestinationsFromString(std::string const& values, uint32 team);
68 std::string SaveTaxiDestinationsToString();
69
70 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
71 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
72 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
73 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
74 uint32 GetCurrentTaxiPath() const;
76 {
77 m_TaxiDestinations.pop_front();
78 return GetTaxiDestination();
79 }
80 bool RequestEarlyLanding();
81 std::deque<uint32> const& GetPath() const { return m_TaxiDestinations; }
82 bool empty() const { return m_TaxiDestinations.empty(); }
83 FactionTemplateEntry const* GetFlightMasterFactionTemplate() const;
84 void SetFlightMasterFactionTemplateId(uint32 factionTemplateId) { m_flightMasterFactionId = factionTemplateId; }
85
86 friend std::ostringstream& operator<<(std::ostringstream& ss, PlayerTaxi const& taxi);
87 private:
89 std::deque<uint32> m_TaxiDestinations;
91};
92
93std::ostringstream& operator <<(std::ostringstream& ss, PlayerTaxi const& taxi);
94
95#endif // PlayerTaxi_h__
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
std::ostringstream & operator<<(std::ostringstream &ss, PlayerTaxi const &taxi)
Definition: PlayerTaxi.cpp:212
std::deque< uint32 > const & GetPath() const
Definition: PlayerTaxi.h:81
void AddTaxiDestination(uint32 dest)
Definition: PlayerTaxi.h:71
void SetFlightMasterFactionTemplateId(uint32 factionTemplateId)
Definition: PlayerTaxi.h:84
bool SetTaximaskNode(uint32 nodeidx)
Definition: PlayerTaxi.h:51
std::deque< uint32 > m_TaxiDestinations
Definition: PlayerTaxi.h:89
uint32 GetTaxiSource() const
Definition: PlayerTaxi.h:72
uint32 m_flightMasterFactionId
Definition: PlayerTaxi.h:90
bool IsTaximaskNodeKnown(uint32 nodeidx) const
Definition: PlayerTaxi.h:45
bool empty() const
Definition: PlayerTaxi.h:82
uint32 NextTaxiDestination()
Definition: PlayerTaxi.h:75
TaxiMask const & GetTaxiMask() const
Definition: PlayerTaxi.h:64
uint32 GetTaxiDestination() const
Definition: PlayerTaxi.h:73
void ClearTaxiDestinations()
Definition: PlayerTaxi.h:70
TaxiMask m_taximask
Definition: PlayerTaxi.h:88