|
1 | | -/** |
2 | | - * MaNGOS is a full featured server for World of Warcraft, supporting |
3 | | - * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 |
4 | | - * |
5 | | - * Copyright (C) 2005-2025 MaNGOS <https://www.getmangos.eu> |
6 | | - * |
7 | | - * This program is free software; you can redistribute it and/or modify |
8 | | - * it under the terms of the GNU General Public License as published by |
9 | | - * the Free Software Foundation; either version 2 of the License, or |
10 | | - * (at your option) any later version. |
11 | | - * |
12 | | - * This program is distributed in the hope that it will be useful, |
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | - * GNU General Public License for more details. |
16 | | - * |
17 | | - * You should have received a copy of the GNU General Public License |
18 | | - * along with this program; if not, write to the Free Software |
19 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | | - * |
21 | | - * World of Warcraft, and all World of Warcraft or Warcraft art, images, |
22 | | - * and lore are copyrighted by Blizzard Entertainment, Inc. |
23 | | - */ |
24 | | - |
25 | | -#ifndef PLAYERTAXI_H |
26 | | -#define PLAYERTAXI_H |
27 | | - |
28 | | -#include "Player.h" |
29 | | - |
30 | | -#include "Common.h" |
31 | | -#include "DBCEnums.h" |
32 | | - |
33 | | -class ByteBuffer; |
34 | | -struct FactionTemplateEntry; |
35 | | - |
36 | | -class PlayerTaxi |
37 | | -{ |
38 | | - public: |
39 | | - PlayerTaxi() : m_flightMasterFactionId(0) { memset(m_taximask, 0, sizeof(m_taximask)); } |
40 | | - ~PlayerTaxi() { } |
41 | | - |
42 | | - // Nodes |
43 | | - void InitTaxiNodes(uint32 race, uint32 chrClass, uint8 level); |
44 | | - void InitTaxiNodesForClass(uint32 chrClass); |
45 | | - void InitTaxiNodesForRace(uint32 race); |
46 | | - void InitTaxiNodesForFaction(uint32 faction); |
47 | | - void InitTaxiNodesForLvl(uint8 level); |
48 | | - |
49 | | - void LoadTaxiMask(const char* data); |
50 | | - |
51 | | - bool IsTaximaskNodeKnown(uint32 nodeidx) const |
52 | | - { |
53 | | - uint8 field = uint8((nodeidx - 1) / 8); |
54 | | - uint8 submask = 1 << ((nodeidx - 1) % 8); |
55 | | - return (m_taximask[field] & submask) == submask; |
56 | | - } |
57 | | - |
58 | | - bool SetTaximaskNode(uint32 nodeidx) |
59 | | - { |
60 | | - uint8 field = uint8((nodeidx - 1) / 8); |
61 | | - uint8 submask = 1 << ((nodeidx - 1) % 8); |
62 | | - if ((m_taximask[field] & submask) != submask) |
63 | | - { |
64 | | - m_taximask[field] |= submask; |
65 | | - return true; |
66 | | - } |
67 | | - else |
68 | | - { |
69 | | - return false; |
70 | | - } |
71 | | - } |
72 | | - |
73 | | - void AppendTaximaskTo(ByteBuffer& data, bool all); |
74 | | - |
75 | | - // Destinations |
76 | | - bool LoadTaxiDestinationsFromString(const std::string& values, Team team); |
77 | | - std::string SaveTaxiDestinationsToString(); |
78 | | - |
79 | | - void ClearTaxiDestinations() |
80 | | - { |
81 | | - m_TaxiDestinations.clear(); |
82 | | - } |
83 | | - |
84 | | - void AddTaxiDestination(uint32 dest) |
85 | | - { |
86 | | - m_TaxiDestinations.push_back(dest); |
87 | | - } |
88 | | - |
89 | | - uint32 GetTaxiSource() const |
90 | | - { |
91 | | - return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); |
92 | | - } |
93 | | - |
94 | | - uint32 GetTaxiDestination() const |
95 | | - { |
96 | | - return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; |
97 | | - } |
98 | | - |
99 | | - uint32 GetCurrentTaxiPath() const; |
100 | | - |
101 | | - uint32 NextTaxiDestination() |
102 | | - { |
103 | | - m_TaxiDestinations.pop_front(); |
104 | | - return GetTaxiDestination(); |
105 | | - } |
106 | | - |
107 | | - bool empty() const |
108 | | - { |
109 | | - return m_TaxiDestinations.empty(); |
110 | | - } |
111 | | - |
112 | | - FactionTemplateEntry const* GetFlightMasterFactionTemplate() const; |
113 | | - void SetFlightMasterFactionTemplateId(uint32 factionTemplateId) |
114 | | - { |
115 | | - m_flightMasterFactionId = factionTemplateId; |
116 | | - } |
117 | | - |
118 | | - friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi); |
119 | | - |
120 | | - private: |
121 | | - TaxiMask m_taximask; |
122 | | - std::deque<uint32> m_TaxiDestinations; |
123 | | - uint32 m_flightMasterFactionId; |
124 | | -}; |
125 | | - |
126 | | -std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi); |
127 | | - |
128 | | -#endif |
| 1 | +/** |
| 2 | + * MaNGOS is a full featured server for World of Warcraft, supporting |
| 3 | + * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 |
| 4 | + * |
| 5 | + * Copyright (C) 2005-2025 MaNGOS <https://www.getmangos.eu> |
| 6 | + * |
| 7 | + * This program is free software; you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation; either version 2 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program; if not, write to the Free Software |
| 19 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | + * |
| 21 | + * World of Warcraft, and all World of Warcraft or Warcraft art, images, |
| 22 | + * and lore are copyrighted by Blizzard Entertainment, Inc. |
| 23 | + */ |
| 24 | + |
| 25 | +#ifndef PLAYERTAXI_H |
| 26 | +#define PLAYERTAXI_H |
| 27 | + |
| 28 | +#include "Common.h" |
| 29 | +#include "DBCEnums.h" |
| 30 | + |
| 31 | +class ByteBuffer; |
| 32 | +struct FactionTemplateEntry; |
| 33 | + |
| 34 | +class Player; // forward declaration |
| 35 | + |
| 36 | +class PlayerTaxi |
| 37 | +{ |
| 38 | + public: |
| 39 | + PlayerTaxi() : m_flightMasterFactionId(0) { memset(m_taximask, 0, sizeof(m_taximask)); } |
| 40 | + ~PlayerTaxi() { } |
| 41 | + |
| 42 | + // Nodes |
| 43 | + void InitTaxiNodes(uint32 race, uint32 chrClass, uint8 level); |
| 44 | + void InitTaxiNodesForClass(uint32 chrClass); |
| 45 | + void InitTaxiNodesForRace(uint32 race); |
| 46 | + void InitTaxiNodesForFaction(uint32 faction); |
| 47 | + void InitTaxiNodesForLvl(uint8 level); |
| 48 | + |
| 49 | + void LoadTaxiMask(const char* data); |
| 50 | + |
| 51 | + bool IsTaximaskNodeKnown(uint32 nodeidx) const |
| 52 | + { |
| 53 | + uint8 field = uint8((nodeidx - 1) / 8); |
| 54 | + uint8 submask = 1 << ((nodeidx - 1) % 8); |
| 55 | + return (m_taximask[field] & submask) == submask; |
| 56 | + } |
| 57 | + |
| 58 | + bool SetTaximaskNode(uint32 nodeidx) |
| 59 | + { |
| 60 | + uint8 field = uint8((nodeidx - 1) / 8); |
| 61 | + uint8 submask = 1 << ((nodeidx - 1) % 8); |
| 62 | + if ((m_taximask[field] & submask) != submask) |
| 63 | + { |
| 64 | + m_taximask[field] |= submask; |
| 65 | + return true; |
| 66 | + } |
| 67 | + else |
| 68 | + { |
| 69 | + return false; |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + void AppendTaximaskTo(ByteBuffer& data, bool all); |
| 74 | + |
| 75 | + // Destinations |
| 76 | + bool LoadTaxiDestinationsFromString(const std::string& values, Team team); |
| 77 | + std::string SaveTaxiDestinationsToString(); |
| 78 | + |
| 79 | + void ClearTaxiDestinations() |
| 80 | + { |
| 81 | + m_TaxiDestinations.clear(); |
| 82 | + } |
| 83 | + |
| 84 | + void AddTaxiDestination(uint32 dest) |
| 85 | + { |
| 86 | + m_TaxiDestinations.push_back(dest); |
| 87 | + } |
| 88 | + |
| 89 | + uint32 GetTaxiSource() const |
| 90 | + { |
| 91 | + return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); |
| 92 | + } |
| 93 | + |
| 94 | + uint32 GetTaxiDestination() const |
| 95 | + { |
| 96 | + return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; |
| 97 | + } |
| 98 | + |
| 99 | + uint32 GetCurrentTaxiPath() const; |
| 100 | + |
| 101 | + uint32 NextTaxiDestination() |
| 102 | + { |
| 103 | + m_TaxiDestinations.pop_front(); |
| 104 | + return GetTaxiDestination(); |
| 105 | + } |
| 106 | + |
| 107 | + bool empty() const |
| 108 | + { |
| 109 | + return m_TaxiDestinations.empty(); |
| 110 | + } |
| 111 | + |
| 112 | + FactionTemplateEntry const* GetFlightMasterFactionTemplate() const; |
| 113 | + void SetFlightMasterFactionTemplateId(uint32 factionTemplateId) |
| 114 | + { |
| 115 | + m_flightMasterFactionId = factionTemplateId; |
| 116 | + } |
| 117 | + |
| 118 | + friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi); |
| 119 | + |
| 120 | + private: |
| 121 | + TaxiMask m_taximask; |
| 122 | + std::deque<uint32> m_TaxiDestinations; |
| 123 | + uint32 m_flightMasterFactionId; |
| 124 | +}; |
| 125 | + |
| 126 | +std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi); |
| 127 | + |
| 128 | +#endif |
0 commit comments