From 84de4826e4ff5731f3649b1c41bdd198104a9b26 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 11 Mar 2022 18:01:21 -0500 Subject: [PATCH] Scripts/InstanceScript: Fix an issue where LoadAllGrids would load creatures before TeamInInstance was properly set Port From (https://github.com/TrinityCore/TrinityCore/commit/5a20f14a9920a16545d913fc8e444c161c2a92bb) --- Source/Game/Maps/Instances/MapInstance.cs | 2 +- Source/Game/Maps/Map.cs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Source/Game/Maps/Instances/MapInstance.cs b/Source/Game/Maps/Instances/MapInstance.cs index 598ff1443..e3719e8a6 100644 --- a/Source/Game/Maps/Instances/MapInstance.cs +++ b/Source/Game/Maps/Instances/MapInstance.cs @@ -196,7 +196,7 @@ namespace Game.Maps Log.outDebug(LogFilter.Maps, "MapInstanced.CreateInstance: {0} map instance {1} for {2} created with difficulty {3}", save != null ? "" : "new ", InstanceId, GetId(), difficulty); - InstanceMap map = new(GetId(), GetGridExpiry(), InstanceId, difficulty, this); + InstanceMap map = new(GetId(), GetGridExpiry(), InstanceId, difficulty, this, teamId); Cypher.Assert(map.IsDungeon()); map.LoadRespawnTimes(); diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index a136bf381..621aaee0f 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -5147,9 +5147,11 @@ namespace Game.Maps public class InstanceMap : Map { - public InstanceMap(uint id, long expiry, uint InstanceId, Difficulty spawnMode, Map _parent) - : base(id, expiry, InstanceId, spawnMode, _parent) + public InstanceMap(uint id, long expiry, uint InstanceId, Difficulty spawnMode, Map parent, int instanceTeam) + : base(id, expiry, InstanceId, spawnMode, parent) { + scriptTeam = instanceTeam; + //lets initialize visibility distance for dungeons InitVisibilityDistance(); @@ -5542,7 +5544,7 @@ namespace Game.Maps player.SendInstanceResetWarning(GetId(), player.GetDifficultyID(GetEntry()), timeLeft, true); } - void SetResetSchedule(bool on) + public void SetResetSchedule(bool on) { // only for normal instances // the reset time is only scheduled when there are no payers inside @@ -5576,12 +5578,16 @@ namespace Game.Maps return GetEntry().MaxPlayers; } - private uint GetMaxResetDelay() + public uint GetMaxResetDelay() { MapDifficultyRecord mapDiff = GetMapDifficulty(); return mapDiff != null ? mapDiff.GetRaidDuration() : 0; } + public int GetTeamIdInInstance() { return scriptTeam; } + + public Team GetTeamInInstance() { return scriptTeam == TeamId.Alliance ? Team.Alliance : Team.Horde; } + public uint GetScriptId() { return i_script_id; @@ -5602,6 +5608,7 @@ namespace Game.Maps InstanceScript i_data; uint i_script_id; + int scriptTeam; InstanceScenario i_scenario; bool m_resetAfterUnload; bool m_unloadWhenEmpty;