mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Merge pull request #16110 from Treeston/3.3.5-instancerevive
Game/Maps: Clean up instance zone-in handling
(cherry picked from commit eb3dc8a4f0)
This commit is contained in:
@@ -3062,62 +3062,38 @@ void InstanceMap::InitVisibilityDistance()
|
||||
/*
|
||||
Do map specific checks to see if the player can enter
|
||||
*/
|
||||
bool InstanceMap::CanEnter(Player* player)
|
||||
Map::EnterState InstanceMap::CannotEnter(Player* player)
|
||||
{
|
||||
if (player->GetMapRef().getTarget() == this)
|
||||
{
|
||||
TC_LOG_ERROR("maps", "InstanceMap::CanEnter - player %s(%s) already in map %d, %d, %d!", player->GetName().c_str(), player->GetGUID().ToString().c_str(), GetId(), GetInstanceId(), GetSpawnMode());
|
||||
TC_LOG_ERROR("maps", "InstanceMap::CannotEnter - player %s(%s) already in map %d, %d, %d!", player->GetName().c_str(), player->GetGUID().ToString().c_str(), GetId(), GetInstanceId(), GetSpawnMode());
|
||||
ABORT();
|
||||
return false;
|
||||
return CANNOT_ENTER_ALREADY_IN_MAP;
|
||||
}
|
||||
|
||||
// allow GM's to enter
|
||||
if (player->IsGameMaster())
|
||||
return Map::CanEnter(player);
|
||||
return Map::CannotEnter(player);
|
||||
|
||||
// cannot enter if the instance is full (player cap), GMs don't count
|
||||
uint32 maxPlayers = GetMaxPlayers();
|
||||
if (GetPlayersCountExceptGMs() >= maxPlayers)
|
||||
{
|
||||
TC_LOG_WARN("maps", "MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName().c_str());
|
||||
player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS);
|
||||
return false;
|
||||
return CANNOT_ENTER_MAX_PLAYERS;
|
||||
}
|
||||
|
||||
// cannot enter while an encounter is in progress
|
||||
// allow if just loading
|
||||
// cannot enter while an encounter is in progress (unless this is a relog, in which case it is permitted)
|
||||
if (!player->IsLoading() && IsRaid() && GetInstanceScript() && GetInstanceScript()->IsEncounterInProgress())
|
||||
{
|
||||
player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT);
|
||||
return false;
|
||||
}
|
||||
return CANNOT_ENTER_ZONE_IN_COMBAT;
|
||||
|
||||
// cannot enter if instance is in use by another party/soloer that have a
|
||||
// permanent save in the same instance id
|
||||
// cannot enter if player is permanent saved to a different instance id
|
||||
if (InstancePlayerBind* playerBind = player->GetBoundInstance(GetId(), GetDifficultyID()))
|
||||
if (playerBind->perm && playerBind->save)
|
||||
if (playerBind->save->GetInstanceId() != GetInstanceId())
|
||||
return CANNOT_ENTER_INSTANCE_BIND_MISMATCH;
|
||||
|
||||
PlayerList const &playerList = GetPlayers();
|
||||
|
||||
if (!playerList.isEmpty())
|
||||
for (PlayerList::const_iterator i = playerList.begin(); i != playerList.end(); ++i)
|
||||
if (Player* iPlayer = i->GetSource())
|
||||
{
|
||||
if (iPlayer->IsGameMaster()) // bypass GMs
|
||||
continue;
|
||||
if (!player->GetGroup()) // player has not group and there is someone inside, deny entry
|
||||
{
|
||||
player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS);
|
||||
return false;
|
||||
}
|
||||
// player inside instance has no group or his groups is different to entering player's one, deny entry
|
||||
if (!iPlayer->GetGroup() || iPlayer->GetGroup() != player->GetGroup())
|
||||
{
|
||||
player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Map::CanEnter(player);
|
||||
return Map::CannotEnter(player);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3474,21 +3450,21 @@ void BattlegroundMap::InitVisibilityDistance()
|
||||
m_VisibilityNotifyPeriod = World::GetVisibilityNotifyPeriodInBGArenas();
|
||||
}
|
||||
|
||||
bool BattlegroundMap::CanEnter(Player* player)
|
||||
Map::EnterState BattlegroundMap::CannotEnter(Player* player)
|
||||
{
|
||||
if (player->GetMapRef().getTarget() == this)
|
||||
{
|
||||
TC_LOG_ERROR("maps", "BGMap::CanEnter - %s is already in map!", player->GetGUID().ToString().c_str());
|
||||
TC_LOG_ERROR("maps", "BGMap::CannotEnter - player %s is already in map!", player->GetGUID().ToString().c_str());
|
||||
ABORT();
|
||||
return false;
|
||||
return CANNOT_ENTER_ALREADY_IN_MAP;
|
||||
}
|
||||
|
||||
if (player->GetBattlegroundId() != GetInstanceId())
|
||||
return false;
|
||||
return CANNOT_ENTER_INSTANCE_BIND_MISMATCH;
|
||||
|
||||
// player number limit is checked in bgmgr, no need to do it here
|
||||
|
||||
return Map::CanEnter(player);
|
||||
return Map::CannotEnter(player);
|
||||
}
|
||||
|
||||
bool BattlegroundMap::AddPlayerToMap(Player* player, bool initPlayer /*= true*/)
|
||||
|
||||
Reference in New Issue
Block a user