TrinityCore
Loading...
Searching...
No Matches
QueryPackets.cpp
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#include "QueryPackets.h"
19
25
27{
28 _worldPacket << uint32(CreatureID | (Allow ? 0x00000000 : 0x80000000)); // creature entry
29
30 if (Allow)
31 {
32 _worldPacket << Stats.Name;
33 _worldPacket << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
34 _worldPacket << Stats.Title;
35 _worldPacket << Stats.CursorName; // "Directions" for guard, string for Icons 2.3.0
36 _worldPacket << uint32(Stats.Flags); // flags
37 _worldPacket << uint32(Stats.CreatureType); // CreatureType.dbc
38 _worldPacket << uint32(Stats.CreatureFamily); // CreatureFamily.dbc
39 _worldPacket << uint32(Stats.Classification); // Creature Rank (elite, boss, etc)
40 _worldPacket.append(Stats.ProxyCreatureID, MAX_KILL_CREDIT); // new in 3.1, kill credit
41 _worldPacket.append(Stats.CreatureDisplayID, MAX_CREATURE_MODELS); // Modelid
42 _worldPacket << float(Stats.HpMulti); // dmg/hp modifier
43 _worldPacket << float(Stats.EnergyMulti); // dmg/mana modifier
44 _worldPacket << uint8(Stats.Leader);
45 _worldPacket.append(Stats.QuestItems, MAX_CREATURE_QUEST_ITEMS);
46 _worldPacket << uint32(Stats.CreatureMovementInfoID); // CreatureMovementInfo.dbc
47 }
48
49 return &_worldPacket;
50}
51
53{
54 _worldPacket >> Player;
55}
56
58{
59 data << lookupData.Name;
60 data << lookupData.RealmName;
61 data << uint8(lookupData.Race);
62 data << uint8(lookupData.Sex);
63 data << uint8(lookupData.ClassID);
64 data << uint8(lookupData.DeclinedNames != nullptr);
65
66 if (lookupData.DeclinedNames)
67 for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
68 data << lookupData.DeclinedNames->name[i];
69
70 return data;
71}
72
74{
75 _worldPacket << Player.WriteAsPacked();
76 _worldPacket << uint8(Result);
77
78 if (Data)
79 _worldPacket << *Data;
80
81 return &_worldPacket;
82}
83
85{
86 _worldPacket >> PageTextID;
87 _worldPacket >> ItemGUID;
88}
89
91{
92 data << page.Text;
93 data << uint32(page.NextPageID);
94
95 return data;
96}
97
99{
100 _worldPacket << uint32(PageTextID | (Allow ? 0x00000000 : 0x80000000));
101
102 if (Allow)
103 _worldPacket << Page;
104
105 return &_worldPacket;
106}
107
109{
110 _worldPacket >> TextID;
111 _worldPacket >> Guid;
112}
113
115{
116 _worldPacket << uint32(TextID | (Allow ? 0x00000000 : 0x80000000));
117
118 if (Allow)
119 {
120 for (NPCText const& option : Options)
121 {
122 _worldPacket << float(option.Probability);
123 _worldPacket << option.Text;
124 _worldPacket << option.Text1;
125 _worldPacket << int32(option.LanguageID);
126 for (std::size_t i = 0; i < MAX_GOSSIP_TEXT_EMOTES; ++i)
127 {
128 _worldPacket << uint32(option.EmoteDelay[i]);
129 _worldPacket << uint32(option.EmoteID[i]);
130 }
131 }
132 }
133
134 return &_worldPacket;
135}
136
138{
139 _worldPacket >> GameObjectID;
140 _worldPacket >> Guid;
141}
142
144{
145 _worldPacket << uint32(GameObjectID | (Allow ? 0x00000000 : 0x80000000));
146
147 if (Allow)
148 {
149 _worldPacket << uint32(Stats.Type);
150 _worldPacket << uint32(Stats.DisplayID);
151 _worldPacket << Stats.Name;
152 _worldPacket << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4
153 _worldPacket << Stats.IconName; // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword)
154 _worldPacket << Stats.CastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting")
155 _worldPacket << Stats.UnkString; // 2.0.3, string
156 _worldPacket.append(Stats.Data, MAX_GAMEOBJECT_DATA);
157 _worldPacket << float(Stats.Size); // go size
158 _worldPacket.append(Stats.QuestItems, MAX_GAMEOBJECT_QUEST_ITEMS);
159 }
160
161 return &_worldPacket;
162}
163
165{
166 _worldPacket << uint8(Valid);
167
168 if (Valid)
169 {
170 _worldPacket << int32(MapID);
171 _worldPacket << Position;
172 _worldPacket << int32(ActualMapID);
173 _worldPacket << uint32(Transport);
174 }
175
176 return &_worldPacket;
177}
178
180{
181 _worldPacket >> Transport;
182}
183
185{
186 _worldPacket << Position;
187 _worldPacket << float(Facing);
188
189 return &_worldPacket;
190}
191
193{
194 _worldPacket << uint32(CurrentTime);
195 _worldPacket << int32(TimeOutRequest);
196
197 return &_worldPacket;
198}
199
201{
202 _worldPacket >> ItemID;
203}
204
206{
207 _worldPacket << uint32(ItemID | (Allow ? 0x00000000 : 0x80000000));
208
209 if (Allow)
210 {
211 _worldPacket << Stats.Class;
212 _worldPacket << Stats.SubClass;
213 _worldPacket << Stats.SoundOverrideSubclass;
214 _worldPacket << Stats.Name;
215 _worldPacket << uint8(0x00); //Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name...
216 _worldPacket << uint8(0x00); //Name3; // blizz not send name there, just uint8(0x00);
217 _worldPacket << uint8(0x00); //Name4; // blizz not send name there, just uint8(0x00);
218 _worldPacket << Stats.DisplayInfoID;
219 _worldPacket << Stats.Quality;
220 _worldPacket.append(Stats.Flags.data(), Stats.Flags.size());
221 _worldPacket << Stats.BuyPrice;
222 _worldPacket << Stats.SellPrice;
223 _worldPacket << Stats.InventoryType;
224 _worldPacket << Stats.AllowableClass;
225 _worldPacket << Stats.AllowableRace;
226 _worldPacket << Stats.ItemLevel;
227 _worldPacket << Stats.RequiredLevel;
228 _worldPacket << Stats.RequiredSkill;
229 _worldPacket << Stats.RequiredSkillRank;
230 _worldPacket << Stats.RequiredSpell;
231 _worldPacket << Stats.RequiredHonorRank;
232 _worldPacket << Stats.RequiredCityRank;
233 _worldPacket << Stats.RequiredReputationFaction;
234 _worldPacket << Stats.RequiredReputationRank;
235 _worldPacket << int32(Stats.MaxCount);
236 _worldPacket << int32(Stats.Stackable);
237 _worldPacket << Stats.ContainerSlots;
238 _worldPacket << Stats.StatsCount; // item stats count
239 for (uint32 i = 0; i < Stats.StatsCount; ++i)
240 {
241 _worldPacket << Stats.ItemStat[i].ItemStatType;
242 _worldPacket << Stats.ItemStat[i].ItemStatValue;
243 }
244 _worldPacket << Stats.ScalingStatDistribution; // scaling stats distribution
245 _worldPacket << Stats.ScalingStatValue; // some kind of flags used to determine stat values column
246 for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
247 {
248 _worldPacket << Stats.Damage[i].DamageMin;
249 _worldPacket << Stats.Damage[i].DamageMax;
250 _worldPacket << Stats.Damage[i].DamageType;
251 }
252
253 // resistances (7)
255 _worldPacket << Stats.Resistance[i];
256
257 _worldPacket << Stats.Delay;
258 _worldPacket << Stats.AmmoType;
259 _worldPacket << Stats.RangedModRange;
260
261 for (uint8 s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s)
262 {
263 // spells are validated on template loading
264 if (Stats.Spells[s].SpellId > 0)
265 {
266 _worldPacket << Stats.Spells[s].SpellId;
267 _worldPacket << Stats.Spells[s].SpellTrigger;
268 _worldPacket << int32(Stats.Spells[s].SpellCharges);
269 _worldPacket << uint32(Stats.Spells[s].SpellCooldown);
270 _worldPacket << uint32(Stats.Spells[s].SpellCategory);
271 _worldPacket << uint32(Stats.Spells[s].SpellCategoryCooldown);
272 }
273 else
274 {
275 _worldPacket << uint32(0);
276 _worldPacket << uint32(0);
277 _worldPacket << uint32(0);
278 _worldPacket << uint32(-1);
279 _worldPacket << uint32(0);
280 _worldPacket << uint32(-1);
281 }
282 }
283 _worldPacket << Stats.Bonding;
284 _worldPacket << Stats.Description;
285 _worldPacket << Stats.PageText;
286 _worldPacket << Stats.LanguageID;
287 _worldPacket << Stats.PageMaterial;
288 _worldPacket << Stats.StartQuest;
289 _worldPacket << Stats.LockID;
290 _worldPacket << int32(Stats.Material);
291 _worldPacket << Stats.Sheath;
292 _worldPacket << Stats.RandomProperty;
293 _worldPacket << Stats.RandomSuffix;
294 _worldPacket << Stats.Block;
295 _worldPacket << Stats.ItemSet;
296 _worldPacket << Stats.MaxDurability;
297 _worldPacket << Stats.Area;
298 _worldPacket << Stats.Map; // Added in 1.12.x & 2.0.1 client branch
299 _worldPacket << Stats.BagFamily;
300 _worldPacket << Stats.TotemCategory;
301 for (uint8 s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s)
302 {
303 _worldPacket << Stats.Socket[s].Color;
304 _worldPacket << Stats.Socket[s].Content;
305 }
306 _worldPacket << Stats.SocketBonus;
307 _worldPacket << Stats.GemProperties;
308 _worldPacket << Stats.RequiredDisenchantSkill;
309 _worldPacket << Stats.ArmorDamageModifier;
310 _worldPacket << Stats.Duration; // added in 2.4.2.8209, duration (seconds)
311 _worldPacket << Stats.ItemLimitCategory; // WotLK, ItemLimitCategory
312 _worldPacket << Stats.HolidayId; // Holiday.dbc?
313 }
314
315 return &_worldPacket;
316}
317
319{
320 _worldPacket >> MissingQuestCount; // quest count, max=25
321
322 if (MissingQuestCount <= MAX_QUEST_LOG_SIZE)
323 {
324 for (uint8 i = 0; i < MissingQuestCount; ++i)
325 _worldPacket >> MissingQuestPOIs[i];
326 }
327
328 _worldPacket.rfinish();
329}
static const uint32 MAX_CREATURE_QUEST_ITEMS
static const uint8 MAX_KILL_CREDIT
static const uint32 MAX_CREATURE_MODELS
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
#define MAX_GAMEOBJECT_QUEST_ITEMS
#define MAX_ITEM_PROTO_SOCKETS
#define MAX_ITEM_PROTO_DAMAGES
#define MAX_ITEM_PROTO_SPELLS
#define MAX_GOSSIP_TEXT_EMOTES
Definition NPCHandler.h:27
ByteBuffer & operator<<(ByteBuffer &buf, ObjectGuid const &guid)
#define MAX_QUEST_LOG_SIZE
Definition QuestDef.h:36
@ SPELL_SCHOOL_NORMAL
@ MAX_SPELL_SCHOOL
#define MAX_GAMEOBJECT_DATA
Stats
#define MAX_DECLINED_NAME_CASES
Data
WorldPacket _worldPacket
Definition Packet.h:42
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
std::string name[MAX_DECLINED_NAME_CASES]