fix(Core): Deserter overrides from BG and Command (#11961)

* fix(Core/Command): Deserter offline add

* feat(Core/Command): Deserter online add restriction

* fix(Core/Battleground): Deserter overrides longer debuff
This commit is contained in:
Kempec Halk
2022-06-13 13:58:49 +02:00
committed by GitHub
parent 8cbc1b0a55
commit 8e7c4fa226
2 changed files with 26 additions and 2 deletions

View File

@@ -117,8 +117,14 @@ public:
if (target)
{
Aura* aura = target->AddAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER, target);
Aura* aura = target->GetAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
if (aura && aura->GetDuration() >= (int32)time * IN_MILLISECONDS)
{
handler->PSendSysMessage("Player %s already has a longer %s Deserter active.", handler->playerLink(player->GetName()), isInstance ? "Instance" : "Battleground");
return true;
}
aura = target->AddAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER, target);
if (!aura)
{
handler->SendSysMessage(LANG_BAD_VALUE);
@@ -130,6 +136,20 @@ public:
return true;
}
int32 duration = 0;
if (QueryResult result = CharacterDatabase.Query("SELECT remainTime FROM character_aura WHERE guid = {} AND spell = {}", player->GetGUID().GetCounter(), isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER))
{
Field* fields = result->Fetch();
duration = fields[0].Get<int32>();
if (duration < 0 || duration >= (int32)time * IN_MILLISECONDS)
{
handler->PSendSysMessage("Player %s already has a longer %s Deserter active.", handler->playerLink(player->GetName()), isInstance ? "Instance" : "Battleground");
return true;
}
CharacterDatabase.Query("DELETE FROM character_aura WHERE guid = {} AND spell = {}", player->GetGUID().GetCounter(), isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
}
uint8 index = 0;
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA);
stmt->SetData(index++, player->GetGUID().GetCounter());