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
27class ByteBuffer;
29
31{
32 public:
33 PlayerTaxi() : m_flightMasterFactionId(0) { }
35 // Nodes
36 void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);
37 bool LoadTaxiMask(std::string const& data);
38
39 bool IsTaximaskNodeKnown(uint32 nodeidx) const
40 {
41 uint32 field = uint32((nodeidx - 1) / (sizeof(TaxiMask::value_type) * 8));
42 TaxiMask::value_type submask = TaxiMask::value_type(1 << ((nodeidx - 1) % (sizeof(TaxiMask::value_type) * 8)));
43 return (m_taximask[field] & submask) != 0;
44 }
45 bool SetTaximaskNode(uint32 nodeidx)
46 {
47 uint32 field = uint32((nodeidx - 1) / (sizeof(TaxiMask::value_type) * 8));
48 TaxiMask::value_type submask = TaxiMask::value_type(1 << ((nodeidx - 1) % (sizeof(TaxiMask::value_type) * 8)));
49 if ((m_taximask[field] & submask) == 0)
50 {
51 m_taximask[field] |= submask;
52 return true;
53 }
54 else
55 return false;
56 }
57 void AppendTaximaskTo(ByteBuffer& data, bool all);
58
59 // Destinations
60 [[nodiscard]] bool LoadTaxiDestinationsFromString(std::string const& values, uint32 team);
61 std::string SaveTaxiDestinationsToString();
62
63 void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
64 void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
65 uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); }
66 uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; }
67 uint32 GetCurrentTaxiPath() const;
69 {
70 m_TaxiDestinations.pop_front();
71 return GetTaxiDestination();
72 }
73
74 std::deque<uint32> const& GetPath() const { return m_TaxiDestinations; }
75 bool empty() const { return m_TaxiDestinations.empty(); }
76 FactionTemplateEntry const* GetFlightMasterFactionTemplate() const;
77 void SetFlightMasterFactionTemplateId(uint32 factionTemplateId) { m_flightMasterFactionId = factionTemplateId; }
78
79 friend std::ostringstream& operator<<(std::ostringstream& ss, PlayerTaxi const& taxi);
80 private:
82 std::deque<uint32> m_TaxiDestinations;
84};
85
86std::ostringstream& operator<<(std::ostringstream& ss, PlayerTaxi const& taxi);
87
88#endif // PlayerTaxi_h__
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
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:74
void AddTaxiDestination(uint32 dest)
Definition PlayerTaxi.h:64
void SetFlightMasterFactionTemplateId(uint32 factionTemplateId)
Definition PlayerTaxi.h:77
bool SetTaximaskNode(uint32 nodeidx)
Definition PlayerTaxi.h:45
std::deque< uint32 > m_TaxiDestinations
Definition PlayerTaxi.h:82
uint32 GetTaxiSource() const
Definition PlayerTaxi.h:65
uint32 m_flightMasterFactionId
Definition PlayerTaxi.h:83
bool IsTaximaskNodeKnown(uint32 nodeidx) const
Definition PlayerTaxi.h:39
bool empty() const
Definition PlayerTaxi.h:75
uint32 NextTaxiDestination()
Definition PlayerTaxi.h:68
uint32 GetTaxiDestination() const
Definition PlayerTaxi.h:66
void ClearTaxiDestinations()
Definition PlayerTaxi.h:63
TaxiMask m_taximask
Definition PlayerTaxi.h:81
uint32 value_type
Definition DBCEnums.h:439