Skip to content

Commit f6de601

Browse files
Heliaslaasker
andauthored
new BattlegroundDesertionTypes for hook OnBattlegroundDesertion (azerothcore#20039)
* new BattlegroundDesertionTypes for hook OnBattlegroundDesertion * chore: minor improvements --------- Co-authored-by: laasker <[email protected]>
1 parent d822108 commit f6de601

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

src/server/game/Battlegrounds/Battleground.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ struct GraveyardStruct;
4747

4848
enum BattlegroundDesertionType : uint8
4949
{
50-
BG_DESERTION_TYPE_LEAVE_BG = 0, // player leaves the BG
51-
BG_DESERTION_TYPE_OFFLINE = 1, // player is kicked from BG because offline
52-
BG_DESERTION_TYPE_LEAVE_QUEUE = 2, // player is invited to join and refuses to do it
53-
BG_DESERTION_TYPE_NO_ENTER_BUTTON = 3, // player is invited to join and do nothing (time expires)
54-
BG_DESERTION_TYPE_INVITE_LOGOUT = 4, // player is invited to join and logs out
50+
BG_DESERTION_TYPE_LEAVE_BG = 0, // player leaves the BG
51+
BG_DESERTION_TYPE_OFFLINE = 1, // player is kicked from BG because offline
52+
BG_DESERTION_TYPE_LEAVE_QUEUE = 2, // player is invited to join and refuses to do it
53+
BG_DESERTION_TYPE_NO_ENTER_BUTTON = 3, // player is invited to join and do nothing (time expires)
54+
BG_DESERTION_TYPE_INVITE_LOGOUT = 4, // player is invited to join and logs out
55+
ARENA_DESERTION_TYPE_LEAVE_BG = 5, // player leaves the Arena
56+
ARENA_DESERTION_TYPE_LEAVE_QUEUE = 6, // player is invited to join arena and refuses to do it
57+
ARENA_DESERTION_TYPE_NO_ENTER_BUTTON = 7, // player is invited to join arena and do nothing (time expires)
58+
ARENA_DESERTION_TYPE_INVITE_LOGOUT = 8, // player is invited to join arena and logs out
5559
};
5660

5761
enum BattlegroundMaps

src/server/game/Battlegrounds/BattlegroundQueue.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,9 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
13571357
sScriptMgr->OnBattlegroundDesertion(player, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
13581358
}
13591359

1360+
if (bg && bg->isArena() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
1361+
sScriptMgr->OnBattlegroundDesertion(player, ARENA_DESERTION_TYPE_NO_ENTER_BUTTON);
1362+
13601363
LOG_DEBUG("bg.battleground", "Battleground: removing player {} from bg queue for instance {} because of not pressing enter battle in time.", player->GetGUID().ToString(), m_BgInstanceGUID);
13611364

13621365
player->RemoveBattlegroundQueueId(m_BgQueueTypeId);

src/server/game/Entities/Player/Player.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11336,6 +11336,9 @@ void Player::LeaveBattleground(Battleground* bg)
1133611336
sScriptMgr->OnBattlegroundDesertion(this, BG_DESERTION_TYPE_LEAVE_BG);
1133711337
}
1133811338

11339+
if (bg->isArena() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
11340+
sScriptMgr->OnBattlegroundDesertion(this, ARENA_DESERTION_TYPE_LEAVE_BG);
11341+
1133911342
bg->RemovePlayerAtLeave(this);
1134011343

1134111344
// xinef: reset corpse reclaim time

src/server/game/Handlers/BattleGroundHandler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)
580580

581581
sScriptMgr->OnBattlegroundDesertion(_player, BG_DESERTION_TYPE_LEAVE_QUEUE);
582582
}
583+
584+
if (bg->isArena() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
585+
sScriptMgr->OnBattlegroundDesertion(_player, ARENA_DESERTION_TYPE_LEAVE_QUEUE);
583586
}
584587
}
585588

src/server/game/Server/WorldSession.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@ void WorldSession::LogoutPlayer(bool save)
637637
sScriptMgr->OnBattlegroundDesertion(_player, BG_DESERTION_TYPE_INVITE_LOGOUT);
638638
}
639639

640+
if (bgQueueTypeId >= BATTLEGROUND_QUEUE_2v2 && bgQueueTypeId < MAX_BATTLEGROUND_QUEUE_TYPES && _player->IsInvitedForBattlegroundQueueType(bgQueueTypeId))
641+
sScriptMgr->OnBattlegroundDesertion(_player, ARENA_DESERTION_TYPE_INVITE_LOGOUT);
642+
640643
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
641644
sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).RemovePlayer(_player->GetGUID(), true);
642645
}

0 commit comments

Comments
 (0)