[Repositories] Convert Damage Shield Types to Repositories

This commit is contained in:
Kinglykrab 2025-08-27 22:20:38 -04:00
parent ba78394ce9
commit d0f83de74b
2 changed files with 11 additions and 13 deletions

View File

@ -53,6 +53,7 @@
#include "repositories/sharedbank_repository.h"
#include "repositories/character_inspect_messages_repository.h"
#include "repositories/spells_new_repository.h"
#include "repositories/damageshieldtypes_repository.h"
namespace ItemField
{
@ -1675,20 +1676,17 @@ bool SharedDatabase::GetCommandSubSettings(std::vector<CommandSubsettingsReposit
return true;
}
void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID) {
const std::string query = StringFormat("SELECT `spellid`, `type` FROM `damageshieldtypes` WHERE `spellid` > 0 "
"AND `spellid` <= %i", iMaxSpellID);
auto results = QueryDatabase(query);
if (!results.Success()) {
return;
}
void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* s, int32 max_spell_id)
{
const auto& l = DamageshieldtypesRepository::All(*this);
for(auto& row = results.begin(); row != results.end(); ++row) {
const int spellID = Strings::ToInt(row[0]);
if((spellID > 0) && (spellID <= iMaxSpellID))
sp[spellID].damage_shield_type = Strings::ToUnsignedInt(row[1]);
}
if (l.empty()) {
return;
}
for (const auto& e : l) {
s[e.spellid].damage_shield_type = e.type;
}
}
const EvolveInfo* SharedDatabase::GetEvolveInfo(uint32 loregroup) {

View File

@ -173,7 +173,7 @@ public:
int GetMaxSpellID();
bool LoadSpells(const std::string &prefix, int32 *records, const SPDat_Spell_Struct **sp);
void LoadSpells(void *data, int max_spells);
void LoadDamageShieldTypes(SPDat_Spell_Struct *sp, int32 iMaxSpellID);
void LoadDamageShieldTypes(SPDat_Spell_Struct *s, int32 max_spell_id);
uint32 GetSharedSpellsCount() { return m_shared_spells_count; }
uint32 GetSpellsCount();