fix(Core/BG): invited count leak when a BG teleport fails + group join checks (#26422)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Francesco Borzì
2026-07-03 02:05:23 +02:00
committed by GitHub
parent b66ea07190
commit c606a246bf
3 changed files with 13 additions and 3 deletions
@@ -252,7 +252,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
} }
}); });
if (err) if (err > 0)
{ {
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0); err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
} }
@@ -152,7 +152,17 @@ void WorldSession::HandleMoveWorldportAck()
{ {
// but landed on another map, cleanup data // but landed on another map, cleanup data
if (!mEntry->IsBattlegroundOrArena()) if (!mEntry->IsBattlegroundOrArena())
{
// release the unconsumed invite, otherwise the BG never satisfies its empty + uninvited deletion gate
if (Battleground* bg = _player->GetBattleground(true))
if (_player->IsInvitedForBattlegroundInstance(bg->GetInstanceID()))
{
bg->DecreaseInvitedCount(_player->GetBgTeamId());
_player->RemoveBattlegroundQueueId(BattlegroundMgr::BGQueueTypeId(bg->GetBgTypeID(), bg->GetArenaType()));
}
_player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE, PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL); _player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE, PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL);
}
// everything ok // everything ok
else if (Battleground* bg = _player->GetBattleground()) else if (Battleground* bg = _player->GetBattleground())
{ {
+2 -2
View File
@@ -1639,7 +1639,7 @@ void World::InitMonthlyQuestResetTime()
void World::InitRandomBGResetTime() void World::InitRandomBGResetTime()
{ {
Seconds wstime = Seconds(sWorldState->getWorldState(WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME)); Seconds wstime = Seconds(sWorldState->getWorldState(WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME));
_nextRandomBGReset = wstime > 0s ? wstime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, 6)); _nextRandomBGReset = wstime > 0s ? wstime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_RANDOM_BG_RESET_HOUR)));
if (wstime == 0s) if (wstime == 0s)
{ {
@@ -1772,7 +1772,7 @@ void World::ResetRandomBG()
if (itr->second->GetPlayer()) if (itr->second->GetPlayer())
itr->second->GetPlayer()->SetRandomWinner(false); itr->second->GetPlayer()->SetRandomWinner(false);
_nextRandomBGReset = Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, 6)); _nextRandomBGReset = Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_RANDOM_BG_RESET_HOUR)));
sWorldState->setWorldState(WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME, _nextRandomBGReset.count()); sWorldState->setWorldState(WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME, _nextRandomBGReset.count());
} }