Core/Players: Check if player can enter the instance during login before trying to add him to map

* Fixes name displaying as "Unknown"

(cherry picked from commit 45994a177c128dc83ea01b0697377f7b74b5c4ba)
This commit is contained in:
Shauren committed 2015-10-29 18:59:06 +01:00
1 parent b1b72dafd0
commit c7bad70e55
3 files changed
+9 -11

No files matched your search

+7 -9
View File
@@ -17453,7 +17453,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
}
else if (map->IsDungeon()) // if map is dungeon...
{
if (!((InstanceMap*)map)->CanEnter(this)) // ... and can't enter map, then look for entry point.
if (!((InstanceMap*)map)->CanEnter(this) || !CheckInstanceLoginValid(map)) // ... and can't enter map, then look for entry point.
{
areaTrigger = sObjectMgr->GetGoBackTrigger(mapId);
check = true;
@@ -17480,6 +17480,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
{
TC_LOG_ERROR("entities.player", "Player %s %s Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.",
m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
RelocateToHomebind();
map = NULL;
}
}
@@ -19010,15 +19011,12 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report
return true;
}
bool Player::CheckInstanceLoginValid()
bool Player::CheckInstanceLoginValid(Map* map)
{
if (!FindMap())
return false;
if (!GetMap()->IsDungeon() || IsGameMaster())
if (!map->IsDungeon() || IsGameMaster())
return true;
if (GetMap()->IsRaid())
if (map->IsRaid())
{
// cannot be in raid instance without a group
if (!GetGroup())
@@ -19027,12 +19025,12 @@ bool Player::CheckInstanceLoginValid()
else
{
// cannot be in normal instance without a group and more players than 1 in instance
if (!GetGroup() && GetMap()->GetPlayersCountExceptGMs() > 1)
if (!GetGroup() && map->GetPlayersCountExceptGMs() > 1)
return false;
}
// do checks for satisfy accessreqs, instance full, encounter in progress (raid), perm bind group != perm bind player
return sMapMgr->CanPlayerEnter(GetMap()->GetId(), this, true);
return sMapMgr->CanPlayerEnter(map->GetId(), this, true);
}
bool Player::CheckInstanceCount(uint32 instanceId) const
+1 -1
View File
@@ -2198,7 +2198,7 @@ class Player : public Unit, public GridObject<Player>
void SendSavedInstances();
static void ConvertInstancesToGroup(Player* player, Group* group, bool switchLeader);
bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false);
bool CheckInstanceLoginValid();
bool CheckInstanceLoginValid(Map* map);
bool CheckInstanceCount(uint32 instanceId) const;
void AddInstanceEnterTime(uint32 instanceId, time_t enterTime);
@@ -887,7 +887,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
}
}
if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid())
if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar))
{
AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
if (at)