From e5d325bf8253a8113eb17b6e338156e2e14c2b54 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 27 Jun 2022 15:54:38 -0400 Subject: [PATCH] Core/WorldStates: Migrate conditions and criteria to new worldstate api Port From (https://github.com/TrinityCore/TrinityCore/commit/7029b78cab620b861818fab4f94c7810caf109de) --- Source/Game/Achievements/CriteriaHandler.cs | 2 +- Source/Game/Conditions/Condition.cs | 2 +- Source/Game/Conditions/ConditionManager.cs | 4 ++-- Source/Game/Entities/Player/Player.Map.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Game/Achievements/CriteriaHandler.cs b/Source/Game/Achievements/CriteriaHandler.cs index bf0d62f91..63bea31ef 100644 --- a/Source/Game/Achievements/CriteriaHandler.cs +++ b/Source/Game/Achievements/CriteriaHandler.cs @@ -1812,7 +1812,7 @@ namespace Game.Achievements return false; break; case ModifierTreeType.PlayersRealmWorldState: // 108 - if (Global.WorldMgr.GetWorldState(reqValue) != secondaryAsset) + if (Global.WorldStateMgr.GetValue((int)reqValue, referencePlayer.GetMap()) != secondaryAsset) return false; break; case ModifierTreeType.TimeBetween: // 109 diff --git a/Source/Game/Conditions/Condition.cs b/Source/Game/Conditions/Condition.cs index 2a66a4e32..a46f6bb10 100644 --- a/Source/Game/Conditions/Condition.cs +++ b/Source/Game/Conditions/Condition.cs @@ -83,7 +83,7 @@ namespace Game.Conditions break; case ConditionTypes.WorldState: { - condMeets = ConditionValue2 == Global.WorldMgr.GetWorldState(ConditionValue1); + condMeets = Global.WorldStateMgr.GetValue((int)ConditionValue1, map) == ConditionValue2; break; } case ConditionTypes.RealmAchievement: diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index 523d4cad2..bc08c4176 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -1668,7 +1668,7 @@ namespace Game } case ConditionTypes.WorldState: { - if (Global.WorldMgr.GetWorldState((WorldStates)cond.ConditionValue1) == 0) + if (Global.WorldStateMgr.GetWorldStateTemplate((int)cond.ConditionValue1) == null) { Log.outError(LogFilter.Sql, "{0} has non existing world state in value1 ({1}), skipped.", cond.ToString(true), cond.ConditionValue1); return false; @@ -2772,7 +2772,7 @@ namespace Game case WorldStateExpressionValueType.WorldState: { uint worldStateId = buffer.ReadUInt32(); - value = (int)Global.WorldMgr.GetWorldState(worldStateId); + value = Global.WorldStateMgr.GetValue((int)worldStateId, player.GetMap()); break; } case WorldStateExpressionValueType.Function: diff --git a/Source/Game/Entities/Player/Player.Map.cs b/Source/Game/Entities/Player/Player.Map.cs index 11b11983b..7acd59c40 100644 --- a/Source/Game/Entities/Player/Player.Map.cs +++ b/Source/Game/Entities/Player/Player.Map.cs @@ -247,7 +247,7 @@ namespace Game.Entities { if (area != null) { - if (InBattleground() || area.HasFlag(AreaFlags.Combat) || (area.PvpCombatWorldStateID != -1 && Global.WorldMgr.GetWorldState((WorldStates)area.PvpCombatWorldStateID) != 0)) + if (InBattleground() || area.HasFlag(AreaFlags.Combat) || (area.PvpCombatWorldStateID != -1 && Global.WorldStateMgr.GetValue(area.PvpCombatWorldStateID, GetMap()) != 0)) pvpInfo.IsInHostileArea = true; else if (IsWarModeLocalActive() || area.HasFlag(AreaFlags.Unk3)) {