Core/Maps: Changed functions checking if map can be entered to use TransferAbortReason directly instead of intermediate Map::EnterState enum

Port From (https://github.com/TrinityCore/TrinityCore/commit/c3e1ff90a5a217691990ea4662bcaa2405b57fde)
This commit is contained in:
hondacrx
2022-10-11 17:54:34 -04:00
parent d16f8c94c2
commit e5c7244893
8 changed files with 122 additions and 162 deletions
+3 -25
View File
@@ -2925,32 +2925,10 @@ namespace Game.Entities
}
else if (map.IsDungeon()) // if map is dungeon...
{
EnterState denyReason = ((InstanceMap)map).CannotEnter(this);
if (denyReason != 0) // ... and can't enter map, then look for entry point.
TransferAbortParams denyReason = map.CannotEnter(this); // ... and can't enter map, then look for entry point.
if (denyReason != null)
{
switch (denyReason)
{
case EnterState.CannotEnterDifficultyUnavailable:
SendTransferAborted(map.GetId(), TransferAbortReason.Difficulty, (byte)map.GetDifficultyID());
break;
case EnterState.CannotEnterInstanceBindMismatch:
SendSysMessage(CypherStrings.InstanceBindMismatch, map.GetMapName());
break;
case EnterState.CannotEnterTooManyInstances:
SendTransferAborted(map.GetId(), TransferAbortReason.TooManyInstances);
break;
case EnterState.CannotEnterMaxPlayers:
SendTransferAborted(map.GetId(), TransferAbortReason.MaxPlayers);
break;
case EnterState.CannotEnterZoneInCombat:
SendTransferAborted(map.GetId(), TransferAbortReason.ZoneInCombat);
break;
case EnterState.CannotEnterInstanceShuttingDown:
SendTransferAborted(map.GetId(), TransferAbortReason.NotFound);
break;
default:
break;
}
SendTransferAborted(map.GetId(), denyReason.Reason, denyReason.Arg, denyReason.MapDifficultyXConditionId);
areaTrigger = Global.ObjectMgr.GetGoBackTrigger(mapId);
check = true;
}
+12 -8
View File
@@ -331,7 +331,7 @@ namespace Game.Entities
SendPacket(instanceInfo);
}
public bool Satisfy(AccessRequirement ar, uint target_map, bool report = false)
public bool Satisfy(AccessRequirement ar, uint target_map, TransferAbortParams abortParams = null, bool report = false)
{
if (!IsGameMaster())
{
@@ -380,12 +380,6 @@ namespace Game.Entities
else if (ar.item2 != 0 && !HasItemCount(ar.item2))
missingItem = ar.item2;
if (Global.DisableMgr.IsDisabledFor(DisableType.Map, target_map, this))
{
GetSession().SendNotification("{0}", Global.ObjectMgr.GetCypherString(CypherStrings.InstanceClosed));
return false;
}
if (GetTeam() == Team.Alliance && ar.quest_A != 0 && !GetQuestRewardStatus(ar.quest_A))
missingQuest = ar.quest_A;
else if (GetTeam() == Team.Horde && ar.quest_H != 0 && !GetQuestRewardStatus(ar.quest_H))
@@ -403,12 +397,22 @@ namespace Game.Entities
if (LevelMin != 0 || LevelMax != 0 || failedMapDifficultyXCondition != 0 || missingItem != 0 || missingQuest != 0 || missingAchievement != 0)
{
if (abortParams != null)
abortParams.Reason = TransferAbortReason.Error;
if (report)
{
if (missingQuest != 0 && !string.IsNullOrEmpty(ar.questFailedText))
SendSysMessage("{0}", ar.questFailedText);
else if (mapDiff.Message[Global.WorldMgr.GetDefaultDbcLocale()][0] != '\0' || failedMapDifficultyXCondition != 0) // if (missingAchievement) covered by this case
SendTransferAborted(target_map, TransferAbortReason.Difficulty, (byte)target_difficulty, failedMapDifficultyXCondition);
{
if (abortParams != null)
{
abortParams.Reason = TransferAbortReason.Difficulty;
abortParams.Arg = (byte)target_difficulty;
abortParams.MapDifficultyXConditionId = failedMapDifficultyXCondition;
}
}
else if (missingItem != 0)
GetSession().SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.LevelMinrequiredAndItem), LevelMin, Global.ObjectMgr.GetItemTemplate(missingItem).GetName());
else if (LevelMin != 0)
+10 -6
View File
@@ -1783,8 +1783,12 @@ namespace Game.Entities
// Check enter rights before map getting to avoid creating instance copy for player
// this check not dependent from map instance copy and same for all instance copies of selected map
if (Map.PlayerCannotEnter(mapid, this, false) != 0)
TransferAbortParams abortParams = Map.PlayerCannotEnter(mapid, this);
if (abortParams != null)
{
SendTransferAborted(mapid, abortParams.Reason, abortParams.Arg, abortParams.MapDifficultyXConditionId);
return false;
}
// Seamless teleport can happen only if cosmetic maps match
if (!oldmap || (oldmap.GetEntry().CosmeticParentMapID != mapid && GetMapId() != mEntry.CosmeticParentMapID &&
@@ -1795,13 +1799,13 @@ namespace Game.Entities
SetSemaphoreTeleportNear(false);
//setup delayed teleport flag
SetDelayedTeleportFlag(IsCanDelayTeleport());
//if teleport spell is casted in Unit.Update() func
//if teleport spell is cast in Unit::Update() func
//then we need to delay it until update process will be finished
if (IsHasDelayedTeleport())
{
SetSemaphoreTeleportFar(true);
//lets save teleport destination for player
teleportDest = new WorldLocation(mapid, x, y, z, orientation);
teleportDest = new(mapid, x, y, z, orientation);
m_teleport_instanceId = instanceId;
m_teleport_options = options;
return true;
@@ -1837,11 +1841,11 @@ namespace Game.Entities
if (pet)
UnsummonPetTemporaryIfAny();
// remove all areatriggers entities
RemoveAllAreaTriggers();
// remove all dyn objects
RemoveAllDynObjects();
// remove all areatriggers entities
RemoveAllAreaTriggers();
// stop spellcasting
// not attempt interrupt teleportation spell at caster teleport