[Repositories] Convert Item Loading to Repositories (#4998)

This commit is contained in:
Alex King 2025-08-30 16:39:23 -04:00 committed by GitHub
parent e015d0d67e
commit 1eb89edbbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 212 additions and 461 deletions

View File

@ -603,7 +603,6 @@ SET(common_headers
ipc_mutex.h ipc_mutex.h
ip_util.h ip_util.h
item_data.h item_data.h
item_fieldlist.h
item_instance.h item_instance.h
json_config.h json_config.h
light_source.h light_source.h

View File

@ -1,206 +0,0 @@
/*
These fields must be in the order of how they are serialized!
*/
F(itemclass)
F(name)
F(lore)
F(idfile)
F(id)
F(weight)
F(norent)
F(nodrop)
F(size)
F(slots)
F(price)
F(icon)
F(UNK012)
F(UNK013)
F(benefitflag)
F(tradeskills)
F(cr)
F(dr)
F(pr)
F(mr)
F(fr)
F(astr)
F(asta)
F(aagi)
F(adex)
F(acha)
F(aint)
F(awis)
F(hp)
F(mana)
F(ac)
F(deity)
F(skillmodvalue)
F(UNK033)
F(skillmodmax)
F(skillmodtype)
F(banedmgrace)
F(banedmgamt)
F(banedmgbody)
F(magic)
F(casttime_)
F(reqlevel)
F(bardtype)
F(bardvalue)
F(light)
F(delay)
F(reclevel)
F(recskill)
F(elemdmgtype)
F(elemdmgamt)
F(range)
F(damage)
F(color)
F(classes)
F(races)
F(UNK054)
F(maxcharges)
F(itemtype)
F(material)
F(herosforgemodel)
F(sellrate)
F(UNK059)
F(casttime)
F(elitematerial)
F(procrate)
F(combateffects)
F(shielding)
F(stunresist)
F(strikethrough)
F(extradmgskill)
F(extradmgamt)
F(spellshield)
F(avoidance)
F(accuracy)
F(charmfileid)
F(factionmod1)
F(factionmod2)
F(factionmod3)
F(factionmod4)
F(factionamt1)
F(factionamt2)
F(factionamt3)
F(factionamt4)
F(charmfile)
F(augtype)
F(augslot1type)
F(augslot1visible)
F(augslot2type)
F(augslot2visible)
F(augslot3type)
F(augslot3visible)
F(augslot4type)
F(augslot4visible)
F(augslot5type)
F(augslot5visible)
F(augslot6type)
F(augslot6visible)
F(ldontheme)
F(ldonprice)
F(ldonsold)
F(bagtype)
F(bagslots)
F(bagsize)
F(bagwr)
F(book)
F(booktype)
F(filename)
F(banedmgraceamt)
F(augrestrict)
F(loregroup)
F(pendingloreflag)
F(artifactflag)
F(summonedflag)
F(favor)
F(fvnodrop)
F(endur)
F(dotshielding)
F(attack)
F(regen)
F(manaregen)
F(enduranceregen)
F(haste)
F(damageshield)
F(recastdelay)
F(recasttype)
F(guildfavor)
F(augdistiller)
F(UNK123)
F(UNK124)
F(attuneable)
F(nopet)
F(UNK127)
F(pointtype)
F(potionbelt)
F(potionbeltslots)
F(stacksize)
F(notransfer)
F(stackable)
F(UNK134)
F(clickeffect)
F(clicktype)
F(clicklevel)
F(clicklevel2)
F(proceffect)
F(proctype)
F(proclevel)
F(proclevel2)
F(worneffect)
F(worntype)
F(wornlevel)
F(wornlevel2)
F(focuseffect)
F(focustype)
F(focuslevel)
F(focuslevel2)
F(scrolleffect)
F(scrolltype)
F(scrolllevel)
F(scrolllevel2)
F(bardeffect)
F(bardeffecttype)
F(bardlevel2)
F(bardlevel)
F(questitemflag)
F(svcorruption)
F(purity)
F(evoitem)
F(evoid)
F(evolvinglevel)
F(evomax)
F(backstabdmg)
F(dsmitigation)
F(heroic_str)
F(heroic_int)
F(heroic_wis)
F(heroic_agi)
F(heroic_dex)
F(heroic_sta)
F(heroic_cha)
F(heroic_mr)
F(heroic_fr)
F(heroic_cr)
F(heroic_dr)
F(heroic_pr)
F(heroic_svcorrup)
F(healamt)
F(spelldmg)
F(ldonsellbackrate)
F(scriptfileid)
F(expendablearrow)
F(clairvoyance)
F(clickname)
F(procname)
F(wornname)
F(focusname)
F(scrollname)
F(subtype)

View File

@ -54,19 +54,7 @@
#include "repositories/character_inspect_messages_repository.h" #include "repositories/character_inspect_messages_repository.h"
#include "repositories/spells_new_repository.h" #include "repositories/spells_new_repository.h"
#include "repositories/damageshieldtypes_repository.h" #include "repositories/damageshieldtypes_repository.h"
#include "repositories/items_repository.h"
namespace ItemField
{
enum {
source = 0,
#define F(x) x,
#include "item_fieldlist.h"
#undef F
updated,
minstatus,
comment,
};
}
SharedDatabase::SharedDatabase() SharedDatabase::SharedDatabase()
: Database() : Database()
@ -947,27 +935,10 @@ void SharedDatabase::ClearOldRecastTimestamps(uint32 char_id)
); );
} }
void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) void SharedDatabase::GetItemsCount(int32& item_count, uint32& max_id)
{ {
item_count = -1; max_id = ItemsRepository::GetMaxId(*this);
max_id = 0; item_count = ItemsRepository::Count(*this);
const std::string query = "SELECT MAX(id), count(*) FROM items";
auto results = QueryDatabase(query);
if (!results.Success()) {
return;
}
if (results.RowCount() == 0)
return;
auto& row = results.begin();
if (row[0])
max_id = Strings::ToUnsignedInt(row[0]);
if (row[1])
item_count = Strings::ToUnsignedInt(row[1]);
} }
bool SharedDatabase::LoadItems(const std::string &prefix) { bool SharedDatabase::LoadItems(const std::string &prefix) {
@ -997,14 +968,14 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
std::string variable_buffer; std::string variable_buffer;
bool disable_attuneable = RuleB(Items, DisableAttuneable); bool disable_attuneable = RuleB(Items, DisableAttuneable);
bool disable_bard_focus_effects = RuleB(Items, DisableBardFocusEffects); bool disable_bard_focus_effects = RuleB(Items, DisableBardFocusEffects);
bool disable_lore = RuleB(Items, DisableLore); bool disable_lore = RuleB(Items, DisableLore);
bool disable_no_drop = RuleB(Items, DisableNoDrop); bool disable_no_drop = RuleB(Items, DisableNoDrop);
bool disable_no_pet = RuleB(Items, DisableNoPet); bool disable_no_pet = RuleB(Items, DisableNoPet);
bool disable_no_rent = RuleB(Items, DisableNoRent); bool disable_no_rent = RuleB(Items, DisableNoRent);
bool disable_no_transfer = RuleB(Items, DisableNoTransfer); bool disable_no_transfer = RuleB(Items, DisableNoTransfer);
bool disable_potion_belt = RuleB(Items, DisablePotionBelt); bool disable_potion_belt = RuleB(Items, DisablePotionBelt);
bool disable_spell_focus_effects = RuleB(Items, DisableSpellFocusEffects); bool disable_spell_focus_effects = RuleB(Items, DisableSpellFocusEffects);
// Old Variable Code // Old Variable Code
@ -1035,206 +1006,204 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
EQ::ItemData item; EQ::ItemData item;
const std::string query = "SELECT source," const auto& l = ItemsRepository::All(*this);
#define F(x) "`"#x"`,"
#include "item_fieldlist.h" if (l.empty()) {
#undef F
"updated, minstatus, comment FROM items ORDER BY id";
auto results = QueryDatabase(query);
if (!results.Success()) {
return; return;
} }
for (auto& row = results.begin(); row != results.end(); ++row) { for (const auto& e : l) {
memset(&item, 0, sizeof(EQ::ItemData)); memset(&item, 0, sizeof(EQ::ItemData));
// Unique Identifier // Unique Identifier
item.ID = Strings::ToUnsignedInt(row[ItemField::id]); item.ID = e.id;
// Minimum Status // Minimum Status
item.MinStatus = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::minstatus])); item.MinStatus = static_cast<uint8>(e.minstatus);
// Name, Lore, and Comment // Name, Lore, and Comment
strn0cpy(item.Name, row[ItemField::name], sizeof(item.Name)); strn0cpy(item.Name, e.Name.c_str(), sizeof(item.Name));
strn0cpy(item.Lore, row[ItemField::lore], sizeof(item.Lore)); strn0cpy(item.Lore, e.lore.c_str(), sizeof(item.Lore));
strn0cpy(item.Comment, row[ItemField::comment], sizeof(item.Comment)); strn0cpy(item.Comment, e.comment.c_str(), sizeof(item.Comment));
// Flags // Flags
item.ArtifactFlag = Strings::ToBool(row[ItemField::artifactflag]); item.ArtifactFlag = e.artifactflag;
item.Attuneable = !disable_attuneable && Strings::ToBool(row[ItemField::attuneable]); item.Attuneable = !disable_attuneable && e.attuneable;
item.BenefitFlag = Strings::ToBool(row[ItemField::benefitflag]); item.BenefitFlag = e.benefitflag;
item.FVNoDrop = Strings::ToBool(row[ItemField::fvnodrop]); item.FVNoDrop = e.fvnodrop;
item.Magic = Strings::ToBool(row[ItemField::magic]); item.Magic = e.magic;
item.NoDrop = disable_no_drop ? static_cast<uint8>(255) : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::nodrop])); item.NoDrop = disable_no_drop ? std::numeric_limits<uint8>::max() : e.nodrop;
item.NoPet = !disable_no_pet && Strings::ToBool(row[ItemField::nopet]); item.NoPet = !disable_no_pet && e.nopet;
item.NoRent = disable_no_rent ? static_cast<uint8>(255) : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::norent])); item.NoRent = disable_no_rent ? std::numeric_limits<uint8>::max() : e.norent;
item.NoTransfer = !disable_no_transfer && Strings::ToBool(row[ItemField::notransfer]); item.NoTransfer = !disable_no_transfer && e.notransfer;
item.PendingLoreFlag = Strings::ToBool(row[ItemField::pendingloreflag]); item.PendingLoreFlag = e.pendingloreflag;
item.QuestItemFlag = Strings::ToBool(row[ItemField::questitemflag]); item.QuestItemFlag = e.questitemflag;
item.Stackable = Strings::ToBool(row[ItemField::stackable]); item.Stackable = e.stackable;
item.Tradeskills = Strings::ToBool(row[ItemField::tradeskills]); item.Tradeskills = e.tradeskills;
item.SummonedFlag = Strings::ToBool(row[ItemField::summonedflag]); item.SummonedFlag = e.summonedflag;
// Lore // Lore
item.LoreGroup = disable_lore ? 0 : Strings::ToInt(row[ItemField::loregroup]); item.LoreGroup = disable_lore ? 0 : e.loregroup;
item.LoreFlag = !disable_lore && item.LoreGroup != 0; item.LoreFlag = !disable_lore && item.LoreGroup != 0;
// Type // Type
item.AugType = Strings::ToUnsignedInt(row[ItemField::augtype]); item.AugType = e.augtype;
item.ItemType = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::itemtype])); item.ItemType = static_cast<uint8>(e.itemtype);
item.SubType = Strings::ToInt(row[ItemField::subtype]); item.SubType = e.subtype;
// Miscellaneous // Miscellaneous
item.ExpendableArrow = static_cast<uint16>(Strings::ToUnsignedInt(row[ItemField::expendablearrow])); item.ExpendableArrow = e.expendablearrow;
item.Light = static_cast<int8>(Strings::ToInt(row[ItemField::light])); item.Light = EQ::Clamp(e.light, -128, 127);
item.MaxCharges = static_cast<int16>(Strings::ToInt(row[ItemField::maxcharges])); item.MaxCharges = e.maxcharges;
item.Size = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::size])); item.Size = static_cast<uint8>(e.size);
item.StackSize = static_cast<int16>(Strings::ToInt(row[ItemField::stacksize])); item.StackSize = e.stacksize;
item.Weight = Strings::ToInt(row[ItemField::weight]); item.Weight = e.weight;
// Potion Belt // Potion Belt
item.PotionBelt = !disable_potion_belt && Strings::ToBool(row[ItemField::potionbelt]); item.PotionBelt = !disable_potion_belt && e.potionbelt;
item.PotionBeltSlots = disable_potion_belt ? 0 : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::potionbeltslots])); item.PotionBeltSlots = disable_potion_belt ? 0 : static_cast<uint8>(e.potionbeltslots);
// Merchant // Merchant
item.Favor = Strings::ToUnsignedInt(row[ItemField::favor]); item.Favor = e.favor;
item.GuildFavor = Strings::ToUnsignedInt(row[ItemField::guildfavor]); item.GuildFavor = e.guildfavor;
item.Price = Strings::ToUnsignedInt(row[ItemField::price]); item.Price = e.price;
item.SellRate = Strings::ToFloat(row[ItemField::sellrate]); item.SellRate = e.sellrate;
// Display // Display
item.Color = Strings::ToUnsignedInt(row[ItemField::color]); item.Color = e.color;
item.EliteMaterial = Strings::ToUnsignedInt(row[ItemField::elitematerial]); item.EliteMaterial = e.elitematerial;
item.HerosForgeModel = Strings::ToUnsignedInt(row[ItemField::herosforgemodel]); item.HerosForgeModel = e.herosforgemodel;
item.Icon = Strings::ToUnsignedInt(row[ItemField::icon]); item.Icon = e.icon;
strn0cpy(item.IDFile, row[ItemField::idfile], sizeof(item.IDFile)); strn0cpy(item.IDFile, e.idfile.c_str(), sizeof(item.IDFile));
item.Material = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::material])); item.Material = e.material;
// Resists // Resists
item.CR = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::cr]), -128, 127)); item.CR = EQ::Clamp(e.cr, -128, 127);
item.DR = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::dr]), -128, 127)); item.DR = EQ::Clamp(e.dr, -128, 127);
item.FR = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::fr]), -128, 127)); item.FR = EQ::Clamp(e.fr, -128, 127);
item.MR = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::mr]), -128, 127)); item.MR = EQ::Clamp(e.mr, -128, 127);
item.PR = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::pr]), -128, 127)); item.PR = EQ::Clamp(e.pr, -128, 127);
item.SVCorruption = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::svcorruption]), -128, 127)); item.SVCorruption = EQ::Clamp(e.svcorruption, -128, 127);
// Heroic Resists // Heroic Resists
item.HeroicCR = Strings::ToInt(row[ItemField::heroic_cr]); item.HeroicCR = e.heroic_cr;
item.HeroicDR = Strings::ToInt(row[ItemField::heroic_dr]); item.HeroicDR = e.heroic_dr;
item.HeroicFR = Strings::ToInt(row[ItemField::heroic_fr]); item.HeroicFR = e.heroic_fr;
item.HeroicMR = Strings::ToInt(row[ItemField::heroic_mr]); item.HeroicMR = e.heroic_mr;
item.HeroicPR = Strings::ToInt(row[ItemField::heroic_pr]); item.HeroicPR = e.heroic_pr;
item.HeroicSVCorrup = Strings::ToInt(row[ItemField::heroic_svcorrup]); item.HeroicSVCorrup = e.heroic_svcorrup;
// Stats // Stats
item.AAgi = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::aagi]), -128, 127)); item.AAgi = EQ::Clamp(e.aagi, -128, 127);
item.ACha = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::acha]), -128, 127)); item.ACha = EQ::Clamp(e.acha, -128, 127);
item.ADex = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::adex]), -128, 127)); item.ADex = EQ::Clamp(e.adex, -128, 127);
item.AInt = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::aint]), -128, 127)); item.AInt = EQ::Clamp(e.aint, -128, 127);
item.ASta = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::asta]), -128, 127)); item.ASta = EQ::Clamp(e.asta, -128, 127);
item.AStr = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::astr]), -128, 127)); item.AStr = EQ::Clamp(e.astr, -128, 127);
item.AWis = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::awis]), -128, 127)); item.AWis = EQ::Clamp(e.awis, -128, 127);
// Heroic Stats // Heroic Stats
item.HeroicAgi = Strings::ToInt(row[ItemField::heroic_agi]); item.HeroicAgi = e.heroic_agi;
item.HeroicCha = Strings::ToInt(row[ItemField::heroic_cha]); item.HeroicCha = e.heroic_cha;
item.HeroicDex = Strings::ToInt(row[ItemField::heroic_dex]); item.HeroicDex = e.heroic_dex;
item.HeroicInt = Strings::ToInt(row[ItemField::heroic_int]); item.HeroicInt = e.heroic_int;
item.HeroicSta = Strings::ToInt(row[ItemField::heroic_sta]); item.HeroicSta = e.heroic_sta;
item.HeroicStr = Strings::ToInt(row[ItemField::heroic_str]); item.HeroicStr = e.heroic_str;
item.HeroicWis = Strings::ToInt(row[ItemField::heroic_wis]); item.HeroicWis = e.heroic_wis;
// Health, Mana, and Endurance // Health, Mana, and Endurance
item.HP = Strings::ToInt(row[ItemField::hp]); item.HP = e.hp;
item.Regen = Strings::ToInt(row[ItemField::regen]); item.Regen = e.regen;
item.Mana = Strings::ToInt(row[ItemField::mana]); item.Mana = e.mana;
item.ManaRegen = Strings::ToInt(row[ItemField::manaregen]); item.ManaRegen = e.manaregen;
item.Endur = Strings::ToInt(row[ItemField::endur]); item.Endur = e.endur;
item.EnduranceRegen = Strings::ToInt(row[ItemField::enduranceregen]); item.EnduranceRegen = e.enduranceregen;
// Bane Damage // Bane Damage
item.BaneDmgAmt = Strings::ToInt(row[ItemField::banedmgamt]); item.BaneDmgAmt = e.banedmgamt;
item.BaneDmgBody = Strings::ToUnsignedInt(row[ItemField::banedmgbody]); item.BaneDmgBody = e.banedmgbody;
item.BaneDmgRace = Strings::ToUnsignedInt(row[ItemField::banedmgrace]); item.BaneDmgRace = e.banedmgrace;
item.BaneDmgRaceAmt = Strings::ToUnsignedInt(row[ItemField::banedmgraceamt]); item.BaneDmgRaceAmt = e.banedmgraceamt;
// Elemental Damage // Elemental Damage
item.ElemDmgType = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::elemdmgtype])); item.ElemDmgType = static_cast<uint8>(e.elemdmgtype);
item.ElemDmgAmt = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::elemdmgamt])); item.ElemDmgAmt = static_cast<uint8>(e.elemdmgamt);
// Combat // Combat
item.BackstabDmg = Strings::ToUnsignedInt(row[ItemField::backstabdmg]); item.BackstabDmg = e.backstabdmg;
item.Damage = Strings::ToUnsignedInt(row[ItemField::damage]); item.Damage = e.damage;
item.Delay = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::delay])); item.Delay = static_cast<uint8>(e.delay);
item.Range = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::range])); item.Range = static_cast<uint8>(e.range_);
// Combat Stats // Combat Stats
item.AC = Strings::ToInt(row[ItemField::ac]); item.AC = e.ac;
item.Accuracy = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::accuracy]), -128, 127)); item.Accuracy = EQ::Clamp(e.accuracy, -128, 127);
item.Attack = Strings::ToInt(row[ItemField::attack]); item.Attack = e.attack;
item.Avoidance = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::avoidance]), -128, 127)); item.Avoidance = EQ::Clamp(e.avoidance, -128, 127);
item.Clairvoyance = Strings::ToUnsignedInt(row[ItemField::clairvoyance]); item.Clairvoyance = e.clairvoyance;
item.CombatEffects = Strings::IsNumber(row[ItemField::combateffects]) ? static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::combateffects]), -128, 127)) : 0; item.CombatEffects = Strings::IsNumber(e.combateffects) ? static_cast<int8>(EQ::Clamp(Strings::ToInt(e.combateffects), -128, 127)) : 0;
item.DamageShield = Strings::ToInt(row[ItemField::damageshield]); item.DamageShield = e.damageshield;
item.DotShielding = Strings::ToInt(row[ItemField::dotshielding]); item.DotShielding = e.dotshielding;
item.DSMitigation = Strings::ToUnsignedInt(row[ItemField::dsmitigation]); item.DSMitigation = e.dsmitigation;
item.Haste = Strings::ToInt(row[ItemField::haste]); item.Haste = e.haste;
item.HealAmt = Strings::ToInt(row[ItemField::healamt]); item.HealAmt = e.healamt;
item.Purity = Strings::ToUnsignedInt(row[ItemField::purity]); item.Purity = e.purity;
item.Shielding = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::shielding]), -128, 127)); item.Shielding = EQ::Clamp(e.shielding, -128, 127);
item.SpellDmg = Strings::ToInt(row[ItemField::spelldmg]); item.SpellDmg = e.spelldmg;
item.SpellShield = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::spellshield]), -128, 127)); item.SpellShield = EQ::Clamp(e.spellshield, -128, 127);
item.StrikeThrough = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::strikethrough]), -128, 127)); item.StrikeThrough = EQ::Clamp(e.strikethrough, -128, 127);
item.StunResist = static_cast<int8>(EQ::Clamp(Strings::ToInt(row[ItemField::stunresist]), -128, 127)); item.StunResist = EQ::Clamp(e.stunresist, -128, 127);
// Restrictions // Restrictions
item.AugRestrict = Strings::ToUnsignedInt(row[ItemField::augrestrict]); item.AugRestrict = e.augrestrict;
item.Classes = Strings::ToUnsignedInt(row[ItemField::classes]); item.Classes = e.classes;
item.Deity = Strings::ToUnsignedInt(row[ItemField::deity]); item.Deity = e.deity;
item.ItemClass = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::itemclass])); item.ItemClass = static_cast<uint8>(e.itemclass);
item.Races = Strings::ToUnsignedInt(row[ItemField::races]); item.Races = e.races;
item.RecLevel = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::reclevel])); item.RecLevel = static_cast<uint8>(e.reclevel);
item.RecSkill = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::recskill])); item.RecSkill = static_cast<uint8>(e.recskill);
item.ReqLevel = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::reqlevel])); item.ReqLevel = static_cast<uint8>(e.reqlevel);
item.Slots = Strings::ToUnsignedInt(row[ItemField::slots]); item.Slots = e.slots;
// Skill Modifier // Skill Modifier
item.SkillModValue = Strings::ToInt(row[ItemField::skillmodvalue]); item.SkillModValue = e.skillmodvalue;
item.SkillModMax = Strings::ToInt(row[ItemField::skillmodmax]); item.SkillModMax = e.skillmodmax;
item.SkillModType = Strings::ToUnsignedInt(row[ItemField::skillmodtype]); item.SkillModType = e.skillmodtype;
// Extra Damage Skill // Extra Damage Skill
item.ExtraDmgSkill = Strings::ToInt(row[ItemField::extradmgskill]); item.ExtraDmgSkill = e.extradmgskill;
item.ExtraDmgAmt = Strings::ToInt(row[ItemField::extradmgamt]); item.ExtraDmgAmt = e.extradmgamt;
// Bard // Bard
item.BardType = Strings::ToUnsignedInt(row[ItemField::bardtype]); item.BardType = e.bardtype;
item.BardValue = Strings::ToInt(row[ItemField::bardvalue]); item.BardValue = e.bardvalue;
// Faction // Faction
item.FactionAmt1 = Strings::ToInt(row[ItemField::factionamt1]); item.FactionAmt1 = e.factionamt1;
item.FactionMod1 = Strings::ToInt(row[ItemField::factionmod1]); item.FactionMod1 = e.factionmod1;
item.FactionAmt2 = Strings::ToInt(row[ItemField::factionamt2]); item.FactionAmt2 = e.factionamt2;
item.FactionMod2 = Strings::ToInt(row[ItemField::factionmod2]); item.FactionMod2 = e.factionmod2;
item.FactionAmt3 = Strings::ToInt(row[ItemField::factionamt3]); item.FactionAmt3 = e.factionamt3;
item.FactionMod3 = Strings::ToInt(row[ItemField::factionmod3]); item.FactionMod3 = e.factionmod3;
item.FactionAmt4 = Strings::ToInt(row[ItemField::factionamt4]); item.FactionAmt4 = e.factionamt4;
item.FactionMod4 = Strings::ToInt(row[ItemField::factionmod4]); item.FactionMod4 = e.factionmod4;
// Augment // Augment Distiller
item.AugDistiller = Strings::ToUnsignedInt(row[ItemField::augdistiller]); item.AugDistiller = e.augdistiller;
item.AugSlotType[0] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot1type]));
item.AugSlotVisible[0] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot1visible])); // Augment Slots
item.AugSlotType[1] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot2type])); item.AugSlotType[0] = static_cast<uint8>(e.augslot1type);
item.AugSlotVisible[1] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot2visible])); item.AugSlotVisible[0] = static_cast<uint8>(e.augslot1visible);
item.AugSlotType[2] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot3type])); item.AugSlotType[1] = static_cast<uint8>(e.augslot2type);
item.AugSlotVisible[2] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot3visible])); item.AugSlotVisible[1] = static_cast<uint8>(e.augslot2visible);
item.AugSlotType[3] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot4type])); item.AugSlotType[2] = static_cast<uint8>(e.augslot3type);
item.AugSlotVisible[3] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot4visible])); item.AugSlotVisible[2] = static_cast<uint8>(e.augslot3visible);
item.AugSlotType[4] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot5type])); item.AugSlotType[3] = static_cast<uint8>(e.augslot4type);
item.AugSlotVisible[4] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot5visible])); item.AugSlotVisible[3] = static_cast<uint8>(e.augslot4visible);
item.AugSlotType[5] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot6type])); item.AugSlotType[4] = static_cast<uint8>(e.augslot5type);
item.AugSlotVisible[5] = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::augslot6visible])); item.AugSlotVisible[4] = static_cast<uint8>(e.augslot5visible);
item.AugSlotType[5] = static_cast<uint8>(e.augslot6type);
item.AugSlotVisible[5] = static_cast<uint8>(e.augslot6visible);
// Augment Unknowns // Augment Unknowns
for (uint8 i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) { for (uint8 i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) {
@ -1242,79 +1211,79 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
} }
// LDoN // LDoN
item.LDoNTheme = Strings::ToUnsignedInt(row[ItemField::ldontheme]); item.LDoNTheme = e.ldontheme;
item.LDoNPrice = Strings::ToUnsignedInt(row[ItemField::ldonprice]); item.LDoNPrice = e.ldonprice;
item.LDoNSellBackRate = Strings::ToUnsignedInt(row[ItemField::ldonsellbackrate]); item.LDoNSellBackRate = e.ldonsellbackrate;
item.LDoNSold = Strings::ToUnsignedInt(row[ItemField::ldonsold]); item.LDoNSold = e.ldonsold;
item.PointType = Strings::ToUnsignedInt(row[ItemField::pointtype]); item.PointType = e.pointtype;
// Bag // Bag
item.BagSize = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::bagsize])); item.BagSize = static_cast<uint8>(e.bagsize);
item.BagSlots = static_cast<uint8>(EQ::Clamp(Strings::ToInt(row[ItemField::bagslots]), 0, static_cast<int>(EQ::invbag::SLOT_COUNT))); item.BagSlots = EQ::Clamp(e.bagslots, 0, static_cast<int>(EQ::invbag::SLOT_COUNT));
item.BagType = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::bagtype])); item.BagType = static_cast<uint8>(e.bagtype);
item.BagWR = static_cast<uint8>(EQ::Clamp(Strings::ToInt(row[ItemField::bagwr]), 0, 100)); item.BagWR = EQ::Clamp(e.bagwr, 0, 100);
// Bard Effect // Bard Effect
item.Bard.Effect = disable_bard_focus_effects ? 0 : Strings::ToInt(row[ItemField::bardeffect]); item.Bard.Effect = disable_bard_focus_effects ? 0 : e.bardeffect;
item.Bard.Type = disable_bard_focus_effects ? 0 : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::bardtype])); item.Bard.Type = disable_bard_focus_effects ? 0 : static_cast<uint8>(e.bardtype);
item.Bard.Level = disable_bard_focus_effects ? 0 : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::bardlevel])); item.Bard.Level = disable_bard_focus_effects ? 0 : static_cast<uint8>(e.bardlevel);
item.Bard.Level2 = disable_bard_focus_effects ? 0 : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::bardlevel2])); item.Bard.Level2 = disable_bard_focus_effects ? 0 : static_cast<uint8>(e.bardlevel2);
// Book // Book
item.Book = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::book])); item.Book = static_cast<uint8>(e.book);
item.BookType = Strings::ToUnsignedInt(row[ItemField::booktype]); item.BookType = e.booktype;
// Click Effect // Click Effect
item.CastTime = Strings::ToUnsignedInt(row[ItemField::casttime]); item.CastTime = e.casttime;
item.CastTime_ = Strings::ToInt(row[ItemField::casttime_]); item.CastTime_ = e.casttime_;
item.Click.Effect = Strings::ToInt(row[ItemField::clickeffect]); item.Click.Effect = e.clickeffect;
item.Click.Type = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::clicktype])); item.Click.Type = static_cast<uint8>(e.clicktype);
item.Click.Level = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::clicklevel])); item.Click.Level = static_cast<uint8>(e.clicklevel);
item.Click.Level2 = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::clicklevel2])); item.Click.Level2 = static_cast<uint8>(e.clicklevel2);
strn0cpy(item.ClickName, row[ItemField::clickname], sizeof(item.ClickName)); strn0cpy(item.ClickName, e.clickname.c_str(), sizeof(item.ClickName));
item.RecastDelay = Strings::ToUnsignedInt(row[ItemField::recastdelay]); item.RecastDelay = e.recastdelay;
item.RecastType = Strings::ToInt(row[ItemField::recasttype]); item.RecastType = e.recasttype;
// Focus Effect // Focus Effect
item.Focus.Effect = disable_spell_focus_effects ? 0 : Strings::ToInt(row[ItemField::focuseffect]); item.Focus.Effect = disable_spell_focus_effects ? 0 : e.focuseffect;
item.Focus.Type = disable_spell_focus_effects ? 0 : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::focustype])); item.Focus.Type = disable_spell_focus_effects ? 0 : static_cast<uint8>(e.focustype);
item.Focus.Level = disable_spell_focus_effects ? 0 : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::focuslevel])); item.Focus.Level = disable_spell_focus_effects ? 0 : static_cast<uint8>(e.focuslevel);
item.Focus.Level2 = disable_spell_focus_effects ? 0 : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::focuslevel2])); item.Focus.Level2 = disable_spell_focus_effects ? 0 : static_cast<uint8>(e.focuslevel2);
strn0cpy(item.FocusName, disable_spell_focus_effects ? "" : row[ItemField::focusname], sizeof(item.FocusName)); strn0cpy(item.FocusName, disable_spell_focus_effects ? "" : e.focusname.c_str(), sizeof(item.FocusName));
// Proc Effect // Proc Effect
item.Proc.Effect = Strings::ToInt(row[ItemField::proceffect]); item.Proc.Effect = e.proceffect;
item.Proc.Type = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::proctype])); item.Proc.Type = static_cast<uint8>(e.proctype);
item.Proc.Level = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::proclevel])); item.Proc.Level = static_cast<uint8>(e.proclevel);
item.Proc.Level2 = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::proclevel2])); item.Proc.Level2 = static_cast<uint8>(e.proclevel2);
strn0cpy(item.ProcName, row[ItemField::procname], sizeof(item.ProcName)); strn0cpy(item.ProcName, e.procname.c_str(), sizeof(item.ProcName));
item.ProcRate = Strings::ToInt(row[ItemField::procrate]); item.ProcRate = e.procrate;
// Scroll Effect // Scroll Effect
item.Scroll.Effect = Strings::ToInt(row[ItemField::scrolleffect]); item.Scroll.Effect = e.scrolleffect;
item.Scroll.Type = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::scrolltype])); item.Scroll.Type = static_cast<uint8>(e.scrolltype);
item.Scroll.Level = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::scrolllevel])); item.Scroll.Level = static_cast<uint8>(e.scrolllevel);
item.Scroll.Level2 = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::scrolllevel2])); item.Scroll.Level2 = static_cast<uint8>(e.scrolllevel2);
strn0cpy(item.ScrollName, row[ItemField::scrollname], sizeof(item.ScrollName)); strn0cpy(item.ScrollName, e.scrollname.c_str(), sizeof(item.ScrollName));
// Worn Effect // Worn Effect
item.Worn.Effect = Strings::ToInt(row[ItemField::worneffect]); item.Worn.Effect = e.worneffect;
item.Worn.Type = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::worntype])); item.Worn.Type = static_cast<uint8>(e.worntype);
item.Worn.Level = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::wornlevel])); item.Worn.Level = static_cast<uint8>(e.wornlevel);
item.Worn.Level2 = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::wornlevel2])); item.Worn.Level2 = static_cast<uint8>(e.wornlevel2);
strn0cpy(item.WornName, row[ItemField::wornname], sizeof(item.WornName)); strn0cpy(item.WornName, e.wornname.c_str(), sizeof(item.WornName));
// Evolving Item // Evolving Item
item.EvolvingID = Strings::ToUnsignedInt(row[ItemField::evoid]); item.EvolvingID = e.evoid;
item.EvolvingItem = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::evoitem])); item.EvolvingItem = static_cast<uint8>(e.evoitem);
item.EvolvingLevel = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::evolvinglevel])); item.EvolvingLevel = static_cast<uint8>(e.evolvinglevel);
item.EvolvingMax = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::evomax])); item.EvolvingMax = static_cast<uint8>(e.evomax);
// Scripting // Scripting
item.CharmFileID = Strings::IsNumber(row[ItemField::charmfileid]) ? Strings::ToUnsignedInt(row[ItemField::charmfileid]) : 0; item.CharmFileID = Strings::IsNumber(e.charmfileid) ? Strings::ToUnsignedInt(e.charmfileid) : 0;
strn0cpy(item.CharmFile, row[ItemField::charmfile], sizeof(item.CharmFile)); strn0cpy(item.CharmFile, e.charmfile.c_str(), sizeof(item.CharmFile));
strn0cpy(item.Filename, row[ItemField::filename], sizeof(item.Filename)); strn0cpy(item.Filename, e.filename.c_str(), sizeof(item.Filename));
item.ScriptFileID = Strings::ToUnsignedInt(row[ItemField::scriptfileid]); item.ScriptFileID = e.scriptfileid;
try { try {
hash.insert(item.ID, item); hash.insert(item.ID, item);
@ -2005,18 +1974,7 @@ uint32 SharedDatabase::GetSpellsCount()
uint32 SharedDatabase::GetItemsCount() uint32 SharedDatabase::GetItemsCount()
{ {
auto results = QueryDatabase("SELECT count(*) FROM items"); return ItemsRepository::Count(*this);
if (!results.Success() || !results.RowCount()) {
return 0;
}
auto& row = results.begin();
if (row[0]) {
return Strings::ToUnsignedInt(row[0]);
}
return 0;
} }
void SharedDatabase::SetSharedItemsCount(uint32 shared_items_count) void SharedDatabase::SetSharedItemsCount(uint32 shared_items_count)

View File

@ -158,7 +158,7 @@ public:
); );
EQ::ItemInstance *CreateBaseItem(const EQ::ItemData *item, int16 charges = 0); EQ::ItemInstance *CreateBaseItem(const EQ::ItemData *item, int16 charges = 0);
void GetItemsCount(int32 &item_count, uint32 &max_id); void GetItemsCount(int32& item_count, uint32& max_id);
void LoadItems(void *data, uint32 size, int32 items, uint32 max_item_id); void LoadItems(void *data, uint32 size, int32 items, uint32 max_item_id);
bool LoadItems(const std::string &prefix); bool LoadItems(const std::string &prefix);
const EQ::ItemData *IterateItems(uint32 *id) const; const EQ::ItemData *IterateItems(uint32 *id) const;