mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Fix compile && better solution for previos patch, by Spp
--HG-- branch : trunk
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "Transports.h"
|
||||
#include "GridDefines.h"
|
||||
#include "MapInstanced.h"
|
||||
#include "InstanceData.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
#include "World.h"
|
||||
#include "CellImpl.h"
|
||||
@@ -229,10 +230,48 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player)
|
||||
}
|
||||
}
|
||||
|
||||
//Get instance where player is bound
|
||||
InstancePlayerBind* boundedInstance = player->GetBoundInstance(mapid, player->GetDifficulty());
|
||||
Map *boundedMap;
|
||||
|
||||
//Search player's instance map
|
||||
for(MapMapType::iterator itr = i_maps.find(mapid); itr != i_maps.end(); )
|
||||
{
|
||||
Map *map = itr->second;
|
||||
if(!map->Instanceable())
|
||||
break;
|
||||
MapInstanced::InstancedMaps &maps = ((MapInstanced *)map)->GetInstancedMaps();
|
||||
for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
|
||||
if (boundedInstance->save->GetInstanceId() == mitr->first)
|
||||
boundedMap = map;
|
||||
}
|
||||
//Encounters in progress
|
||||
if (boundedMap && ((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);
|
||||
}
|
||||
|
||||
// Requirements
|
||||
InstanceTemplate const* instance = objmgr.GetInstanceTemplate(mapid);
|
||||
if(!instance)
|
||||
return false;
|
||||
|
||||
//Instance is full
|
||||
if (boundedMap)
|
||||
{
|
||||
Map::PlayerList const &players = boundedMap->GetPlayers();
|
||||
uint8 count = 0;
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
++count;
|
||||
if (count == player->GetDifficulty() ? instance->maxPlayersHeroic : instance->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 player->Satisfy(objmgr.GetAccessRequirement(instance->access_id), mapid, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user