MapManager: Block access to instances if encounter in progress or are full
--HG-- branch : trunk
This commit is contained in:
+34
-1
@@ -30,6 +30,7 @@
|
|||||||
#include "Transports.h"
|
#include "Transports.h"
|
||||||
#include "GridDefines.h"
|
#include "GridDefines.h"
|
||||||
#include "MapInstanced.h"
|
#include "MapInstanced.h"
|
||||||
|
#include "InstanceData.h"
|
||||||
#include "DestinationHolderImp.h"
|
#include "DestinationHolderImp.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "CellImpl.h"
|
#include "CellImpl.h"
|
||||||
@@ -229,11 +230,43 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requirements
|
|
||||||
InstanceTemplate const* instance = objmgr.GetInstanceTemplate(mapid);
|
InstanceTemplate const* instance = objmgr.GetInstanceTemplate(mapid);
|
||||||
if(!instance)
|
if(!instance)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//Get instance where player's group is bound & its map
|
||||||
|
if (player->GetGroup())
|
||||||
|
{
|
||||||
|
InstanceGroupBind* boundedInstance = player->GetGroup()->GetBoundInstance(mapid, player->GetDifficulty());
|
||||||
|
if (boundedInstance && boundedInstance->save)
|
||||||
|
{
|
||||||
|
Map *boundedMap = MapManager::Instance().FindMap(mapid,boundedInstance->save->GetInstanceId());
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Other requirements
|
||||||
return player->Satisfy(objmgr.GetAccessRequirement(instance->access_id), mapid, true);
|
return player->Satisfy(objmgr.GetAccessRequirement(instance->access_id), mapid, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -19466,6 +19466,8 @@ void Player::SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg)
|
|||||||
case TRANSFER_ABORT_INSUF_EXPAN_LVL:
|
case TRANSFER_ABORT_INSUF_EXPAN_LVL:
|
||||||
case TRANSFER_ABORT_DIFFICULTY:
|
case TRANSFER_ABORT_DIFFICULTY:
|
||||||
case TRANSFER_ABORT_UNIQUE_MESSAGE:
|
case TRANSFER_ABORT_UNIQUE_MESSAGE:
|
||||||
|
case TRANSFER_ABORT_ZONE_IN_COMBAT:
|
||||||
|
case TRANSFER_ABORT_MAX_PLAYERS:
|
||||||
data << uint8(arg);
|
data << uint8(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user