TrinityCore
Loading...
Searching...
No Matches
TradeData.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 TradeData_h__
19
#define TradeData_h__
20
21
#include "
ObjectGuid.h
"
22
23
enum
TradeSlots
24
{
25
TRADE_SLOT_COUNT
= 7,
26
TRADE_SLOT_TRADED_COUNT
= 6,
27
TRADE_SLOT_NONTRADED
= 6,
28
TRADE_SLOT_INVALID
= -1
29
};
30
31
class
Item
;
32
class
Player
;
33
34
class
TC_GAME_API
TradeData
35
{
36
public
:
37
TradeData
(
Player
* player,
Player
* trader) :
38
_player(player), _trader(trader), _accepted(false), _acceptProccess(false),
39
_money(0), _spell(0), _spellCastItem(), _clientStateIndex(1), _serverStateIndex(1) { }
40
41
Player
*
GetTrader
()
const
{
return
_trader; }
42
TradeData
* GetTraderData()
const
;
43
44
Item
* GetItem(
TradeSlots
slot)
const
;
45
bool
HasItem(
ObjectGuid
itemGuid)
const
;
46
TradeSlots
GetTradeSlotForItem(
ObjectGuid
itemGuid)
const
;
47
void
SetItem(
TradeSlots
slot,
Item
* item,
bool
update =
false
);
48
49
uint32
GetSpell
()
const
{
return
_spell; }
50
void
SetSpell(
uint32
spell_id,
Item
* castItem =
nullptr
);
51
52
Item
* GetSpellCastItem()
const
;
53
bool
HasSpellCastItem
()
const
{
return
!_spellCastItem.IsEmpty(); }
54
55
uint64
GetMoney
()
const
{
return
_money; }
56
void
SetMoney(
uint64
money);
57
58
bool
IsAccepted
()
const
{
return
_accepted; }
59
void
SetAccepted(
bool
state,
bool
forTrader =
false
);
60
61
bool
IsInAcceptProcess
()
const
{
return
_acceptProccess; }
62
void
SetInAcceptProcess
(
bool
state) { _acceptProccess = state; }
63
64
uint32
GetClientStateIndex
()
const
{
return
_clientStateIndex; }
65
void
UpdateClientStateIndex
() { ++_clientStateIndex; }
66
67
uint32
GetServerStateIndex
()
const
{
return
_serverStateIndex; }
68
void
UpdateServerStateIndex();
69
70
private
:
71
void
Update(
bool
for_trader =
true
)
const
;
72
73
Player
*
_player
;
// Player who own of this TradeData
74
Player
*
_trader
;
// Player who trade with _player
75
76
bool
_accepted
;
// _player press accept for trade list
77
bool
_acceptProccess
;
// one from player/trader press accept and this processed
78
79
uint64
_money
;
// _player place money to trade
80
81
uint32
_spell
;
// _player apply spell to non-traded slot item
82
ObjectGuid
_spellCastItem
;
// applied spell cast by item use
83
84
ObjectGuid
_items[
TRADE_SLOT_COUNT
];
// traded items from _player side including non-traded slot
85
86
uint32
_clientStateIndex
;
87
uint32
_serverStateIndex
;
88
};
89
90
#endif
// TradeData_h__
TC_GAME_API
#define TC_GAME_API
Definition
Define.h:129
uint64
uint64_t uint64
Definition
Define.h:153
uint32
uint32_t uint32
Definition
Define.h:154
ObjectGuid.h
TradeSlots
TradeSlots
Definition
TradeData.h:24
TRADE_SLOT_COUNT
@ TRADE_SLOT_COUNT
Definition
TradeData.h:25
TRADE_SLOT_TRADED_COUNT
@ TRADE_SLOT_TRADED_COUNT
Definition
TradeData.h:26
TRADE_SLOT_INVALID
@ TRADE_SLOT_INVALID
Definition
TradeData.h:28
TRADE_SLOT_NONTRADED
@ TRADE_SLOT_NONTRADED
Definition
TradeData.h:27
Item
Definition
Item.h:179
ObjectGuid
Definition
ObjectGuid.h:308
Player
Definition
Player.h:1233
TradeData
Definition
TradeData.h:35
TradeData::HasSpellCastItem
bool HasSpellCastItem() const
Definition
TradeData.h:53
TradeData::_acceptProccess
bool _acceptProccess
Definition
TradeData.h:77
TradeData::GetTrader
Player * GetTrader() const
Definition
TradeData.h:41
TradeData::_serverStateIndex
uint32 _serverStateIndex
Definition
TradeData.h:87
TradeData::GetClientStateIndex
uint32 GetClientStateIndex() const
Definition
TradeData.h:64
TradeData::SetInAcceptProcess
void SetInAcceptProcess(bool state)
Definition
TradeData.h:62
TradeData::_player
Player * _player
Definition
TradeData.h:73
TradeData::UpdateClientStateIndex
void UpdateClientStateIndex()
Definition
TradeData.h:65
TradeData::_clientStateIndex
uint32 _clientStateIndex
Definition
TradeData.h:86
TradeData::IsAccepted
bool IsAccepted() const
Definition
TradeData.h:58
TradeData::GetMoney
uint64 GetMoney() const
Definition
TradeData.h:55
TradeData::_accepted
bool _accepted
Definition
TradeData.h:76
TradeData::GetSpell
uint32 GetSpell() const
Definition
TradeData.h:49
TradeData::_spellCastItem
ObjectGuid _spellCastItem
Definition
TradeData.h:82
TradeData::IsInAcceptProcess
bool IsInAcceptProcess() const
Definition
TradeData.h:61
TradeData::TradeData
TradeData(Player *player, Player *trader)
Definition
TradeData.h:37
TradeData::GetServerStateIndex
uint32 GetServerStateIndex() const
Definition
TradeData.h:67
TradeData::_spell
uint32 _spell
Definition
TradeData.h:81
TradeData::_money
uint64 _money
Definition
TradeData.h:79
TradeData::_trader
Player * _trader
Definition
TradeData.h:74
server
game
Entities
Player
TradeData.h
Generated on Sun May 10 2026 02:08:58 for TrinityCore by
1.9.8