Fix custom spells persisting cross zone, food/drink as an example

This commit is contained in:
Emagi 2022-10-30 16:39:29 -04:00
parent 7c95b36ac2
commit be924b2306
4 changed files with 20 additions and 11 deletions

View file

@ -6590,7 +6590,7 @@ void Player::SaveSpellEffects()
effectSave.AddQueryAsync(GetCharacterID(), &database, Q_INSERT,
"insert into character_spell_effects (name, caster_char_id, target_char_id, target_type, db_effect_type, spell_id, effect_slot, slot_pos, icon, icon_backdrop, conc_used, tier, total_time, expire_timestamp, lua_file, custom_spell, charid, damage_remaining, effect_bitmask, num_triggers, had_triggers, cancel_after_triggers, crit, last_spellattack_hit, interrupted, resisted, custom_function) values ('%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %f, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, '%s')",
database.getSafeEscapeString(info->spell_effects[i].spell->spell->GetName()).c_str(), caster_char_id,
target_char_id, 0 /*no target_type for spell_effects*/, DB_TYPE_SPELLEFFECTS /* db_effect_type for spell_effects */, info->spell_effects[i].spell_id, i, info->spell_effects[i].spell->slot_pos,
target_char_id, 0 /*no target_type for spell_effects*/, DB_TYPE_SPELLEFFECTS /* db_effect_type for spell_effects */, info->spell_effects[i].spell->spell->IsCopiedSpell() ? info->spell_effects[i].spell->spell->GetSpellData()->inherited_spell_id : info->spell_effects[i].spell_id, i, info->spell_effects[i].spell->slot_pos,
info->spell_effects[i].icon, info->spell_effects[i].icon_backdrop, 0 /* no conc_used for spell_effects */, info->spell_effects[i].tier,
info->spell_effects[i].total_time, timestamp, database.getSafeEscapeString(info->spell_effects[i].spell->file_name.c_str()).c_str(), info->spell_effects[i].spell->spell->IsCopiedSpell(), GetCharacterID(),
info->spell_effects[i].spell->damage_remaining, info->spell_effects[i].spell->effect_bitmask, info->spell_effects[i].spell->num_triggers, info->spell_effects[i].spell->had_triggers, info->spell_effects[i].spell->cancel_after_all_triggers,
@ -6618,7 +6618,7 @@ void Player::SaveSpellEffects()
Query effectSave;
effectSave.AddQueryAsync(GetCharacterID(), &database, Q_INSERT,
"insert into character_spell_effects (name, caster_char_id, target_char_id, target_type, db_effect_type, spell_id, effect_slot, slot_pos, icon, icon_backdrop, conc_used, tier, total_time, expire_timestamp, lua_file, custom_spell, charid, damage_remaining, effect_bitmask, num_triggers, had_triggers, cancel_after_triggers, crit, last_spellattack_hit, interrupted, resisted, custom_function) values ('%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %f, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, '%s')",
database.getSafeEscapeString(info->maintained_effects[i].name).c_str(), caster_char_id, target_char_id, info->maintained_effects[i].target_type, DB_TYPE_MAINTAINEDEFFECTS /* db_effect_type for maintained_effects */, info->maintained_effects[i].spell_id, i, info->maintained_effects[i].slot_pos,
database.getSafeEscapeString(info->maintained_effects[i].name).c_str(), caster_char_id, target_char_id, info->maintained_effects[i].target_type, DB_TYPE_MAINTAINEDEFFECTS /* db_effect_type for maintained_effects */, info->maintained_effects[i].spell->spell->IsCopiedSpell() ? info->maintained_effects[i].spell->spell->GetSpellData()->inherited_spell_id : info->maintained_effects[i].spell_id, i, info->maintained_effects[i].slot_pos,
info->maintained_effects[i].icon, info->maintained_effects[i].icon_backdrop, info->maintained_effects[i].conc_used, info->maintained_effects[i].tier,
info->maintained_effects[i].total_time, timestamp, database.getSafeEscapeString(info->maintained_effects[i].spell->file_name.c_str()).c_str(), info->maintained_effects[i].spell->spell->IsCopiedSpell(), GetCharacterID(),
info->maintained_effects[i].spell->damage_remaining, info->maintained_effects[i].spell->effect_bitmask, info->maintained_effects[i].spell->num_triggers, info->maintained_effects[i].spell->had_triggers, info->maintained_effects[i].spell->cancel_after_all_triggers,

View file

@ -48,7 +48,7 @@ Spell::Spell(){
copied_spell = false;
}
Spell::Spell(Spell* host_spell)
Spell::Spell(Spell* host_spell, bool unique_spell)
{
std::shared_lock lock(host_spell->MSpellInfo);
copied_spell = true;
@ -57,14 +57,21 @@ Spell::Spell(Spell* host_spell)
if (host_spell->GetSpellData())
{
// try inheriting an existing custom spell id, otherwise obtain the new highest number on the spell list
int32 tmpid = lua_interface->GetFreeCustomSpellID();
if (tmpid)
spell->id = tmpid;
else
{
spell->id = master_spell_list.GetNewMaxSpellID();
if(!unique_spell) {
spell->id = host_spell->GetSpellData()->id;
}
else {
// try inheriting an existing custom spell id, otherwise obtain the new highest number on the spell list
int32 tmpid = lua_interface->GetFreeCustomSpellID();
if (tmpid)
spell->id = tmpid;
else
{
spell->id = master_spell_list.GetNewMaxSpellID();
}
}
spell->inherited_spell_id = host_spell->GetSpellData()->inherited_spell_id;
spell->affect_only_group_members = host_spell->GetSpellData()->affect_only_group_members;
spell->call_frequency = host_spell->GetSpellData()->call_frequency;

View file

@ -226,6 +226,7 @@ struct SpellDisplayEffect{
struct SpellData{
int32 spell_book_type;
int32 id;
int32 inherited_spell_id;
sint16 icon;
int16 icon_heroic_op;
int16 icon_backdrop;
@ -302,7 +303,7 @@ public:
~Spell();
Spell();
Spell(SpellData* in_spell);
Spell(Spell* host_spell);
Spell(Spell* host_spell, bool unique_spell = true);
EQ2Packet* SerializeSpell(Client* client, bool display, bool trait_display = false, int8 packet_type = 0, int8 sub_packet_type = 0, const char* struct_name = 0);
EQ2Packet* SerializeSpecialSpell(Client* client, bool display, int8 packet_type = 0, int8 sub_packet_type = 0);
EQ2Packet* SerializeAASpell(Client* client,int8 tier, AltAdvanceData* data, bool display, bool trait_display = false, int8 packet_type = 0, int8 sub_packet_type = 0, const char* struct_name = 0);

View file

@ -4679,6 +4679,7 @@ void WorldDatabase::LoadSpells()
/* General Spell info */
data->id = spell_id;
data->inherited_spell_id = spell_id;
data->soe_spell_crc = result.GetInt32Str("soe_spell_crc");
data->tier = result.GetInt8Str("tier");
data->ts_loc_index = result.GetInt8Str("index");