From b2b83d49ad379547da874afef04317a0fef4de0d Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 27 Dec 2021 16:16:58 +0100 Subject: Core/ObjectMgr: Replace manually constructed uint32 map key with pair --- src/server/game/Globals/ObjectMgr.cpp | 8 ++++---- src/server/game/Globals/ObjectMgr.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/server') diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 9273c826ec0..ec2bf4b499b 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2312,7 +2312,7 @@ void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* for (Difficulty difficulty : data->spawnDifficulties) { CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY()); - CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()]; + CellObjectGuids& cell_guids = _mapObjectGuidsStore[{ data->mapId, difficulty }][cellCoord.GetId()]; cell_guids.creatures.insert(guid); } } @@ -2322,7 +2322,7 @@ void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData co for (Difficulty difficulty : data->spawnDifficulties) { CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY()); - CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()]; + CellObjectGuids& cell_guids = _mapObjectGuidsStore[{ data->mapId, difficulty }][cellCoord.GetId()]; cell_guids.creatures.erase(guid); } } @@ -2890,7 +2890,7 @@ void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData con for (Difficulty difficulty : data->spawnDifficulties) { CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY()); - CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()]; + CellObjectGuids& cell_guids = _mapObjectGuidsStore[{ data->mapId, difficulty }][cellCoord.GetId()]; cell_guids.gameobjects.insert(guid); } } @@ -2900,7 +2900,7 @@ void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectDat for (Difficulty difficulty : data->spawnDifficulties) { CellCoord cellCoord = Trinity::ComputeCellCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY()); - CellObjectGuids& cell_guids = _mapObjectGuidsStore[MAKE_PAIR32(data->mapId, difficulty)][cellCoord.GetId()]; + CellObjectGuids& cell_guids = _mapObjectGuidsStore[{ data->mapId, difficulty }][cellCoord.GetId()]; cell_guids.gameobjects.erase(guid); } } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index ff914354413..52eefdec97c 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -486,7 +486,7 @@ struct CellObjectGuids CellGuidSet gameobjects; }; typedef std::unordered_map CellObjectGuidsMap; -typedef std::unordered_map MapObjectGuids; +typedef std::unordered_map, CellObjectGuidsMap> MapObjectGuids; struct TrinityString { @@ -1454,14 +1454,14 @@ class TC_GAME_API ObjectMgr return nullptr; } - CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id) + CellObjectGuids const& GetCellObjectGuids(uint16 mapid, Difficulty spawnMode, uint32 cell_id) { - return _mapObjectGuidsStore[MAKE_PAIR32(mapid, spawnMode)][cell_id]; + return _mapObjectGuidsStore[{ mapid, spawnMode }][cell_id]; } - CellObjectGuidsMap const& GetMapObjectGuids(uint16 mapid, uint8 spawnMode) + CellObjectGuidsMap const& GetMapObjectGuids(uint16 mapid, Difficulty spawnMode) { - return _mapObjectGuidsStore[MAKE_PAIR32(mapid, spawnMode)]; + return _mapObjectGuidsStore[{ mapid, spawnMode }]; } /** -- cgit v1.2.3