From 6e07b058bc5b903ebb5a6c559086dbf4a643d2cd Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 9 Jan 2022 14:19:07 -0500 Subject: [PATCH] Core/ObjectMgr: Replace manually constructed uint32 map key with pair Port From (https://github.com/TrinityCore/TrinityCore/commit/b2b83d49ad379547da874afef04317a0fef4de0d) --- Source/Game/Globals/ObjectManager.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 9f5880a65..414964030 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -10212,29 +10212,29 @@ namespace Game } CellObjectGuids CreateCellObjectGuids(uint mapid, Difficulty difficulty, uint cellid) { - uint newid = MathFunctions.MakePair32(mapid, (uint)difficulty); + var key = (mapid, difficulty); - if (!mapObjectGuidsStore.ContainsKey(newid)) - mapObjectGuidsStore.Add(newid, new Dictionary()); + if (!mapObjectGuidsStore.ContainsKey(key)) + mapObjectGuidsStore.Add(key, new Dictionary()); - if (!mapObjectGuidsStore[newid].ContainsKey(cellid)) - mapObjectGuidsStore[newid].Add(cellid, new CellObjectGuids()); + if (!mapObjectGuidsStore[key].ContainsKey(cellid)) + mapObjectGuidsStore[key].Add(cellid, new CellObjectGuids()); - return mapObjectGuidsStore[newid][cellid]; + return mapObjectGuidsStore[key][cellid]; } public CellObjectGuids GetCellObjectGuids(uint mapid, Difficulty difficulty, uint cellid) { - uint newid = MathFunctions.MakePair32(mapid, (uint)difficulty); + var key = (mapid, difficulty); - if (mapObjectGuidsStore.ContainsKey(newid) && mapObjectGuidsStore[newid].ContainsKey(cellid)) - return mapObjectGuidsStore[newid][cellid]; + if (mapObjectGuidsStore.ContainsKey(key) && mapObjectGuidsStore[key].ContainsKey(cellid)) + return mapObjectGuidsStore[key][cellid]; return null; } - public Dictionary GetMapObjectGuids(uint mapid, byte spawnMode) + public Dictionary GetMapObjectGuids(uint mapid, Difficulty difficulty) { - var pair = MathFunctions.MakePair32(mapid, spawnMode); - return mapObjectGuidsStore.LookupByKey(pair); + var key = (mapid, difficulty); + return mapObjectGuidsStore.LookupByKey(key); } public PageText GetPageText(uint pageEntry) { @@ -10665,7 +10665,7 @@ namespace Game //Maps public Dictionary gameTeleStorage = new(); - Dictionary> mapObjectGuidsStore = new(); + Dictionary<(uint mapId, Difficulty difficulty), Dictionary> mapObjectGuidsStore = new(); Dictionary instanceTemplateStorage = new(); public MultiMap GraveYardStorage = new(); List _transportMaps = new();