Merge pull request #4587 from wilds/fix_reenter_bg

Core/Battleground: Fix re-entering battlegrounds after disconnect
Closes #90
This commit is contained in:
Shocker
2012-01-04 13:18:05 -08:00
3 changed files with 13 additions and 7 deletions
@@ -1245,8 +1245,6 @@ void Battleground::EventPlayerLoggedOut(Player* player)
if (GetAlivePlayersCountByTeam(player->GetTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetTeam()))) if (GetAlivePlayersCountByTeam(player->GetTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetTeam())))
EndBattleground(GetOtherTeam(player->GetTeam())); EndBattleground(GetOtherTeam(player->GetTeam()));
} }
player->LeaveBattleground();
} }
// This method should be called only once ... it adds pointer to queue // This method should be called only once ... it adds pointer to queue
+3 -3
View File
@@ -16670,10 +16670,10 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
if (player_at_bg && currentBg->GetStatus() != STATUS_WAIT_LEAVE) if (player_at_bg && currentBg->GetStatus() != STATUS_WAIT_LEAVE)
{ {
BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(currentBg->GetTypeID(true), currentBg->GetArenaType()); BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(currentBg->GetTypeID(), currentBg->GetArenaType());
AddBattlegroundQueueId(bgQueueTypeId); AddBattlegroundQueueId(bgQueueTypeId);
m_bgData.bgTypeID = currentBg->GetTypeID(true); m_bgData.bgTypeID = currentBg->GetTypeID();
//join player to battleground group //join player to battleground group
currentBg->EventPlayerLoggedIn(this); currentBg->EventPlayerLoggedIn(this);
@@ -16845,7 +16845,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
} }
// if the player is in an instance and it has been reset in the meantime teleport him to the entrance // if the player is in an instance and it has been reset in the meantime teleport him to the entrance
if (instanceId && !sInstanceSaveMgr->GetInstanceSave(instanceId)) if (instanceId && !sInstanceSaveMgr->GetInstanceSave(instanceId) && !map->IsBattlegroundOrArena())
{ {
AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(mapId); AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(mapId);
if (at) if (at)
+10 -2
View File
@@ -124,9 +124,17 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
// the instance id is set in battlegroundid // the instance id is set in battlegroundid
NewInstanceId = player->GetBattlegroundId(); NewInstanceId = player->GetBattlegroundId();
if (!NewInstanceId) return NULL; if (!NewInstanceId) return NULL;
map = FindInstanceMap(NewInstanceId); map = sMapMgr->FindMap(mapId, NewInstanceId);
if (!map) if (!map)
map = CreateBattleground(NewInstanceId, player->GetBattleground()); {
if (Battleground* bg = player->GetBattleground())
map = CreateBattleground(NewInstanceId, bg);
else
{
player->TeleportToBGEntryPoint();
return NULL;
}
}
} }
else else
{ {