aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/MiscHandler.cpp
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2015-12-27 18:03:03 +0100
committertreeston <treeston.mmoc@gmail.com>2015-12-31 01:02:07 +0100
commit43fa7d48a5650c71f74098f3398cf5aca89c3837 (patch)
treea6d808e4b447f9df2b1f1cfe0a19483d64fe87d5 /src/server/game/Handlers/MiscHandler.cpp
parent812809a977e2ba2a53e55c3dfc74bbed9dd59b7a (diff)
Game/Maps: Clean up instance handling.
- Rename Map::CanEnter to Map::CannotEnter. Return value changed from boolean (true means player can enter) to enum Map::EnterState (CAN_ENTER=0 means player can enter, any other value is a reason for deny). - Move hack-y player error messages from within Map::CanEnter to the function calling CanEnter as appropriate (primarily WorldSession::HandleAreaTriggerOpcode). - Modify WorldSession::HandleAreaTriggerOpcode to properly revive the player upon touching the portal leading to the instance they died in even if they are currently unable to zone in. Fixes and closes #15758. - Modify Player::LoadFromDB to properly spawn players in the instance they logged off in if possible. Fixes and closes #15561. - Modify permanent save behavior to be blizzlike: Players can always enter an instance they are saved to (assuming there are no map constraints against it), but get a homebind timer if the instance is already in use.
Diffstat (limited to 'src/server/game/Handlers/MiscHandler.cpp')
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 6dcd3242a6c..345202dc329 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -866,8 +866,77 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
bool teleported = false;
if (player->GetMapId() != at->target_mapId)
{
- if (!sMapMgr->CanPlayerEnter(at->target_mapId, player, false))
+ if (Map::EnterState denyReason = sMapMgr->PlayerCannotEnter(at->target_mapId, player, false))
+ {
+ bool reviveAtTrigger = false; // should we revive the player if he is trying to enter the correct instance?
+ switch (denyReason)
+ {
+ case Map::CANNOT_ENTER_NO_ENTRY:
+ TC_LOG_DEBUG("maps", "MAP: Player '%s' attempted to enter map with id %d which has no entry", player->GetName().c_str(), at->target_mapId);
+ break;
+ case Map::CANNOT_ENTER_UNINSTANCED_DUNGEON:
+ TC_LOG_DEBUG("maps", "MAP: Player '%s' attempted to enter dungeon map %d but no instance template was found", player->GetName().c_str(), at->target_mapId);
+ break;
+ case Map::CANNOT_ENTER_DIFFICULTY_UNAVAILABLE:
+ TC_LOG_DEBUG("maps", "MAP: Player '%s' attempted to enter instance map %d but the requested difficulty was not found", player->GetName().c_str(), at->target_mapId);
+ if (MapEntry const* entry = sMapStore.LookupEntry(at->target_mapId))
+ player->SendTransferAborted(entry->MapID, TRANSFER_ABORT_DIFFICULTY, player->GetDifficulty(entry->IsRaid()));
+ break;
+ case Map::CANNOT_ENTER_NOT_IN_RAID:
+ if (MapEntry const* entry = sMapStore.LookupEntry(at->target_mapId))
+ {
+ char const* mapName = entry->name[player->GetSession()->GetSessionDbcLocale()];
+ TC_LOG_DEBUG("maps", "MAP: Player '%s' must be in a raid group to enter instance '%s'", player->GetName().c_str(), mapName);
+ // probably there must be special opcode, because client has this string constant in GlobalStrings.lua
+ player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetTrinityString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName);
+ }
+ reviveAtTrigger = true;
+ break;
+ case Map::CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE:
+ {
+ WorldPacket data(SMSG_CORPSE_NOT_IN_INSTANCE);
+ player->GetSession()->SendPacket(&data);
+ TC_LOG_DEBUG("maps", "MAP: Player '%s' does not have a corpse in instance map %d and cannot enter", player->GetName().c_str(), at->target_mapId);
+ break;
+ }
+ case Map::CANNOT_ENTER_INSTANCE_BIND_MISMATCH:
+ if (MapEntry const* entry = sMapStore.LookupEntry(at->target_mapId))
+ {
+ char const* mapName = entry->name[player->GetSession()->GetSessionDbcLocale()];
+ TC_LOG_DEBUG("maps", "MAP: Player '%s' cannot enter instance map '%s' because their permanent bind is incompatible with their group's", player->GetName().c_str(), mapName);
+ // is there a special opcode for this?
+ // @todo figure out how to get player localized difficulty string (e.g. "10 player", "Heroic" etc)
+ ChatHandler(player->GetSession()).PSendSysMessage(player->GetSession()->GetTrinityString(LANG_INSTANCE_BIND_MISMATCH), mapName);
+ }
+ reviveAtTrigger = true;
+ break;
+ case Map::CANNOT_ENTER_TOO_MANY_INSTANCES:
+ player->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_TOO_MANY_INSTANCES);
+ TC_LOG_DEBUG("maps", "MAP: Player '%s' cannot enter instance map %d because he has exceeded the maximum number of instances per hour.", player->GetName().c_str(), at->target_mapId);
+ reviveAtTrigger = true;
+ break;
+ case Map::CANNOT_ENTER_MAX_PLAYERS:
+ player->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_MAX_PLAYERS);
+ reviveAtTrigger = true;
+ break;
+ case Map::CANNOT_ENTER_ZONE_IN_COMBAT:
+ player->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_ZONE_IN_COMBAT);
+ reviveAtTrigger = true;
+ break;
+ default:
+ break;
+ }
+
+ if (reviveAtTrigger) // check if the player is touching the areatrigger leading to the map his corpse is on
+ if (!player->IsAlive() && player->HasCorpse())
+ if (player->GetCorpseLocation().GetMapId() == at->target_mapId)
+ {
+ player->ResurrectPlayer(0.5f);
+ player->SpawnCorpseBones();
+ }
+
return;
+ }
if (Group* group = player->GetGroup())
if (group->isLFGGroup() && player->GetMap()->IsDungeon())