Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
DB2Utility.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
DB2Utility.h
"
7
#include "
ObjectMgr.h
"
8
9
inline
bool
ItemExists
(
uint32
id
)
10
{
11
return
sObjectMgr
->GetItemTemplate(
id
) != NULL;
12
}
13
14
bool
DB2Utilities::HasItemEntry
(
DB2Storage<ItemEntry>
const
&
/*store*/
,
uint32
id
)
15
{
16
return
ItemExists
(
id
);
17
}
18
19
bool
DB2Utilities::HasItemSparseEntry
(
DB2Storage<ItemSparseEntry>
const
&
/*store*/
,
uint32
id
)
20
{
21
return
ItemExists
(
id
);
22
}
23
24
void
DB2Utilities::WriteItemDbReply
(
DB2Storage<ItemEntry>
const
&
/*store*/
,
uint32
id
,
uint32
/*locale*/
,
ByteBuffer
& buffer)
25
{
26
ItemTemplate
const
* proto =
sObjectMgr
->GetItemTemplate(
id
);
27
ASSERT
(proto);
28
29
buffer <<
uint32
(proto->
ItemId
);
30
buffer <<
uint32
(proto->
Class
);
31
buffer <<
uint32
(proto->
SubClass
);
32
buffer <<
int32
(proto->
SoundOverrideSubclass
);
33
buffer <<
uint32
(proto->
Material
);
34
buffer <<
uint32
(proto->
DisplayInfoID
);
35
buffer <<
uint32
(proto->
InventoryType
);
36
buffer <<
uint32
(proto->
Sheath
);
37
}
38
39
void
DB2Utilities::WriteItemSparseDbReply
(
DB2Storage<ItemSparseEntry>
const
&
/*store*/
,
uint32
id
,
uint32
locale,
ByteBuffer
& buffer)
40
{
41
ItemTemplate
const
* proto =
sObjectMgr
->GetItemTemplate(
id
);
42
ASSERT
(proto);
43
44
ItemLocale
const
* localeData = locale ?
sObjectMgr
->GetItemLocale(
id
) : NULL;
45
46
buffer <<
uint32
(proto->
ItemId
);
47
buffer <<
uint32
(proto->
Quality
);
48
buffer <<
uint32
(proto->
Flags
);
49
buffer <<
uint32
(proto->
Flags2
);
50
buffer <<
uint32
(proto->
Flags3
);
51
buffer << float(proto->
Unk430_1
);
52
buffer << float(proto->
Unk430_2
);
53
buffer <<
uint32
(proto->
BuyCount
);
54
buffer <<
int32
(proto->
BuyPrice
);
55
buffer <<
uint32
(proto->
SellPrice
);
56
buffer <<
uint32
(proto->
InventoryType
);
57
buffer <<
int32
(proto->
AllowableClass
);
58
buffer <<
int32
(proto->
AllowableRace
);
59
buffer <<
uint32
(proto->
ItemLevel
);
60
buffer <<
uint32
(proto->
RequiredLevel
);
61
buffer <<
uint32
(proto->
RequiredSkill
);
62
buffer <<
uint32
(proto->
RequiredSkillRank
);
63
buffer <<
uint32
(proto->
RequiredSpell
);
64
buffer <<
uint32
(proto->
RequiredHonorRank
);
65
buffer <<
uint32
(proto->
RequiredCityRank
);
66
buffer <<
uint32
(proto->
RequiredReputationFaction
);
67
buffer <<
uint32
(proto->
RequiredReputationRank
);
68
buffer <<
int32
(proto->
MaxCount
);
69
buffer <<
int32
(proto->
Stackable
);
70
buffer <<
uint32
(proto->
ContainerSlots
);
71
72
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_STATS
; ++x)
73
buffer <<
uint32
(proto->
ItemStat
[x].
ItemStatType
);
74
75
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_STATS
; ++x)
76
buffer <<
int32
(proto->
ItemStat
[x].
ItemStatValue
);
77
78
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_STATS
; ++x)
79
buffer <<
int32
(proto->
ItemStat
[x].
ItemStatUnk1
);
80
81
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_STATS
; ++x)
82
buffer <<
int32
(proto->
ItemStat
[x].
ItemStatUnk2
);
83
84
buffer <<
uint32
(proto->
ScalingStatDistribution
);
85
buffer <<
uint32
(proto->
DamageType
);
86
buffer <<
uint32
(proto->
Delay
);
87
buffer << float(proto->
RangedModRange
);
88
89
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SPELLS
; ++x)
90
buffer <<
int32
(proto->
Spells
[x].
SpellId
);
91
92
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SPELLS
; ++x)
93
buffer <<
uint32
(proto->
Spells
[x].
SpellTrigger
);
94
95
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SPELLS
; ++x)
96
buffer <<
int32
(proto->
Spells
[x].
SpellCharges
);
97
98
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SPELLS
; ++x)
99
buffer <<
int32
(proto->
Spells
[x].
SpellCooldown
);
100
101
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SPELLS
; ++x)
102
buffer <<
uint32
(proto->
Spells
[x].
SpellCategory
);
103
104
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SPELLS
; ++x)
105
buffer <<
int32
(proto->
Spells
[x].
SpellCategoryCooldown
);
106
107
buffer <<
uint32
(proto->
Bonding
);
108
109
// item name
110
std::string name = proto->
Name1
;
111
if
(localeData)
112
ObjectMgr::GetLocaleString
(localeData->
Name
, locale, name);
113
114
buffer <<
uint16
(name.length());
115
if
(name.length())
116
buffer << name;
117
118
for
(
uint32
i = 0; i < 3; ++i)
// other 3 names
119
buffer <<
uint16
(0);
120
121
std::string desc = proto->
Description
;
122
if
(localeData)
123
ObjectMgr::GetLocaleString
(localeData->
Description
, locale, desc);
124
125
buffer <<
uint16
(desc.length());
126
if
(desc.length())
127
buffer << desc;
128
129
buffer <<
uint32
(proto->
PageText
);
130
buffer <<
uint32
(proto->
LanguageID
);
131
buffer <<
uint32
(proto->
PageMaterial
);
132
buffer <<
uint32
(proto->
StartQuest
);
133
buffer <<
uint32
(proto->
LockID
);
134
buffer <<
int32
(proto->
Material
);
135
buffer <<
uint32
(proto->
Sheath
);
136
buffer <<
int32
(proto->
RandomProperty
);
137
buffer <<
int32
(proto->
RandomSuffix
);
138
buffer <<
uint32
(proto->
ItemSet
);
139
140
buffer <<
uint32
(proto->
Area
);
141
buffer <<
uint32
(proto->
Map
);
142
buffer <<
uint32
(proto->
BagFamily
);
143
buffer <<
uint32
(proto->
TotemCategory
);
144
145
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SOCKETS
; ++x)
146
buffer <<
uint32
(proto->
Socket
[x].
Color
);
147
148
for
(
uint32
x = 0; x <
MAX_ITEM_PROTO_SOCKETS
; ++x)
149
buffer <<
uint32
(proto->
Socket
[x].
Content
);
150
151
buffer <<
uint32
(proto->
socketBonus
);
152
buffer <<
uint32
(proto->
GemProperties
);
153
buffer << float(proto->
ArmorDamageModifier
);
154
buffer <<
int32
(proto->
Duration
);
155
buffer <<
uint32
(proto->
ItemLimitCategory
);
156
buffer <<
uint32
(proto->
HolidayId
);
157
buffer << float(proto->
StatScalingFactor
);
// StatScalingFactor
158
buffer <<
uint32
(proto->
CurrencySubstitutionId
);
159
buffer <<
uint32
(proto->
CurrencySubstitutionCount
);
160
}
ItemExists
bool ItemExists(uint32 id)
Definition
DB2Utility.cpp:9
DB2Utility.h
int32
std::int32_t int32
Definition
Define.h:73
uint32
std::uint32_t uint32
Definition
Define.h:77
uint16
std::uint16_t uint16
Definition
Define.h:78
ASSERT
#define ASSERT
Definition
Errors.h:29
MAX_ITEM_PROTO_SOCKETS
#define MAX_ITEM_PROTO_SOCKETS
Definition
ItemPrototype.h:623
MAX_ITEM_PROTO_SPELLS
#define MAX_ITEM_PROTO_SPELLS
Definition
ItemPrototype.h:624
MAX_ITEM_PROTO_STATS
#define MAX_ITEM_PROTO_STATS
Definition
ItemPrototype.h:625
ObjectMgr.h
sObjectMgr
#define sObjectMgr
Definition
ObjectMgr.h:1617
ByteBuffer
Definition
ByteBuffer.h:120
DB2Storage
Definition
DB2Store.h:90
ObjectMgr::GetLocaleString
static void GetLocaleString(const StringVector &data, int loc_idx, std::string &value)
Definition
ObjectMgr.h:1353
DB2Utilities::HasItemSparseEntry
bool HasItemSparseEntry(DB2Storage< ItemSparseEntry > const &store, uint32 id)
Definition
DB2Utility.cpp:19
DB2Utilities::WriteItemDbReply
void WriteItemDbReply(DB2Storage< ItemEntry > const &store, uint32 id, uint32 locale, ByteBuffer &buffer)
Definition
DB2Utility.cpp:24
DB2Utilities::HasItemEntry
bool HasItemEntry(DB2Storage< ItemEntry > const &store, uint32 id)
Definition
DB2Utility.cpp:14
DB2Utilities::WriteItemSparseDbReply
void WriteItemSparseDbReply(DB2Storage< ItemSparseEntry > const &store, uint32 id, uint32 locale, ByteBuffer &buffer)
Definition
DB2Utility.cpp:39
_ItemStat::ItemStatValue
int32 ItemStatValue
Definition
ItemPrototype.h:594
_ItemStat::ItemStatUnk2
int32 ItemStatUnk2
Definition
ItemPrototype.h:596
_ItemStat::ItemStatType
uint32 ItemStatType
Definition
ItemPrototype.h:593
_ItemStat::ItemStatUnk1
int32 ItemStatUnk1
Definition
ItemPrototype.h:595
_Socket::Content
uint32 Content
Definition
ItemPrototype.h:612
_Socket::Color
uint32 Color
Definition
ItemPrototype.h:611
_Spell::SpellCharges
int32 SpellCharges
Definition
ItemPrototype.h:603
_Spell::SpellTrigger
uint32 SpellTrigger
Definition
ItemPrototype.h:602
_Spell::SpellCategoryCooldown
int32 SpellCategoryCooldown
Definition
ItemPrototype.h:606
_Spell::SpellCooldown
int32 SpellCooldown
Definition
ItemPrototype.h:604
_Spell::SpellCategory
uint32 SpellCategory
Definition
ItemPrototype.h:605
_Spell::SpellId
int32 SpellId
Definition
ItemPrototype.h:601
ItemLocale
Definition
ItemPrototype.h:850
ItemLocale::Name
StringVector Name
Definition
ItemPrototype.h:851
ItemLocale::Description
StringVector Description
Definition
ItemPrototype.h:852
ItemTemplate
Definition
ItemPrototype.h:628
ItemTemplate::RandomProperty
int32 RandomProperty
Definition
ItemPrototype.h:683
ItemTemplate::BuyCount
uint32 BuyCount
Definition
ItemPrototype.h:650
ItemTemplate::Map
uint32 Map
Definition
ItemPrototype.h:688
ItemTemplate::Quality
uint32 Quality
Definition
ItemPrototype.h:644
ItemTemplate::ItemLevel
uint32 ItemLevel
Definition
ItemPrototype.h:656
ItemTemplate::RequiredCityRank
uint32 RequiredCityRank
Definition
ItemPrototype.h:662
ItemTemplate::RequiredSkill
uint32 RequiredSkill
Definition
ItemPrototype.h:658
ItemTemplate::RequiredSpell
uint32 RequiredSpell
Definition
ItemPrototype.h:660
ItemTemplate::MaxCount
int32 MaxCount
Definition
ItemPrototype.h:665
ItemTemplate::Description
std::string Description
Definition
ItemPrototype.h:675
ItemTemplate::AllowableClass
uint32 AllowableClass
Definition
ItemPrototype.h:654
ItemTemplate::RequiredSkillRank
uint32 RequiredSkillRank
Definition
ItemPrototype.h:659
ItemTemplate::Unk430_1
float Unk430_1
Definition
ItemPrototype.h:648
ItemTemplate::RequiredHonorRank
uint32 RequiredHonorRank
Definition
ItemPrototype.h:661
ItemTemplate::RangedModRange
float RangedModRange
Definition
ItemPrototype.h:672
ItemTemplate::Sheath
uint32 Sheath
Definition
ItemPrototype.h:682
ItemTemplate::ArmorDamageModifier
float ArmorDamageModifier
Definition
ItemPrototype.h:694
ItemTemplate::Material
int32 Material
Definition
ItemPrototype.h:681
ItemTemplate::Spells
_Spell Spells[MAX_ITEM_PROTO_SPELLS]
Definition
ItemPrototype.h:673
ItemTemplate::Area
uint32 Area
Definition
ItemPrototype.h:687
ItemTemplate::BuyPrice
int32 BuyPrice
Definition
ItemPrototype.h:651
ItemTemplate::socketBonus
uint32 socketBonus
Definition
ItemPrototype.h:692
ItemTemplate::TotemCategory
uint32 TotemCategory
Definition
ItemPrototype.h:690
ItemTemplate::StatScalingFactor
float StatScalingFactor
Definition
ItemPrototype.h:698
ItemTemplate::PageMaterial
uint32 PageMaterial
Definition
ItemPrototype.h:678
ItemTemplate::Flags
uint32 Flags
Definition
ItemPrototype.h:645
ItemTemplate::RequiredLevel
uint32 RequiredLevel
Definition
ItemPrototype.h:657
ItemTemplate::Name1
std::string Name1
Definition
ItemPrototype.h:642
ItemTemplate::LockID
uint32 LockID
Definition
ItemPrototype.h:680
ItemTemplate::ItemSet
uint32 ItemSet
Definition
ItemPrototype.h:685
ItemTemplate::HolidayId
uint32 HolidayId
Definition
ItemPrototype.h:697
ItemTemplate::GemProperties
uint32 GemProperties
Definition
ItemPrototype.h:693
ItemTemplate::CurrencySubstitutionCount
uint32 CurrencySubstitutionCount
Definition
ItemPrototype.h:700
ItemTemplate::RequiredReputationRank
uint32 RequiredReputationRank
Definition
ItemPrototype.h:664
ItemTemplate::Flags3
uint32 Flags3
Definition
ItemPrototype.h:647
ItemTemplate::ContainerSlots
uint32 ContainerSlots
Definition
ItemPrototype.h:667
ItemTemplate::DisplayInfoID
uint32 DisplayInfoID
Definition
ItemPrototype.h:643
ItemTemplate::AllowableRace
uint32 AllowableRace
Definition
ItemPrototype.h:655
ItemTemplate::RequiredReputationFaction
uint32 RequiredReputationFaction
Definition
ItemPrototype.h:663
ItemTemplate::Class
uint32 Class
Definition
ItemPrototype.h:639
ItemTemplate::ItemLimitCategory
uint32 ItemLimitCategory
Definition
ItemPrototype.h:696
ItemTemplate::PageText
uint32 PageText
Definition
ItemPrototype.h:676
ItemTemplate::ScalingStatDistribution
uint32 ScalingStatDistribution
Definition
ItemPrototype.h:669
ItemTemplate::ItemStat
_ItemStat ItemStat[MAX_ITEM_PROTO_STATS]
Definition
ItemPrototype.h:668
ItemTemplate::BagFamily
uint32 BagFamily
Definition
ItemPrototype.h:689
ItemTemplate::InventoryType
uint32 InventoryType
Definition
ItemPrototype.h:653
ItemTemplate::LanguageID
uint32 LanguageID
Definition
ItemPrototype.h:677
ItemTemplate::CurrencySubstitutionId
uint32 CurrencySubstitutionId
Definition
ItemPrototype.h:699
ItemTemplate::Flags2
uint32 Flags2
Definition
ItemPrototype.h:646
ItemTemplate::Delay
uint32 Delay
Definition
ItemPrototype.h:671
ItemTemplate::Unk430_2
float Unk430_2
Definition
ItemPrototype.h:649
ItemTemplate::RandomSuffix
int32 RandomSuffix
Definition
ItemPrototype.h:684
ItemTemplate::DamageType
uint32 DamageType
Definition
ItemPrototype.h:670
ItemTemplate::Duration
uint32 Duration
Definition
ItemPrototype.h:695
ItemTemplate::SubClass
uint32 SubClass
Definition
ItemPrototype.h:640
ItemTemplate::Stackable
int32 Stackable
Definition
ItemPrototype.h:666
ItemTemplate::StartQuest
uint32 StartQuest
Definition
ItemPrototype.h:679
ItemTemplate::SoundOverrideSubclass
int32 SoundOverrideSubclass
Definition
ItemPrototype.h:641
ItemTemplate::Socket
_Socket Socket[MAX_ITEM_PROTO_SOCKETS]
Definition
ItemPrototype.h:691
ItemTemplate::ItemId
uint32 ItemId
Definition
ItemPrototype.h:638
ItemTemplate::Bonding
uint32 Bonding
Definition
ItemPrototype.h:674
ItemTemplate::SellPrice
uint32 SellPrice
Definition
ItemPrototype.h:652
src
server
game
DataStores
DB2Utility.cpp
Generated on
for Project SkyFire Core by
1.17.0