TrinityCore
Loading...
Searching...
No Matches
CraftingPacketsCommon.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
19#include "PacketOperators.h"
20
22{
24{
25 data.ResetBitPos();
26 data >> OptionalInit(reagent.ItemID);
27 data >> OptionalInit(reagent.CurrencyID);
28
29 if (reagent.ItemID)
30 data >> *reagent.ItemID;
31
32 if (reagent.CurrencyID)
33 data >> *reagent.CurrencyID;
34
35 return data;
36}
37
39{
40 data << OptionalInit(reagent.ItemID);
41 data << OptionalInit(reagent.CurrencyID);
42 data.FlushBits();
43
44 if (reagent.ItemID)
45 data << int32(*reagent.ItemID);
46
47 if (reagent.CurrencyID)
48 data << int32(*reagent.CurrencyID);
49
50 return data;
51}
52
53ByteBuffer& operator<<(ByteBuffer& data, SpellReducedReagent const& spellReducedReagent)
54{
55 data << int32(spellReducedReagent.Quantity);
56 data << spellReducedReagent.Reagent;
57
58 return data;
59}
60
61ByteBuffer& operator<<(ByteBuffer& data, CraftingData const& craftingData)
62{
63 data << int32(craftingData.CraftingQualityID);
64 data << float(craftingData.QualityProgress);
65 data << int32(craftingData.SkillLineAbilityID);
66 data << int32(craftingData.CraftingDataID);
67 data << int32(craftingData.Multicraft);
68 data << int32(craftingData.SkillFromReagents);
69 data << int32(craftingData.Skill);
70 data << int32(craftingData.CritBonusSkill);
71 data << float(craftingData.ModSkillGain);
72 data << uint64(craftingData.OrderID);
73 data << Size<uint32>(craftingData.ResourcesReturned);
74 data << uint32(craftingData.OperationID);
75 data << craftingData.ItemGUID;
76 data << int32(craftingData.Quantity);
77 data << int32(craftingData.EnchantID);
78 data << int32(craftingData.ConcentrationCurrencyID);
79 data << int32(craftingData.ConcentrationSpent);
80 data << int32(craftingData.IngenuityRefund);
81
82 data << Bits<1>(craftingData.IsCrit);
83 data << Bits<1>(craftingData.IsRecraft);
84 data << Bits<1>(craftingData.IsInitialRecraft);
85 data << Bits<1>(craftingData.IsFirstCraft);
86 data << Bits<1>(craftingData.HasIngenuityProc);
87 data << Bits<1>(craftingData.ApplyConcentration);
88 data.FlushBits();
89
90 data << craftingData.OldItem;
91 data << craftingData.NewItem;
92
93 for (SpellReducedReagent const& spellReducedReagent : craftingData.ResourcesReturned)
94 data << spellReducedReagent;
95
96 return data;
97}
98}
int32_t int32
Definition Define.h:150
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
void ResetBitPos()
Definition ByteBuffer.h:152
void FlushBits()
Definition ByteBuffer.h:141
ByteBuffer & operator<<(ByteBuffer &data, CraftingReagentBase const &reagent)
ByteBuffer & operator>>(ByteBuffer &data, CraftingReagentBase &reagent)
OptionalInitWriter< T > OptionalInit(Optional< T > const &value)
std::vector< SpellReducedReagent > ResourcesReturned