aboutsummaryrefslogtreecommitdiff
path: root/src/game/MiscHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/MiscHandler.cpp')
-rw-r--r--src/game/MiscHandler.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 46c822fcbf0..5cc3d6f3e35 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -48,6 +48,8 @@
#include "CreatureAI.h"
#include "DBCEnums.h"
#include "ScriptMgr.h"
+#include "MapManager.h"
+#include "InstanceData.h"
void WorldSession::HandleRepopRequestOpcode(WorldPacket & recv_data)
{
@@ -915,6 +917,25 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
if (!GetPlayer()->Satisfy(objmgr.GetAccessRequirement(at->access_id), at->target_mapId, true))
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);
+ 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);
}