Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
9inline bool ItemExists(uint32 id)
10{
11 return sObjectMgr->GetItemTemplate(id) != NULL;
12}
13
15{
16 return ItemExists(id);
17}
18
20{
21 return ItemExists(id);
22}
23
24void 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
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}
bool ItemExists(uint32 id)
Definition DB2Utility.cpp:9
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
std::uint16_t uint16
Definition Define.h:78
#define ASSERT
Definition Errors.h:29
#define MAX_ITEM_PROTO_SOCKETS
#define MAX_ITEM_PROTO_SPELLS
#define MAX_ITEM_PROTO_STATS
#define sObjectMgr
Definition ObjectMgr.h:1617
static void GetLocaleString(const StringVector &data, int loc_idx, std::string &value)
Definition ObjectMgr.h:1353
bool HasItemSparseEntry(DB2Storage< ItemSparseEntry > const &store, uint32 id)
void WriteItemDbReply(DB2Storage< ItemEntry > const &store, uint32 id, uint32 locale, ByteBuffer &buffer)
bool HasItemEntry(DB2Storage< ItemEntry > const &store, uint32 id)
void WriteItemSparseDbReply(DB2Storage< ItemSparseEntry > const &store, uint32 id, uint32 locale, ByteBuffer &buffer)
int32 ItemStatValue
int32 ItemStatUnk2
uint32 ItemStatType
int32 ItemStatUnk1
uint32 Content
uint32 Color
int32 SpellCharges
uint32 SpellTrigger
int32 SpellCategoryCooldown
int32 SpellCooldown
uint32 SpellCategory
int32 SpellId
StringVector Name
StringVector Description
uint32 RequiredCityRank
uint32 RequiredSkill
uint32 RequiredSpell
std::string Description
uint32 AllowableClass
uint32 RequiredSkillRank
uint32 RequiredHonorRank
float ArmorDamageModifier
_Spell Spells[MAX_ITEM_PROTO_SPELLS]
uint32 TotemCategory
float StatScalingFactor
uint32 PageMaterial
uint32 RequiredLevel
std::string Name1
uint32 GemProperties
uint32 CurrencySubstitutionCount
uint32 RequiredReputationRank
uint32 ContainerSlots
uint32 DisplayInfoID
uint32 AllowableRace
uint32 RequiredReputationFaction
uint32 ItemLimitCategory
uint32 ScalingStatDistribution
_ItemStat ItemStat[MAX_ITEM_PROTO_STATS]
uint32 InventoryType
uint32 CurrencySubstitutionId
int32 SoundOverrideSubclass
_Socket Socket[MAX_ITEM_PROTO_SOCKETS]