TrinityCore
Loading...
Searching...
No Matches
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:
40 PlayerTaxi(PlayerTaxi const& other);
41 PlayerTaxi(PlayerTaxi&& other) noexcept;
43 PlayerTaxi& operator=(PlayerTaxi&& other) noexcept;
45
46 // Nodes
47 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);
48 bool LoadTaxiMask(std::string const& data);
49
50 bool IsTaximaskNodeKnown(uint32 nodeidx) const
51 {
52 uint32 field = uint32((nodeidx - 1) / (sizeof(TaxiMask::value_type) * 8));
53 TaxiMask::value_type submask = TaxiMask::value_type(1 << ((nodeidx - 1) % (sizeof(TaxiMask::value_type) * 8)));
54 return (m_taximask[field] & submask) != 0;
55 }
56 bool SetTaximaskNode(uint32 nodeidx)
57 {
58 uint32 field = uint32((nodeidx - 1) / (sizeof(TaxiMask::value_type) * 8));
59 TaxiMask::value_type submask = TaxiMask::value_type(1 << ((nodeidx - 1) % (sizeof(TaxiMask::value_type) * 8)));
60 if ((m_taximask[field] & submask) == 0)
61 {
62 m_taximask[field] |= submask;
63 return true;
64 }
65 else
66 return false;
67 }
68 void AppendTaximaskTo(WorldPackets::Taxi::ShowTaxiNodes& data, bool all);
69 TaxiMask const& GetTaxiMask() const { return m_taximask; }
70
71 // Destinations
72 [[nodiscard]] bool LoadTaxiDestinationsFromString(std::string const& values, uint32 team);
73 std::string SaveTaxiDestinationsToString();
74
75 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
76 void AddTaxiDestination(uint32 dest);
77 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
78 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
79 uint32 GetCurrentTaxiPath() const;
81 {
82 m_TaxiDestinations.pop_front();
83 return GetTaxiDestination();
84 }
85 bool RequestEarlyLanding();
86 std::deque<uint32> const& GetPath() const { return m_TaxiDestinations; }
87 bool empty() const { return m_TaxiDestinations.empty(); }
88 FactionTemplateEntry const* GetFlightMasterFactionTemplate() const;
89 void SetFlightMasterFactionTemplateId(uint32 factionTemplateId) { m_flightMasterFactionId = factionTemplateId; }
90
91 friend std::ostringstream& operator<<(std::ostringstream& ss, PlayerTaxi const& taxi);
92 private:
94 std::deque<uint32> m_TaxiDestinations;
95 uint32 m_flightMasterFactionId = 0;
96};
97
98std::ostringstream& operator <<(std::ostringstream& ss, PlayerTaxi const& taxi);
99
100#endif // PlayerTaxi_h__
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
ByteBuffer & operator<<(ByteBuffer &buf, ObjectGuid const &guid)
std::ostringstream & operator<<(std::ostringstream &ss, PlayerTaxi const &taxi)
std::deque< uint32 > const & GetPath() const
Definition PlayerTaxi.h:86
PlayerTaxi(PlayerTaxi const &other)
void SetFlightMasterFactionTemplateId(uint32 factionTemplateId)
Definition PlayerTaxi.h:89
bool SetTaximaskNode(uint32 nodeidx)
Definition PlayerTaxi.h:56
std::deque< uint32 > m_TaxiDestinations
Definition PlayerTaxi.h:94
PlayerTaxi & operator=(PlayerTaxi &&other) noexcept
uint32 GetTaxiSource() const
Definition PlayerTaxi.h:77
PlayerTaxi(PlayerTaxi &&other) noexcept
bool IsTaximaskNodeKnown(uint32 nodeidx) const
Definition PlayerTaxi.h:50
bool empty() const
Definition PlayerTaxi.h:87
uint32 NextTaxiDestination()
Definition PlayerTaxi.h:80
TaxiMask const & GetTaxiMask() const
Definition PlayerTaxi.h:69
uint32 GetTaxiDestination() const
Definition PlayerTaxi.h:78
void ClearTaxiDestinations()
Definition PlayerTaxi.h:75
TaxiMask m_taximask
Definition PlayerTaxi.h:93
PlayerTaxi & operator=(PlayerTaxi const &other)
uint8 value_type
Definition DBCEnums.h:2506