Some additional checks to Login Instance check. + code layout.
--HG-- branch : trunk
This commit is contained in:
+17
-23
@@ -162,18 +162,18 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
const MapEntry *entry = sMapStore.LookupEntry(mapid);
|
||||
if (!entry)
|
||||
return false;
|
||||
|
||||
if (!entry->IsDungeon())
|
||||
return true;
|
||||
|
||||
const char *mapName = entry->name[player->GetSession()->GetSessionDbcLocale()];
|
||||
|
||||
if (entry->map_type == MAP_INSTANCE || entry->map_type == MAP_RAID)
|
||||
{
|
||||
if (entry->map_type == MAP_RAID)
|
||||
{
|
||||
// GMs can avoid raid limitations
|
||||
if (!player->isGameMaster() && !sWorld.getConfig(CONFIG_INSTANCE_IGNORE_RAID))
|
||||
Group* pGroup = player->GetGroup();
|
||||
if (entry->IsRaid())
|
||||
{
|
||||
// can only enter in a raid group
|
||||
Group* group = player->GetGroup();
|
||||
if (!group || !group->isRaidGroup())
|
||||
// GMs can avoid raid limitations
|
||||
if ((!pGroup || !pGroup->isRaidGroup()) && !player->isGameMaster() && !sWorld.getConfig(CONFIG_INSTANCE_IGNORE_RAID))
|
||||
{
|
||||
// probably there must be special opcode, because client has this string constant in GlobalStrings.lua
|
||||
// TODO: this is not a good place to send the message
|
||||
@@ -182,13 +182,12 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//The player has a heroic mode and tries to enter into instance which has no a heroic mode
|
||||
MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID,player->GetDifficulty(entry->map_type == MAP_RAID));
|
||||
MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID,player->GetDifficulty(entry->IsRaid()));
|
||||
if (!mapDiff)
|
||||
{
|
||||
bool isNormalTargetMap = entry->map_type == MAP_RAID
|
||||
bool isNormalTargetMap = entry->IsRaid()
|
||||
? (player->GetRaidDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL)
|
||||
: (player->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL);
|
||||
|
||||
@@ -224,9 +223,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
sLog.outDebug("MAP: Player '%s' has corpse in instance '%s' and can enter", player->GetName(), mapName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outDebug("Map::CanEnter - player '%s' is dead but doesn't have a corpse!", player->GetName());
|
||||
}
|
||||
sLog.outDebug("Map::CanPlayerEnter - player '%s' is dead but doesn't have a corpse!", player->GetName());
|
||||
}
|
||||
|
||||
InstanceTemplate const* instance = objmgr.GetInstanceTemplate(mapid);
|
||||
@@ -234,9 +231,9 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
return false;
|
||||
|
||||
//Get instance where player's group is bound & its map
|
||||
if (player->GetGroup())
|
||||
if (pGroup)
|
||||
{
|
||||
InstanceGroupBind* boundedInstance = player->GetGroup()->GetBoundInstance(player);
|
||||
InstanceGroupBind* boundedInstance = pGroup->GetBoundInstance(player);
|
||||
if (boundedInstance && boundedInstance->save)
|
||||
{
|
||||
if (Map *boundedMap = MapManager::Instance().FindMap(mapid,boundedInstance->save->GetInstanceId()))
|
||||
@@ -251,11 +248,11 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
}
|
||||
|
||||
// Encounters in progress
|
||||
if (entry->map_type == MAP_RAID && ((InstanceMap*)boundedMap)->GetInstanceData() && ((InstanceMap*)boundedMap)->GetInstanceData()->IsEncounterInProgress())
|
||||
if (!loginCHeck && entry->IsRaid() && ((InstanceMap*)boundedMap)->GetInstanceData() && ((InstanceMap*)boundedMap)->GetInstanceData()->IsEncounterInProgress())
|
||||
{
|
||||
sLog.outDebug("MAP: Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), mapName);
|
||||
player->SendTransferAborted(mapid, TRANSFER_ABORT_ZONE_IN_COMBAT);
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Instance is full
|
||||
@@ -263,11 +260,11 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
int8 maxPlayers = mapDiff ? mapDiff->maxPlayers : 0;
|
||||
if (maxPlayers != -1) //-1: unlimited access
|
||||
{
|
||||
if (loginCheck ? boundedMap->GetPlayersCountExceptGMs() > maxPlayers : boundedMap->GetPlayersCountExceptGMs() >= maxPlayers)
|
||||
if (boundedMap->GetPlayersCountExceptGMs() >= (loginCheck ? maxPlayers+1 : maxPlayers))
|
||||
{
|
||||
sLog.outDebug("MAP: Player '%s' can't enter instance '%s' because it's full.", player->GetName(), mapName);
|
||||
player->SendTransferAborted(mapid, TRANSFER_ABORT_MAX_PLAYERS);
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,9 +274,6 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
//Other requirements
|
||||
return player->Satisfy(objmgr.GetAccessRequirement(instance->access_id), mapid, true);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void MapManager::RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y)
|
||||
{
|
||||
|
||||
@@ -918,23 +918,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
|
||||
return;
|
||||
|
||||
// check if player can enter instance : instance not full, and raid instance not in encounter fight
|
||||
if (Map * newMap = MapManager::Instance().CreateMap(at->target_mapId, GetPlayer(), 0))
|
||||
{
|
||||
if (newMap && newMap->IsDungeon() && ((InstanceMap*)newMap)->GetInstanceData() && ((InstanceMap*)newMap)->GetMapDifficulty())
|
||||
{
|
||||
if (newMap->GetPlayersCountExceptGMs() >= ((InstanceMap*)newMap)->GetMapDifficulty()->maxPlayers)
|
||||
{
|
||||
GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_MAX_PLAYERS);
|
||||
if (!MapManager::Instance().CanPlayerEnter(at->target_mapId, GetPlayer(), false))
|
||||
return;
|
||||
}
|
||||
|
||||
if (newMap->IsRaid() && ((InstanceMap*)newMap)->GetInstanceData()->IsEncounterInProgress())
|
||||
{
|
||||
GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_ZONE_IN_COMBAT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT);
|
||||
}
|
||||
|
||||
+2
-2
@@ -17357,8 +17357,8 @@ bool Player::CheckInstanceLoginValid()
|
||||
|
||||
if (GetMap()->IsRaid())
|
||||
{
|
||||
// cannot be in raid instance without a group
|
||||
if (!GetGroup())
|
||||
// cannot be in raid instance without a raid group
|
||||
if (!GetGroup() || !GetGroup()->isRaidGroup())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user