diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-06-11 21:41:11 +0200 |
|---|---|---|
| committer | Carbenium <carbenium@outlook.com> | 2020-07-16 22:00:29 +0200 |
| commit | bd96262248fa4d9c8e867b4056e52c44852364c3 (patch) | |
| tree | bfcf447563b8edc99de222eb21bf69a999483cd3 /src/server/game | |
| parent | 68131dbd92f2a9c7b932a7f23719f57adf66d90e (diff) | |
Core/OutdoorPvP: refactor using Position and Quat to pack parameters
- Moved statics to cpp
- Save scriptids into an array
(cherry picked from commit 3e7b64b2f765bebc722c1194b7fc2f749fae77f7)
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 29 | ||||
| -rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 4 | ||||
| -rw-r--r-- | src/server/game/OutdoorPvP/OutdoorPvP.cpp | 12 | ||||
| -rw-r--r-- | src/server/game/OutdoorPvP/OutdoorPvP.h | 41 | ||||
| -rw-r--r-- | src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp | 19 | ||||
| -rw-r--r-- | src/server/game/OutdoorPvP/OutdoorPvPMgr.h | 13 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.cpp | 6 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.h | 3 |
8 files changed, 47 insertions, 80 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index f0fc3f5e297..73a0b0c0c6d 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2187,7 +2187,7 @@ void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData co } } -ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3) +ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, Position const& pos, QuaternionData const& rot, uint32 spawntimedelay /*= 0*/) { GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry); if (!goinfo) @@ -2201,14 +2201,10 @@ ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, fl GameObjectData& data = NewGOData(guid); data.id = entry; data.mapid = mapId; - data.posX = x; - data.posY = y; - data.posZ = z; - data.orientation = o; - data.rotation.x = rotation0; - data.rotation.y = rotation1; - data.rotation.z = rotation2; - data.rotation.w = rotation3; + + pos.GetPosition(data.posX, data.posY, data.posZ, data.orientation); + + data.rotation = rot; data.spawntimesecs = spawntimedelay; data.animprogress = 100; data.spawnDifficulties.push_back(DIFFICULTY_NONE); @@ -2220,7 +2216,7 @@ ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, fl // Spawn if necessary (loaded grids only) // We use spawn coords to spawn - if (!map->Instanceable() && map->IsGridLoaded(x, y)) + if (!map->Instanceable() && map->IsGridLoaded(data.posX, data.posY)) { GameObject* go = GameObject::CreateGameObjectFromDB(guid, map); if (!go) @@ -2230,12 +2226,12 @@ ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, fl } } - TC_LOG_DEBUG("maps", "AddGOData: dbguid " UI64FMTD " entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, x, y, z, o); + TC_LOG_DEBUG("maps", "AddGOData: dbguid " UI64FMTD " entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, data.posX, data.posY, data.posZ, data.orientation); return guid; } -ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay /*= 0*/) +ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, Position const& pos, uint32 spawntimedelay /*= 0*/) { CreatureTemplate const* cInfo = GetCreatureTemplate(entry); if (!cInfo) @@ -2256,10 +2252,9 @@ ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float data.mapid = mapId; data.displayid = 0; data.equipmentId = 0; - data.posX = x; - data.posY = y; - data.posZ = z; - data.orientation = o; + + pos.GetPosition(data.posX, data.posY, data.posZ, data.orientation); + data.spawntimesecs = spawntimedelay; data.spawndist = 0; data.currentwaypoint = 0; @@ -2275,7 +2270,7 @@ ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float AddCreatureToGrid(guid, &data); // We use spawn coords to spawn - if (!map->Instanceable() && !map->IsRemovalGrid(x, y)) + if (!map->Instanceable() && !map->IsRemovalGrid(data.posX, data.posY)) { Creature* creature = Creature::CreateCreatureFromDB(guid, map); if (!creature) diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 1bcf58a452d..85974e3b9da 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -1492,8 +1492,8 @@ class TC_GAME_API ObjectMgr void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data); void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data); void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data); - ObjectGuid::LowType AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); - ObjectGuid::LowType AddCreatureData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0); + ObjectGuid::LowType AddGOData(uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot, uint32 spawntimedelay = 0); + ObjectGuid::LowType AddCreatureData(uint32 entry, uint32 map, Position const& pos, uint32 spawntimedelay = 0); // reserved names void LoadReservedPlayersNames(); diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index a0d56420d83..c1abd7625e9 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -109,9 +109,9 @@ void OPvPCapturePoint::AddCre(uint32 type, ObjectGuid::LowType guid) m_CreatureTypes[m_Creatures[type]] = type; } -bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3) +bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot) { - if (ObjectGuid::LowType guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3)) + if (ObjectGuid::LowType guid = sObjectMgr->AddGOData(entry, map, pos, rot, 0)) { AddGO(type, guid); return true; @@ -120,9 +120,9 @@ bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, return false; } -bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, TeamId /*teamId = TEAM_NEUTRAL*/, uint32 spawntimedelay /*= 0*/) +bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, Position const& pos, TeamId /*teamId = TEAM_NEUTRAL*/, uint32 spawntimedelay /*= 0*/) { - if (ObjectGuid::LowType guid = sObjectMgr->AddCreatureData(entry, map, x, y, z, o, spawntimedelay)) + if (ObjectGuid::LowType guid = sObjectMgr->AddCreatureData(entry, map, pos, spawntimedelay)) { AddCre(type, guid); return true; @@ -131,7 +131,7 @@ bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, float return false; } -bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3) +bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot) { TC_LOG_DEBUG("outdoorpvp", "Creating capture point %u", entry); @@ -143,7 +143,7 @@ bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, float x, fl return false; } - m_capturePointSpawnId = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3); + m_capturePointSpawnId = sObjectMgr->AddGOData(entry, map, pos, rot, 0); if (!m_capturePointSpawnId) return false; diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index b063352c07b..e5a01706cbf 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -18,22 +18,22 @@ #ifndef OUTDOOR_PVP_H_ #define OUTDOOR_PVP_H_ +#include "Position.h" +#include "QuaternionData.h" #include "SharedDefines.h" #include "ZoneScript.h" #include <map> -class GameObject; - enum OutdoorPvPTypes { OUTDOOR_PVP_HP = 1, - OUTDOOR_PVP_NA = 2, - OUTDOOR_PVP_TF = 3, - OUTDOOR_PVP_ZM = 4, - OUTDOOR_PVP_SI = 5 -}; + OUTDOOR_PVP_NA, + OUTDOOR_PVP_TF, + OUTDOOR_PVP_ZM, + OUTDOOR_PVP_SI, -#define MAX_OUTDOORPVP_TYPES 6 + MAX_OUTDOORPVP_TYPES +}; enum ObjectiveStates { @@ -53,14 +53,8 @@ struct go_type { uint32 entry; uint32 map; - float x; - float y; - float z; - float o; - float rot0; - float rot1; - float rot2; - float rot3; + Position pos; + QuaternionData rot; }; // struct for creature spawning @@ -68,10 +62,7 @@ struct creature_type { uint32 entry; uint32 map; - float x; - float y; - float z; - float o; + Position pos; }; class Creature; @@ -142,17 +133,15 @@ class TC_GAME_API OPvPCapturePoint void AddGO(uint32 type, ObjectGuid::LowType guid); void AddCre(uint32 type, ObjectGuid::LowType guid); - bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0, - float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); + bool SetCapturePointData(uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot); protected: - bool AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, - float rotation0, float rotation1, float rotation2, float rotation3); - virtual bool AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, TeamId teamId = TEAM_NEUTRAL, uint32 spawntimedelay = 0); + bool AddObject(uint32 type, uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot); + bool AddCreature(uint32 type, uint32 entry, uint32 map, Position const& pos, TeamId teamId = TEAM_NEUTRAL, uint32 spawntimedelay = 0); - bool DelCreature(uint32 type); bool DelObject(uint32 type); + bool DelCreature(uint32 type); bool DelCapturePoint(); diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp index d9a5dd0cd92..d9a80286db1 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp @@ -27,21 +27,17 @@ OutdoorPvPMgr::OutdoorPvPMgr() { m_UpdateTimer = 0; - //TC_LOG_DEBUG("outdoorpvp", "Instantiating OutdoorPvPMgr"); } void OutdoorPvPMgr::Die() { - //TC_LOG_DEBUG("outdoorpvp", "Deleting OutdoorPvPMgr"); for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr) delete *itr; m_OutdoorPvPSet.clear(); - for (OutdoorPvPDataMap::iterator itr = m_OutdoorPvPDatas.begin(); itr != m_OutdoorPvPDatas.end(); ++itr) - delete itr->second; - - m_OutdoorPvPDatas.clear(); + for (uint32 i = 0; i < MAX_OUTDOORPVP_TYPES; ++i) + m_OutdoorPvPDatas[i] = 0; m_OutdoorPvPMap.clear(); } @@ -58,7 +54,6 @@ void OutdoorPvPMgr::InitOutdoorPvP() // 0 1 QueryResult result = WorldDatabase.Query("SELECT TypeId, ScriptName FROM outdoorpvp_template"); - if (!result) { TC_LOG_ERROR("server.loading", ">> Loaded 0 outdoor PvP definitions. DB table `outdoorpvp_template` is empty."); @@ -83,11 +78,8 @@ void OutdoorPvPMgr::InitOutdoorPvP() continue; } - OutdoorPvPData* data = new OutdoorPvPData(); OutdoorPvPTypes realTypeId = OutdoorPvPTypes(typeId); - data->TypeId = realTypeId; - data->ScriptId = sObjectMgr->GetScriptId(fields[1].GetString()); - m_OutdoorPvPDatas[realTypeId] = data; + m_OutdoorPvPDatas[realTypeId] = sObjectMgr->GetScriptId(fields[1].GetString()); ++count; } @@ -96,14 +88,13 @@ void OutdoorPvPMgr::InitOutdoorPvP() OutdoorPvP* pvp; for (uint8 i = 1; i < MAX_OUTDOORPVP_TYPES; ++i) { - OutdoorPvPDataMap::iterator iter = m_OutdoorPvPDatas.find(OutdoorPvPTypes(i)); - if (iter == m_OutdoorPvPDatas.end()) + if (!m_OutdoorPvPDatas[i]) { TC_LOG_ERROR("sql.sql", "Could not initialize OutdoorPvP object for type ID %u; no entry in database.", uint32(i)); continue; } - pvp = sScriptMgr->CreateOutdoorPvP(iter->second); + pvp = sScriptMgr->CreateOutdoorPvP(m_OutdoorPvPDatas[i]); if (!pvp) { TC_LOG_ERROR("outdoorpvp", "Could not initialize OutdoorPvP object for type ID %u; got NULL pointer from script.", uint32(i)); diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h index c964cf8f82c..1a73a46da70 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h @@ -21,6 +21,7 @@ #define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000 #include "OutdoorPvP.h" +#include <unordered_map> class Player; class GameObject; @@ -29,12 +30,6 @@ class ZoneScript; struct GossipMenuItems; enum LocaleConstant : uint8; -struct OutdoorPvPData -{ - OutdoorPvPTypes TypeId; - uint32 ScriptId; -}; - // class to handle player enter / leave / areatrigger / GO use events class TC_GAME_API OutdoorPvPMgr { @@ -85,8 +80,8 @@ class TC_GAME_API OutdoorPvPMgr private: typedef std::vector<OutdoorPvP*> OutdoorPvPSet; - typedef std::map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap; - typedef std::map<OutdoorPvPTypes, OutdoorPvPData*> OutdoorPvPDataMap; + typedef std::unordered_map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap; + typedef std::array<uint32, MAX_OUTDOORPVP_TYPES> OutdoorPvPScriptIds; // contains all initiated outdoor pvp events // used when initing / cleaning up @@ -97,7 +92,7 @@ class TC_GAME_API OutdoorPvPMgr OutdoorPvPMap m_OutdoorPvPMap; // Holds the outdoor PvP templates - OutdoorPvPDataMap m_OutdoorPvPDatas; + OutdoorPvPScriptIds m_OutdoorPvPDatas; // update interval uint32 m_UpdateTimer; diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 668f4bba387..09528245993 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1654,11 +1654,9 @@ Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/) return NULL; } -OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data) +OutdoorPvP* ScriptMgr::CreateOutdoorPvP(uint32 scriptId) { - ASSERT(data); - - GET_SCRIPT_RET(OutdoorPvPScript, data->ScriptId, tmpscript, NULL); + GET_SCRIPT_RET(OutdoorPvPScript, scriptId, tmpscript, NULL); return tmpscript->GetOutdoorPvP(); } diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 60cd06d5007..c5e5d1456c5 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -71,7 +71,6 @@ struct CreatureTemplate; struct CreatureData; struct ItemTemplate; struct MapEntry; -struct OutdoorPvPData; struct QuestObjective; struct SceneTemplate; @@ -991,7 +990,7 @@ class TC_GAME_API ScriptMgr public: /* OutdoorPvPScript */ - OutdoorPvP* CreateOutdoorPvP(OutdoorPvPData const* data); + OutdoorPvP* CreateOutdoorPvP(uint32 scriptId); public: /* CommandScript */ |
