aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
committerariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
commit85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch)
treedf3d2084ee2e35008903c03178039b9c986e2d08 /src/server/game/Scripting
parent052fc24315ace866ea1cf610e85df119b68100c9 (diff)
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/server/game/Scripting')
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp108
-rw-r--r--src/server/game/Scripting/ScriptMgr.h96
-rw-r--r--src/server/game/Scripting/ScriptReloadMgr.cpp40
-rw-r--r--src/server/game/Scripting/ScriptSystem.cpp28
-rw-r--r--src/server/game/Scripting/ScriptSystem.h46
5 files changed, 182 insertions, 136 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 5d71b0ed33e..9f42ded8cc6 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -17,27 +17,32 @@
*/
#include "ScriptMgr.h"
-#include "ScriptReloadMgr.h"
+#include "Chat.h"
#include "Config.h"
+#include "Creature.h"
+#include "CreatureAIImpl.h"
#include "DatabaseEnv.h"
#include "DBCStores.h"
+#include "GossipDef.h"
+#include "InstanceScript.h"
+#include "Item.h"
+#include "LFGScripts.h"
+#include "Log.h"
+#include "MapManager.h"
#include "ObjectMgr.h"
#include "OutdoorPvPMgr.h"
+#include "Player.h"
+#include "ScriptReloadMgr.h"
#include "ScriptSystem.h"
-#include "Transport.h"
-#include "Vehicle.h"
#include "SmartAI.h"
#include "SpellInfo.h"
+#include "SpellMgr.h"
#include "SpellScript.h"
-#include "GossipDef.h"
-#include "CreatureAIImpl.h"
-#include "Player.h"
+#include "Transport.h"
+#include "Vehicle.h"
+#include "Weather.h"
#include "WorldPacket.h"
#include "WorldSession.h"
-#include "Chat.h"
-#include "MapManager.h"
-#include "LFGScripts.h"
-#include "InstanceScript.h"
// Trait which indicates whether this script type
// must be assigned in the database.
@@ -984,7 +989,7 @@ struct TSpellSummary
uint8 Effects; // set of enum SelectEffect
} *SpellSummary;
-ScriptObject::ScriptObject(const char* name) : _name(name)
+ScriptObject::ScriptObject(char const* name) : _name(name)
{
sScriptMgr->IncreaseScriptCount();
}
@@ -1508,7 +1513,7 @@ InstanceScript* ScriptMgr::CreateInstanceData(InstanceMap* map)
{
ASSERT(map);
- GET_SCRIPT_RET(InstanceMapScript, map->GetScriptId(), tmpscript, NULL);
+ GET_SCRIPT_RET(InstanceMapScript, map->GetScriptId(), tmpscript, nullptr);
return tmpscript->GetInstanceScript(map);
}
@@ -1579,7 +1584,7 @@ CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature)
{
ASSERT(creature);
- GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, NULL);
+ GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, nullptr);
return tmpscript->GetAI(creature);
}
@@ -1587,7 +1592,7 @@ GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* gameobject)
{
ASSERT(gameobject);
- GET_SCRIPT_RET(GameObjectScript, gameobject->GetScriptId(), tmpscript, NULL);
+ GET_SCRIPT_RET(GameObjectScript, gameobject->GetScriptId(), tmpscript, nullptr);
return tmpscript->GetAI(gameobject);
}
@@ -1604,12 +1609,12 @@ Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/)
{
/// @todo Implement script-side battlegrounds.
ABORT();
- return NULL;
+ return nullptr;
}
OutdoorPvP* ScriptMgr::CreateOutdoorPvP(uint32 scriptId)
{
- GET_SCRIPT_RET(OutdoorPvPScript, scriptId, tmpscript, NULL);
+ GET_SCRIPT_RET(OutdoorPvPScript, scriptId, tmpscript, nullptr);
return tmpscript->GetOutdoorPvP();
}
@@ -1624,7 +1629,7 @@ std::vector<ChatCommand> ScriptMgr::GetChatCommands()
}
// Sort commands in alphabetical order
- std::sort(table.begin(), table.end(), [](const ChatCommand& a, const ChatCommand&b)
+ std::sort(table.begin(), table.end(), [](ChatCommand const& a, ChatCommand const& b)
{
return strcmp(a.Name, b.Name) < 0;
});
@@ -2070,7 +2075,7 @@ void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid)
FOREACH_SCRIPT(GroupScript)->OnInviteMember(group, guid);
}
-void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason)
+void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason)
{
ASSERT(group);
FOREACH_SCRIPT(GroupScript)->OnRemoveMember(group, guid, method, kicker, reason);
@@ -2119,167 +2124,176 @@ void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& dama
FOREACH_SCRIPT(PlayerScript)->ModifySpellDamageTaken(target, attacker, damage);
}
-SpellScriptLoader::SpellScriptLoader(const char* name)
+SpellScriptLoader::SpellScriptLoader(char const* name)
: ScriptObject(name)
{
ScriptRegistry<SpellScriptLoader>::Instance()->AddScript(this);
}
-ServerScript::ServerScript(const char* name)
+ServerScript::ServerScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<ServerScript>::Instance()->AddScript(this);
}
-WorldScript::WorldScript(const char* name)
+WorldScript::WorldScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<WorldScript>::Instance()->AddScript(this);
}
-FormulaScript::FormulaScript(const char* name)
+FormulaScript::FormulaScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<FormulaScript>::Instance()->AddScript(this);
}
-UnitScript::UnitScript(const char* name, bool addToScripts)
+UnitScript::UnitScript(char const* name, bool addToScripts)
: ScriptObject(name)
{
if (addToScripts)
ScriptRegistry<UnitScript>::Instance()->AddScript(this);
}
-WorldMapScript::WorldMapScript(const char* name, uint32 mapId)
- : ScriptObject(name), MapScript<Map>(mapId)
+WorldMapScript::WorldMapScript(char const* name, uint32 mapId)
+ : ScriptObject(name), MapScript<Map>(sMapStore.LookupEntry(mapId))
{
+ if (!GetEntry())
+ TC_LOG_ERROR("scripts", "Invalid WorldMapScript for %u; no such map ID.", mapId);
+
if (GetEntry() && !GetEntry()->IsWorldMap())
TC_LOG_ERROR("scripts", "WorldMapScript for map %u is invalid.", mapId);
ScriptRegistry<WorldMapScript>::Instance()->AddScript(this);
}
-InstanceMapScript::InstanceMapScript(const char* name, uint32 mapId)
- : ScriptObject(name), MapScript<InstanceMap>(mapId)
+InstanceMapScript::InstanceMapScript(char const* name, uint32 mapId)
+ : ScriptObject(name), MapScript<InstanceMap>(sMapStore.LookupEntry(mapId))
{
+ if (!GetEntry())
+ TC_LOG_ERROR("scripts", "Invalid InstanceMapScript for %u; no such map ID.", mapId);
+
if (GetEntry() && !GetEntry()->IsDungeon())
TC_LOG_ERROR("scripts", "InstanceMapScript for map %u is invalid.", mapId);
ScriptRegistry<InstanceMapScript>::Instance()->AddScript(this);
}
-BattlegroundMapScript::BattlegroundMapScript(const char* name, uint32 mapId)
- : ScriptObject(name), MapScript<BattlegroundMap>(mapId)
+BattlegroundMapScript::BattlegroundMapScript(char const* name, uint32 mapId)
+ : ScriptObject(name), MapScript<BattlegroundMap>(sMapStore.LookupEntry(mapId))
{
+ if (!GetEntry())
+ TC_LOG_ERROR("scripts", "Invalid BattlegroundMapScript for %u; no such map ID.", mapId);
+
if (GetEntry() && !GetEntry()->IsBattleground())
TC_LOG_ERROR("scripts", "BattlegroundMapScript for map %u is invalid.", mapId);
ScriptRegistry<BattlegroundMapScript>::Instance()->AddScript(this);
}
-ItemScript::ItemScript(const char* name)
+ItemScript::ItemScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<ItemScript>::Instance()->AddScript(this);
}
-CreatureScript::CreatureScript(const char* name)
+CreatureScript::CreatureScript(char const* name)
: UnitScript(name, false)
{
ScriptRegistry<CreatureScript>::Instance()->AddScript(this);
}
-GameObjectScript::GameObjectScript(const char* name)
+GameObjectScript::GameObjectScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<GameObjectScript>::Instance()->AddScript(this);
}
-AreaTriggerScript::AreaTriggerScript(const char* name)
+AreaTriggerScript::AreaTriggerScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<AreaTriggerScript>::Instance()->AddScript(this);
}
-BattlegroundScript::BattlegroundScript(const char* name)
+BattlegroundScript::BattlegroundScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<BattlegroundScript>::Instance()->AddScript(this);
}
-OutdoorPvPScript::OutdoorPvPScript(const char* name)
+OutdoorPvPScript::OutdoorPvPScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<OutdoorPvPScript>::Instance()->AddScript(this);
}
-CommandScript::CommandScript(const char* name)
+CommandScript::CommandScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<CommandScript>::Instance()->AddScript(this);
}
-WeatherScript::WeatherScript(const char* name)
+WeatherScript::WeatherScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<WeatherScript>::Instance()->AddScript(this);
}
-AuctionHouseScript::AuctionHouseScript(const char* name)
+AuctionHouseScript::AuctionHouseScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<AuctionHouseScript>::Instance()->AddScript(this);
}
-ConditionScript::ConditionScript(const char* name)
+ConditionScript::ConditionScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<ConditionScript>::Instance()->AddScript(this);
}
-VehicleScript::VehicleScript(const char* name)
+VehicleScript::VehicleScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<VehicleScript>::Instance()->AddScript(this);
}
-DynamicObjectScript::DynamicObjectScript(const char* name)
+DynamicObjectScript::DynamicObjectScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<DynamicObjectScript>::Instance()->AddScript(this);
}
-TransportScript::TransportScript(const char* name)
+TransportScript::TransportScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<TransportScript>::Instance()->AddScript(this);
}
-AchievementCriteriaScript::AchievementCriteriaScript(const char* name)
+AchievementCriteriaScript::AchievementCriteriaScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<AchievementCriteriaScript>::Instance()->AddScript(this);
}
-PlayerScript::PlayerScript(const char* name)
+PlayerScript::PlayerScript(char const* name)
: UnitScript(name, false)
{
ScriptRegistry<PlayerScript>::Instance()->AddScript(this);
}
-AccountScript::AccountScript(const char* name)
+AccountScript::AccountScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<AccountScript>::Instance()->AddScript(this);
}
-GuildScript::GuildScript(const char* name)
+GuildScript::GuildScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<GuildScript>::Instance()->AddScript(this);
}
-GroupScript::GroupScript(const char* name)
+GroupScript::GroupScript(char const* name)
: ScriptObject(name)
{
ScriptRegistry<GroupScript>::Instance()->AddScript(this);
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index ff89a1314a2..311a7faf911 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -20,12 +20,8 @@
#define SC_SCRIPTMGR_H
#include "Common.h"
-#include <atomic>
-#include "DBCStores.h"
-#include "QuestDef.h"
-#include "SharedDefines.h"
-#include "World.h"
-#include "Weather.h"
+#include "ObjectGuid.h"
+#include <vector>
class AccountMgr;
class AuctionHouseObject;
@@ -59,18 +55,33 @@ class SpellCastTargets;
class Transport;
class Unit;
class Vehicle;
+class Weather;
class WorldPacket;
class WorldSocket;
class WorldObject;
class WorldSession;
struct AchievementCriteriaData;
+struct AreaTriggerEntry;
struct AuctionEntry;
struct ConditionSourceInfo;
struct Condition;
struct CreatureTemplate;
struct CreatureData;
struct ItemTemplate;
+struct MapEntry;
+
+enum BattlegroundTypeId : uint32;
+enum ContentLevels : uint8;
+enum Difficulty : uint8;
+enum DuelCompleteType : uint8;
+enum QuestStatus : uint8;
+enum RemoveMethod : uint8;
+enum ShutdownExitCode : uint32;
+enum ShutdownMask : uint32;
+enum SpellEffIndex : uint8;
+enum WeatherState : uint32;
+enum XPColorChar : uint8;
#define VISIBLE_RANGE 166.0f //MAX visible range (size of grid)
@@ -100,7 +111,7 @@ struct ItemTemplate;
protected:
- MyScriptType(const char* name, uint32 someId)
+ MyScriptType(char const* name, uint32 someId)
: ScriptObject(name), _someId(someId)
{
ScriptRegistry<MyScriptType>::AddScript(this);
@@ -161,7 +172,7 @@ class TC_GAME_API ScriptObject
protected:
- ScriptObject(const char* name);
+ ScriptObject(char const* name);
virtual ~ScriptObject();
private:
@@ -188,22 +199,22 @@ class TC_GAME_API SpellScriptLoader : public ScriptObject
{
protected:
- SpellScriptLoader(const char* name);
+ SpellScriptLoader(char const* name);
public:
// Should return a fully valid SpellScript pointer.
- virtual SpellScript* GetSpellScript() const { return NULL; }
+ virtual SpellScript* GetSpellScript() const { return nullptr; }
// Should return a fully valid AuraScript pointer.
- virtual AuraScript* GetAuraScript() const { return NULL; }
+ virtual AuraScript* GetAuraScript() const { return nullptr; }
};
class TC_GAME_API ServerScript : public ScriptObject
{
protected:
- ServerScript(const char* name);
+ ServerScript(char const* name);
public:
@@ -233,7 +244,7 @@ class TC_GAME_API WorldScript : public ScriptObject
{
protected:
- WorldScript(const char* name);
+ WorldScript(char const* name);
public:
@@ -266,7 +277,7 @@ class TC_GAME_API FormulaScript : public ScriptObject
{
protected:
- FormulaScript(const char* name);
+ FormulaScript(char const* name);
public:
@@ -298,12 +309,7 @@ template<class TMap> class MapScript : public UpdatableScript<TMap>
protected:
- MapScript(uint32 mapId)
- : _mapEntry(sMapStore.LookupEntry(mapId))
- {
- if (!_mapEntry)
- TC_LOG_ERROR("scripts", "Invalid MapScript for %u; no such map ID.", mapId);
- }
+ MapScript(MapEntry const* mapEntry) : _mapEntry(mapEntry) { }
public:
@@ -333,7 +339,7 @@ class TC_GAME_API WorldMapScript : public ScriptObject, public MapScript<Map>
{
protected:
- WorldMapScript(const char* name, uint32 mapId);
+ WorldMapScript(char const* name, uint32 mapId);
};
class TC_GAME_API InstanceMapScript
@@ -341,26 +347,26 @@ class TC_GAME_API InstanceMapScript
{
protected:
- InstanceMapScript(const char* name, uint32 mapId);
+ InstanceMapScript(char const* name, uint32 mapId);
public:
// Gets an InstanceScript object for this instance.
- virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return NULL; }
+ virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return nullptr; }
};
class TC_GAME_API BattlegroundMapScript : public ScriptObject, public MapScript<BattlegroundMap>
{
protected:
- BattlegroundMapScript(const char* name, uint32 mapId);
+ BattlegroundMapScript(char const* name, uint32 mapId);
};
class TC_GAME_API ItemScript : public ScriptObject
{
protected:
- ItemScript(const char* name);
+ ItemScript(char const* name);
public:
@@ -384,7 +390,7 @@ class TC_GAME_API UnitScript : public ScriptObject
{
protected:
- UnitScript(const char* name, bool addToScripts = true);
+ UnitScript(char const* name, bool addToScripts = true);
public:
// Called when a unit deals healing to another unit
@@ -407,7 +413,7 @@ class TC_GAME_API CreatureScript : public UnitScript
{
protected:
- CreatureScript(const char* name);
+ CreatureScript(char const* name);
public:
@@ -422,7 +428,7 @@ class TC_GAME_API GameObjectScript : public ScriptObject
{
protected:
- GameObjectScript(const char* name);
+ GameObjectScript(char const* name);
public:
@@ -434,7 +440,7 @@ class TC_GAME_API AreaTriggerScript : public ScriptObject
{
protected:
- AreaTriggerScript(const char* name);
+ AreaTriggerScript(char const* name);
public:
@@ -446,7 +452,7 @@ class TC_GAME_API BattlegroundScript : public ScriptObject
{
protected:
- BattlegroundScript(const char* name);
+ BattlegroundScript(char const* name);
public:
@@ -458,7 +464,7 @@ class TC_GAME_API OutdoorPvPScript : public ScriptObject
{
protected:
- OutdoorPvPScript(const char* name);
+ OutdoorPvPScript(char const* name);
public:
@@ -470,7 +476,7 @@ class TC_GAME_API CommandScript : public ScriptObject
{
protected:
- CommandScript(const char* name);
+ CommandScript(char const* name);
public:
@@ -482,7 +488,7 @@ class TC_GAME_API WeatherScript : public ScriptObject, public UpdatableScript<We
{
protected:
- WeatherScript(const char* name);
+ WeatherScript(char const* name);
public:
@@ -494,7 +500,7 @@ class TC_GAME_API AuctionHouseScript : public ScriptObject
{
protected:
- AuctionHouseScript(const char* name);
+ AuctionHouseScript(char const* name);
public:
@@ -515,7 +521,7 @@ class TC_GAME_API ConditionScript : public ScriptObject
{
protected:
- ConditionScript(const char* name);
+ ConditionScript(char const* name);
public:
@@ -527,7 +533,7 @@ class TC_GAME_API VehicleScript : public ScriptObject
{
protected:
- VehicleScript(const char* name);
+ VehicleScript(char const* name);
public:
@@ -554,14 +560,14 @@ class TC_GAME_API DynamicObjectScript : public ScriptObject, public UpdatableScr
{
protected:
- DynamicObjectScript(const char* name);
+ DynamicObjectScript(char const* name);
};
class TC_GAME_API TransportScript : public ScriptObject, public UpdatableScript<Transport>
{
protected:
- TransportScript(const char* name);
+ TransportScript(char const* name);
public:
@@ -582,7 +588,7 @@ class TC_GAME_API AchievementCriteriaScript : public ScriptObject
{
protected:
- AchievementCriteriaScript(const char* name);
+ AchievementCriteriaScript(char const* name);
public:
@@ -594,7 +600,7 @@ class TC_GAME_API PlayerScript : public UnitScript
{
protected:
- PlayerScript(const char* name);
+ PlayerScript(char const* name);
public:
@@ -694,7 +700,7 @@ class TC_GAME_API AccountScript : public ScriptObject
{
protected:
- AccountScript(const char* name);
+ AccountScript(char const* name);
public:
@@ -721,7 +727,7 @@ class TC_GAME_API GuildScript : public ScriptObject
{
protected:
- GuildScript(const char* name);
+ GuildScript(char const* name);
public:
@@ -762,7 +768,7 @@ class TC_GAME_API GroupScript : public ScriptObject
{
protected:
- GroupScript(const char* name);
+ GroupScript(char const* name);
public:
@@ -773,7 +779,7 @@ class TC_GAME_API GroupScript : public ScriptObject
virtual void OnInviteMember(Group* /*group*/, ObjectGuid /*guid*/) { }
// Called when a member is removed from a group.
- virtual void OnRemoveMember(Group* /*group*/, ObjectGuid /*guid*/, RemoveMethod /*method*/, ObjectGuid /*kicker*/, const char* /*reason*/) { }
+ virtual void OnRemoveMember(Group* /*group*/, ObjectGuid /*guid*/, RemoveMethod /*method*/, ObjectGuid /*kicker*/, char const* /*reason*/) { }
// Called when the leader of a group is changed.
virtual void OnChangeLeader(Group* /*group*/, ObjectGuid /*newLeaderGuid*/, ObjectGuid /*oldLeaderGuid*/) { }
@@ -1027,7 +1033,7 @@ class TC_GAME_API ScriptMgr
void OnGroupAddMember(Group* group, ObjectGuid guid);
void OnGroupInviteMember(Group* group, ObjectGuid guid);
- void OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason);
+ void OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason);
void OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid);
void OnGroupDisband(Group* group);
diff --git a/src/server/game/Scripting/ScriptReloadMgr.cpp b/src/server/game/Scripting/ScriptReloadMgr.cpp
index 18b910420b1..04c15b67c86 100644
--- a/src/server/game/Scripting/ScriptReloadMgr.cpp
+++ b/src/server/game/Scripting/ScriptReloadMgr.cpp
@@ -17,6 +17,7 @@
#include "ScriptReloadMgr.h"
#include "Errors.h"
+#include "Optional.h"
#ifndef TRINITY_API_USE_DYNAMIC_LINKING
@@ -36,31 +37,30 @@ ScriptReloadMgr* ScriptReloadMgr::instance()
#else
+#include "BuiltInConfig.h"
+#include "Config.h"
+#include "GitRevision.h"
+#include "Log.h"
+#include "MPSCQueue.h"
+#include "Regex.h"
+#include "ScriptMgr.h"
+#include "SHA1.h"
+#include "StartProcess.h"
+#include "Timer.h"
+#include "World.h"
+#include <boost/algorithm/string/replace.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/system/system_error.hpp>
+#include <efsw/efsw.hpp>
#include <algorithm>
-#include <vector>
+#include <fstream>
#include <future>
#include <memory>
-#include <fstream>
+#include <sstream>
#include <type_traits>
-#include <unordered_set>
#include <unordered_map>
-
-#include "Regex.h"
-
-#include <boost/algorithm/string/replace.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/system/system_error.hpp>
-
-#include "efsw/efsw.hpp"
-
-#include "Log.h"
-#include "Config.h"
-#include "BuiltInConfig.h"
-#include "ScriptMgr.h"
-#include "SHA1.h"
-#include "StartProcess.h"
-#include "MPSCQueue.h"
-#include "GitRevision.h"
+#include <unordered_set>
+#include <vector>
namespace fs = boost::filesystem;
diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp
index a310d4d6ee0..1b4ad6b98d5 100644
--- a/src/server/game/Scripting/ScriptSystem.cpp
+++ b/src/server/game/Scripting/ScriptSystem.cpp
@@ -17,10 +17,15 @@
*/
#include "ScriptSystem.h"
-#include "ObjectMgr.h"
+#include "Creature.h"
#include "DatabaseEnv.h"
+#include "Log.h"
+#include "ObjectMgr.h"
#include "ScriptMgr.h"
-#include "Creature.h"
+#include "SplineChain.h"
+
+SystemMgr::SystemMgr() = default;
+SystemMgr::~SystemMgr() = default;
SystemMgr* SystemMgr::instance()
{
@@ -108,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())
{
@@ -116,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;
@@ -137,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);
@@ -157,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 nullptr;
+ return &it->second;
+}
+
+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 c67316eb64b..7828c24d680 100644
--- a/src/server/game/Scripting/ScriptSystem.h
+++ b/src/server/game/Scripting/ScriptSystem.h
@@ -1,14 +1,31 @@
-/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
-* This program is free software licensed under GPL version 2
-* Please see the included DOCS/LICENSE.TXT for more information */
+/*
+ * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef SC_SYSTEM_H
#define SC_SYSTEM_H
-#include "ScriptMgr.h"
-#include "SplineChain.h"
+#include "Define.h"
+#include "Hash.h"
+#include <unordered_map>
+#include <vector>
class Creature;
+struct SplineChainLink;
#define TEXT_SOURCE_RANGE -1000000 //the amount of entries each text source has available
@@ -27,8 +44,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();
@@ -49,20 +68,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()