diff options
| author | Shauren <shauren.trinity@gmail.com> | 2017-06-04 01:00:45 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-06-04 01:00:45 +0200 |
| commit | b453e124231a90321fe79fbf3a62acdcfa54a691 (patch) | |
| tree | ca2a815b923080385ed9a3a69aefe20ee54a7969 /src/server/game/Scripting | |
| parent | ec72a59b08e71ebc7ba00b32592ec903a7995a84 (diff) | |
Core/Game: Include cleanup part 5
* ObjectMgr.h
* Player.h
* Unit.h
* G3D should no longer propagate everywhere from Spline/MotionMaster
Diffstat (limited to 'src/server/game/Scripting')
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.cpp | 1 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptSystem.cpp | 23 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptSystem.h | 21 |
3 files changed, 27 insertions, 18 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index cf9cb50b3be..3eed0132d3c 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -26,6 +26,7 @@ #include "Errors.h" #include "GameObject.h" #include "GossipDef.h" +#include "Item.h" #include "LFGScripts.h" #include "Log.h" #include "Map.h" diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index f205fa138af..3a86e761aca 100644 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -22,6 +22,10 @@ #include "Log.h" #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "SplineChain.h" + +SystemMgr::SystemMgr() = default; +SystemMgr::~SystemMgr() = default; SystemMgr* SystemMgr::instance() { @@ -109,7 +113,7 @@ void SystemMgr::LoadScriptSplineChains() uint32 entry = fieldsMeta[0].GetUInt32(); uint16 chainId = fieldsMeta[1].GetUInt16(); uint8 splineId = fieldsMeta[2].GetUInt8(); - SplineChain& chain = m_mSplineChainsMap[{entry,chainId}]; + std::vector<SplineChainLink>& chain = m_mSplineChainsMap[{entry,chainId}]; if (splineId != chain.size()) { @@ -117,8 +121,9 @@ void SystemMgr::LoadScriptSplineChains() continue; } - uint32 expectedDuration = fieldsMeta[3].GetUInt32(), msUntilNext = fieldsMeta[4].GetUInt32(); - chain.push_back(SplineChainLink(expectedDuration, msUntilNext)); + uint32 expectedDuration = fieldsMeta[3].GetUInt32(); + uint32 msUntilNext = fieldsMeta[4].GetUInt32(); + chain.emplace_back(expectedDuration, msUntilNext); if (splineId == 0) ++chainCount; @@ -138,7 +143,7 @@ void SystemMgr::LoadScriptSplineChains() TC_LOG_WARN("server.loading", "Creature #%u has waypoint data for spline chain %u. No such chain exists - entry skipped.", entry, chainId); continue; } - SplineChain& chain = it->second; + std::vector<SplineChainLink>& chain = it->second; if (splineId >= chain.size()) { TC_LOG_WARN("server.loading", "Creature #%u has waypoint data for spline (%u,%u). The specified chain does not have a spline with this index - entry skipped.", entry, chainId, splineId); @@ -158,7 +163,15 @@ void SystemMgr::LoadScriptSplineChains() } } -SplineChain const* SystemMgr::GetSplineChain(Creature const* who, uint16 id) const +std::vector<SplineChainLink> const* SystemMgr::GetSplineChain(uint32 entry, uint16 chainId) const +{ + auto it = m_mSplineChainsMap.find({ entry, chainId }); + if (it != m_mSplineChainsMap.end()) + return &it->second; + return nullptr; +} + +std::vector<SplineChainLink> const* SystemMgr::GetSplineChain(Creature const* who, uint16 id) const { return GetSplineChain(who->GetEntry(), id); } diff --git a/src/server/game/Scripting/ScriptSystem.h b/src/server/game/Scripting/ScriptSystem.h index 304275e87c7..af29bf1fdec 100644 --- a/src/server/game/Scripting/ScriptSystem.h +++ b/src/server/game/Scripting/ScriptSystem.h @@ -21,11 +21,11 @@ #include "Define.h" #include "Hash.h" -#include "SplineChain.h" #include <unordered_map> #include <vector> class Creature; +struct SplineChainLink; #define TEXT_SOURCE_RANGE -1000000 //the amount of entries each text source has available @@ -68,8 +68,10 @@ typedef std::vector<ScriptPointMove> ScriptPointVector; class TC_GAME_API SystemMgr { private: - SystemMgr() { } - ~SystemMgr() { } + SystemMgr(); + ~SystemMgr(); + SystemMgr(SystemMgr const&) = delete; + SystemMgr& operator=(SystemMgr const&) = delete; public: static SystemMgr* instance(); @@ -90,20 +92,13 @@ class TC_GAME_API SystemMgr return &itr->second; } - SplineChain const* GetSplineChain(uint32 entry, uint16 chainId) const - { - auto it = m_mSplineChainsMap.find({ entry, chainId }); - if (it == m_mSplineChainsMap.end()) - return nullptr; - return &it->second; - } - - SplineChain const* GetSplineChain(Creature const* who, uint16 id) const; + std::vector<SplineChainLink> const* GetSplineChain(uint32 entry, uint16 chainId) const; + std::vector<SplineChainLink> const* GetSplineChain(Creature const* who, uint16 id) const; protected: PointMoveMap m_mPointMoveMap; //coordinates for waypoints typedef std::pair<uint32, uint16> ChainKeyType; // creature entry + chain ID - std::unordered_map<ChainKeyType, SplineChain> m_mSplineChainsMap; // spline chains + std::unordered_map<ChainKeyType, std::vector<SplineChainLink>> m_mSplineChainsMap; // spline chains }; #define sScriptSystemMgr SystemMgr::instance() |
