Skip to content

Commit

Permalink
new BattlegroundDesertionTypes for hook OnBattlegroundDesertion (azer…
Browse files Browse the repository at this point in the history
…othcore#20039)

* new BattlegroundDesertionTypes for hook OnBattlegroundDesertion

* chore: minor improvements

---------

Co-authored-by: laasker <[email protected]>
  • Loading branch information
Helias and laasker authored Sep 27, 2024
1 parent d822108 commit f6de601
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/server/game/Battlegrounds/Battleground.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ struct GraveyardStruct;

enum BattlegroundDesertionType : uint8
{
BG_DESERTION_TYPE_LEAVE_BG = 0, // player leaves the BG
BG_DESERTION_TYPE_OFFLINE = 1, // player is kicked from BG because offline
BG_DESERTION_TYPE_LEAVE_QUEUE = 2, // player is invited to join and refuses to do it
BG_DESERTION_TYPE_NO_ENTER_BUTTON = 3, // player is invited to join and do nothing (time expires)
BG_DESERTION_TYPE_INVITE_LOGOUT = 4, // player is invited to join and logs out
BG_DESERTION_TYPE_LEAVE_BG = 0, // player leaves the BG
BG_DESERTION_TYPE_OFFLINE = 1, // player is kicked from BG because offline
BG_DESERTION_TYPE_LEAVE_QUEUE = 2, // player is invited to join and refuses to do it
BG_DESERTION_TYPE_NO_ENTER_BUTTON = 3, // player is invited to join and do nothing (time expires)
BG_DESERTION_TYPE_INVITE_LOGOUT = 4, // player is invited to join and logs out
ARENA_DESERTION_TYPE_LEAVE_BG = 5, // player leaves the Arena
ARENA_DESERTION_TYPE_LEAVE_QUEUE = 6, // player is invited to join arena and refuses to do it
ARENA_DESERTION_TYPE_NO_ENTER_BUTTON = 7, // player is invited to join arena and do nothing (time expires)
ARENA_DESERTION_TYPE_INVITE_LOGOUT = 8, // player is invited to join arena and logs out
};

enum BattlegroundMaps
Expand Down
3 changes: 3 additions & 0 deletions src/server/game/Battlegrounds/BattlegroundQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,9 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
sScriptMgr->OnBattlegroundDesertion(player, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
}

if (bg && bg->isArena() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
sScriptMgr->OnBattlegroundDesertion(player, ARENA_DESERTION_TYPE_NO_ENTER_BUTTON);

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);

player->RemoveBattlegroundQueueId(m_BgQueueTypeId);
Expand Down
3 changes: 3 additions & 0 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11336,6 +11336,9 @@ void Player::LeaveBattleground(Battleground* bg)
sScriptMgr->OnBattlegroundDesertion(this, BG_DESERTION_TYPE_LEAVE_BG);
}

if (bg->isArena() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
sScriptMgr->OnBattlegroundDesertion(this, ARENA_DESERTION_TYPE_LEAVE_BG);

bg->RemovePlayerAtLeave(this);

// xinef: reset corpse reclaim time
Expand Down
3 changes: 3 additions & 0 deletions src/server/game/Handlers/BattleGroundHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)

sScriptMgr->OnBattlegroundDesertion(_player, BG_DESERTION_TYPE_LEAVE_QUEUE);
}

if (bg->isArena() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
sScriptMgr->OnBattlegroundDesertion(_player, ARENA_DESERTION_TYPE_LEAVE_QUEUE);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/server/game/Server/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ void WorldSession::LogoutPlayer(bool save)
sScriptMgr->OnBattlegroundDesertion(_player, BG_DESERTION_TYPE_INVITE_LOGOUT);
}

if (bgQueueTypeId >= BATTLEGROUND_QUEUE_2v2 && bgQueueTypeId < MAX_BATTLEGROUND_QUEUE_TYPES && _player->IsInvitedForBattlegroundQueueType(bgQueueTypeId))
sScriptMgr->OnBattlegroundDesertion(_player, ARENA_DESERTION_TYPE_INVITE_LOGOUT);

_player->RemoveBattlegroundQueueId(bgQueueTypeId);
sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).RemovePlayer(_player->GetGUID(), true);
}
Expand Down

0 comments on commit f6de601

Please sign in to comment.