Fixed the buff database entries and updated database migrations (#5076)
Build / Linux (push) Has been cancelled
Build / Windows (push) Has been cancelled

This commit is contained in:
dannuic
2026-05-05 22:23:43 -06:00
committed by GitHub
parent e5ce882b9d
commit 99f99c8b8e
23 changed files with 995 additions and 534 deletions
+107 -43
View File
@@ -622,41 +622,70 @@ bool BotDatabase::LoadBuffs(Bot* b)
buffs[index].spellid = SPELL_UNKNOWN;
}
uint32 buff_count = 0;
uint32 buff_index = 0;
for (const auto& e : l) {
if (buff_count >= BUFF_COUNT) {
if (buff_index >= BUFF_COUNT) {
continue;
}
buffs[buff_count].spellid = e.spell_id;
buffs[buff_count].casterlevel = e.caster_level;
buffs[buff_count].ticsremaining = e.tics_remaining;
buffs[buff_count].counters = 0;
Client* c = entity_list.GetClientByName(e.caster_name.c_str());
if (CalculatePoisonCounters(buffs[buff_count].spellid) > 0) {
buffs[buff_count].counters = e.poison_counters;
} else if (CalculateDiseaseCounters(buffs[buff_count].spellid) > 0) {
buffs[buff_count].counters = e.disease_counters;
} else if (CalculateCurseCounters(buffs[buff_count].spellid) > 0) {
buffs[buff_count].counters = e.curse_counters;
} else if (CalculateCorruptionCounters(buffs[buff_count].spellid) > 0) {
buffs[buff_count].counters = e.corruption_counters;
buffs[buff_index].spellid = e.spell_id;
buffs[buff_index].casterlevel = e.caster_level;
if (c) {
buffs[buff_index].casterid = c->GetID();
buffs[buff_index].client = true;
strncpy(buffs[buff_index].caster_name, c->GetName(), 64);
} else {
buffs[buff_index].casterid = 0;
buffs[buff_index].client = false;
strncpy(buffs[buff_index].caster_name, "", 64);
}
buffs[buff_count].hit_number = e.numhits;
buffs[buff_count].melee_rune = e.melee_rune;
buffs[buff_count].magic_rune = e.magic_rune;
buffs[buff_count].dot_rune = e.dot_rune;
buffs[buff_count].persistant_buff = e.persistent;
buffs[buff_count].caston_x = e.caston_x;
buffs[buff_count].caston_y = e.caston_y;
buffs[buff_count].caston_z = e.caston_z;
buffs[buff_count].ExtraDIChance = e.extra_di_chance;
buffs[buff_count].instrument_mod = e.instrument_mod;
buffs[buff_count].casterid = 0;
buffs[buff_index].ticsremaining = e.tics_remaining;
buffs[buff_index].initialduration = e.initial_duration;
buffs[buff_index].counters = 0;
buffs[buff_index].hit_number = e.numhits;
buffs[buff_index].melee_rune = e.melee_rune;
buffs[buff_index].magic_rune = e.magic_rune;
buffs[buff_index].persistent_buff = e.persistent ? true : false;
buffs[buff_index].dot_rune = e.dot_rune;
buffs[buff_index].caston_x = e.caston_x;
buffs[buff_index].caston_y = e.caston_y;
buffs[buff_index].caston_z = e.caston_z;
buffs[buff_index].ExtraDIChance = e.extra_di_chance;
buffs[buff_index].RootBreakChance = 0;
buffs[buff_index].virus_spread_time = 0;
buffs[buff_index].UpdateClient = false;
buffs[buff_index].instrument_mod = e.instrument_mod;
++buff_count;
if (CalculatePoisonCounters(buffs[buff_index].spellid) > 0) {
buffs[buff_index].counters = e.poison_counters;
} else if (CalculateDiseaseCounters(buffs[buff_index].spellid) > 0) {
buffs[buff_index].counters = e.disease_counters;
} else if (CalculateCurseCounters(buffs[buff_index].spellid) > 0) {
buffs[buff_index].counters = e.curse_counters;
} else if (CalculateCorruptionCounters(buffs[buff_index].spellid) > 0) {
buffs[buff_index].counters = e.corruption_counters;
}
buffs[buff_index].hit_number = e.numhits;
buffs[buff_index].melee_rune = e.melee_rune;
buffs[buff_index].magic_rune = e.magic_rune;
buffs[buff_index].dot_rune = e.dot_rune;
buffs[buff_index].persistent_buff = e.persistent;
buffs[buff_index].caston_x = e.caston_x;
buffs[buff_index].caston_y = e.caston_y;
buffs[buff_index].caston_z = e.caston_z;
buffs[buff_index].ExtraDIChance = e.extra_di_chance;
buffs[buff_index].instrument_mod = e.instrument_mod;
buffs[buff_index].casterid = 0;
++buff_index;
}
return true;
@@ -691,8 +720,10 @@ bool BotDatabase::SaveBuffs(Bot* b)
e.spell_id = buffs[buff_index].spellid;
e.caster_level = buffs[buff_index].casterlevel;
e.caster_name = buffs[buff_index].caster_name;
e.duration_formula = spells[buffs[buff_index].spellid].buff_duration_formula;
e.tics_remaining = buffs[buff_index].ticsremaining;
e.initial_duration = buffs[buff_index].initialduration;
e.poison_counters = CalculatePoisonCounters(buffs[buff_index].spellid) > 0 ? buffs[buff_index].counters : 0;
e.disease_counters = CalculateDiseaseCounters(buffs[buff_index].spellid) > 0 ? buffs[buff_index].counters : 0;
e.curse_counters = CalculateCurseCounters(buffs[buff_index].spellid) > 0 ? buffs[buff_index].counters : 0;
@@ -701,7 +732,7 @@ bool BotDatabase::SaveBuffs(Bot* b)
e.melee_rune = buffs[buff_index].melee_rune;
e.magic_rune = buffs[buff_index].magic_rune;
e.dot_rune = buffs[buff_index].dot_rune;
e.persistent = buffs[buff_index].persistant_buff ? 1 : 0;
e.persistent = buffs[buff_index].persistent_buff ? 1 : 0;
e.caston_x = buffs[buff_index].caston_x;
e.caston_y = buffs[buff_index].caston_y;
e.caston_z = buffs[buff_index].caston_z;
@@ -1360,7 +1391,7 @@ bool BotDatabase::DeletePetStats(const uint32 bot_id)
return BotPetsRepository::DeleteOne(database, saved_pet_index) == 1;
}
bool BotDatabase::LoadPetBuffs(const uint32 bot_id, SpellBuff_Struct* pet_buffs)
bool BotDatabase::LoadPetBuffs(const uint32 bot_id, Buffs_Struct* pet_buffs)
{
if (!bot_id) {
return false;
@@ -1395,27 +1426,47 @@ bool BotDatabase::LoadPetBuffs(const uint32 bot_id, SpellBuff_Struct* pet_buffs)
break;
}
pet_buffs[buff_index].spellid = e.spell_id;
pet_buffs[buff_index].level = e.caster_level;
pet_buffs[buff_index].duration = e.duration;
Client* c = entity_list.GetClientByName(e.caster_name.c_str());
if (CalculatePoisonCounters(pet_buffs[buff_index].spellid) > 0) {
pet_buffs[buff_index].counters = CalculatePoisonCounters(pet_buffs[buff_index].spellid);
} else if (CalculateDiseaseCounters(pet_buffs[buff_index].spellid) > 0) {
pet_buffs[buff_index].counters = CalculateDiseaseCounters(pet_buffs[buff_index].spellid);
} else if (CalculateCurseCounters(pet_buffs[buff_index].spellid) > 0) {
pet_buffs[buff_index].counters = CalculateCurseCounters(pet_buffs[buff_index].spellid);
} else if (CalculateCorruptionCounters(pet_buffs[buff_index].spellid) > 0) {
pet_buffs[buff_index].counters = CalculateCorruptionCounters(pet_buffs[buff_index].spellid);
pet_buffs[buff_index].spellid = e.spell_id;
pet_buffs[buff_index].casterlevel = e.caster_level;
if (c) {
pet_buffs[buff_index].casterid = c->GetID();
pet_buffs[buff_index].client = true;
strncpy(pet_buffs[buff_index].caster_name, c->GetName(), 64);
} else {
pet_buffs[buff_index].casterid = 0;
pet_buffs[buff_index].client = false;
strncpy(pet_buffs[buff_index].caster_name, "", 64);
}
pet_buffs[buff_index].ticsremaining = e.tics_remaining;
pet_buffs[buff_index].initialduration = e.initial_duration;
pet_buffs[buff_index].counters = e.counters;
pet_buffs[buff_index].hit_number = e.numhits;
pet_buffs[buff_index].melee_rune = e.melee_rune;
pet_buffs[buff_index].magic_rune = e.magic_rune;
pet_buffs[buff_index].persistent_buff = e.persistent ? true : false;
pet_buffs[buff_index].dot_rune = e.dot_rune;
pet_buffs[buff_index].caston_x = e.caston_x;
pet_buffs[buff_index].caston_y = e.caston_y;
pet_buffs[buff_index].caston_z = e.caston_z;
pet_buffs[buff_index].ExtraDIChance = e.extra_di_chance;
pet_buffs[buff_index].RootBreakChance = 0;
pet_buffs[buff_index].virus_spread_time = 0;
pet_buffs[buff_index].UpdateClient = false;
pet_buffs[buff_index].instrument_mod = e.instrument_mod;
++buff_index;
}
return true;
}
bool BotDatabase::SavePetBuffs(const uint32 bot_id, const SpellBuff_Struct* pet_buffs, bool delete_flag)
bool BotDatabase::SavePetBuffs(const uint32 bot_id, const Buffs_Struct* pet_buffs, bool delete_flag)
{
if (
!bot_id ||
@@ -1446,9 +1497,22 @@ bool BotDatabase::SavePetBuffs(const uint32 bot_id, const SpellBuff_Struct* pet_
continue;
}
e.spell_id = pet_buffs[buff_index].spellid;
e.caster_level = pet_buffs[buff_index].level;
e.duration = pet_buffs[buff_index].duration;
e.spell_id = pet_buffs[buff_index].spellid;
e.caster_level = pet_buffs[buff_index].casterlevel;
e.caster_name = pet_buffs[buff_index].caster_name;
e.tics_remaining = pet_buffs[buff_index].ticsremaining;
e.initial_duration = pet_buffs[buff_index].initialduration;
e.counters = pet_buffs[buff_index].counters;
e.numhits = pet_buffs[buff_index].hit_number;
e.melee_rune = pet_buffs[buff_index].melee_rune;
e.magic_rune = pet_buffs[buff_index].magic_rune;
e.persistent = pet_buffs[buff_index].persistent_buff;
e.dot_rune = pet_buffs[buff_index].dot_rune;
e.caston_x = pet_buffs[buff_index].caston_x;
e.caston_y = pet_buffs[buff_index].caston_y;
e.caston_z = pet_buffs[buff_index].caston_z;
e.extra_di_chance = pet_buffs[buff_index].ExtraDIChance;
e.instrument_mod = pet_buffs[buff_index].instrument_mod;
v.emplace_back(e);
}