aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Server/Packets/TradePackets.h
blob: 1f3c028b7445a03fe862eb592e4c25405e45b9eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TRINITYCORE_TRADE_PACKETS_H
#define TRINITYCORE_TRADE_PACKETS_H

#include "Packet.h"
#include "ItemPacketsCommon.h"
#include "ObjectGuid.h"
#include "SharedDefines.h"

namespace WorldPackets
{
    namespace Trade
    {
        class AcceptTrade final : public ClientPacket
        {
        public:
            explicit AcceptTrade(WorldPacket&& packet) : ClientPacket(CMSG_ACCEPT_TRADE, std::move(packet)) { }

            void Read() override;

            uint32 StateIndex = 0;
        };

        class BeginTrade final : public ClientPacket
        {
        public:
            explicit BeginTrade(WorldPacket&& packet) : ClientPacket(CMSG_BEGIN_TRADE, std::move(packet)) { }

            void Read() override { }
        };

        class BusyTrade final : public ClientPacket
        {
        public:
            explicit BusyTrade(WorldPacket&& packet) : ClientPacket(CMSG_BUSY_TRADE, std::move(packet)) { }

            void Read() override { }
        };

        class CancelTrade final : public ClientPacket
        {
        public:
            explicit CancelTrade(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_TRADE, std::move(packet)) { }

            void Read() override { }
        };

        class ClearTradeItem final : public ClientPacket
        {
        public:
            explicit ClearTradeItem(WorldPacket&& packet) : ClientPacket(CMSG_CLEAR_TRADE_ITEM, std::move(packet)) { }

            void Read() override;

            uint8 TradeSlot = 0;
        };

        class IgnoreTrade final : public ClientPacket
        {
        public:
            explicit IgnoreTrade(WorldPacket&& packet) : ClientPacket(CMSG_IGNORE_TRADE, std::move(packet)) { }

            void Read() override { }
        };

        class InitiateTrade final : public ClientPacket
        {
        public:
            explicit InitiateTrade(WorldPacket&& packet) : ClientPacket(CMSG_INITIATE_TRADE, std::move(packet)) { }

            void Read() override;

            ObjectGuid Guid;
        };

        class SetTradeCurrency final : public ClientPacket
        {
        public:
            explicit SetTradeCurrency(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_CURRENCY, std::move(packet)) { }

            void Read() override;

            uint32 Type = 0;
            uint32 Quantity = 0;
        };

        class SetTradeGold final : public ClientPacket
        {
        public:
            explicit SetTradeGold(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_GOLD, std::move(packet)) { }

            void Read() override;

            uint64 Coinage = 0;
        };

        class SetTradeItem final : public ClientPacket
        {
        public:
            explicit SetTradeItem(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_ITEM, std::move(packet)) { }

            void Read() override;

            uint8 TradeSlot = 0;
            uint8 PackSlot = 0;
            uint8 ItemSlotInPack = 0;
        };

        class UnacceptTrade final : public ClientPacket
        {
        public:
            explicit UnacceptTrade(WorldPacket&& packet) : ClientPacket(CMSG_UNACCEPT_TRADE, std::move(packet)) { }

            void Read() override { }
        };

        class TradeStatus final : public ServerPacket
        {
        public:
            explicit TradeStatus() : ServerPacket(SMSG_TRADE_STATUS, 1 + 1 + 16 + 4 + 4 + 1 + 4 + 4 + 4 + 1) { }

            WorldPacket const* Write() override;

            ::TradeStatus Status = TRADE_STATUS_INITIATED;
            uint8 TradeSlot = 0;
            ObjectGuid PartnerAccount;
            ObjectGuid Partner;
            int32 CurrencyType = 0;
            int32 CurrencyQuantity = 0;
            bool FailureForYou = false;
            int32 BagResult = 0;
            uint32 ItemID = 0;
            uint32 ID = 0;
            bool PartnerIsSameBnetAccount = false;
        };

        struct UnwrappedTradeItem
        {
            int32 EnchantID = 0;
            int32 OnUseEnchantmentID = 0;
            ObjectGuid Creator;
            int32 Charges = 0;
            bool Lock = false;
            uint32 MaxDurability = 0;
            uint32 Durability = 0;
            std::vector<Item::ItemGemData> Gems;
        };

        struct TradeItem
        {
            uint8 Slot = 0;
            Item::ItemInstance Item;
            int32 StackCount = 0;
            ObjectGuid GiftCreator;
            Optional<UnwrappedTradeItem> Unwrapped;
        };

        class TradeUpdated final : public ServerPacket
        {
        public:
            explicit TradeUpdated() : ServerPacket(SMSG_TRADE_UPDATED, 8 + 4 + 1 + 4 + 7 * sizeof(UnwrappedTradeItem) + 4 + 4 + 4 + 4) { }

            WorldPacket const* Write() override;

            uint64 Gold = 0;
            uint32 CurrentStateIndex = 0;
            uint8 WhichPlayer = 0;
            uint32 ClientStateIndex = 0;
            std::vector<TradeItem> Items;
            int32 CurrencyType = 0;
            uint32 ID = 0;
            int32 ProposedEnchantment = 0;
            int32 CurrencyQuantity = 0;
        };
    }
}

#endif // TRINITYCORE_TRADE_PACKETS_H