diff options
Diffstat (limited to 'src/server/game/Scripting')
-rw-r--r-- | src/server/game/Scripting/ScriptMgr.cpp | 88 | ||||
-rw-r--r-- | src/server/game/Scripting/ScriptMgr.h | 94 |
2 files changed, 168 insertions, 14 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 1ca7264aa2d..cbec3f39834 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1196,7 +1196,7 @@ ScriptMgr::ScriptMgr() { } -ScriptMgr::~ScriptMgr() { } +ScriptMgr::~ScriptMgr() = default; ScriptMgr* ScriptMgr::instance() { @@ -2374,24 +2374,32 @@ ServerScript::ServerScript(char const* name) ScriptRegistry<ServerScript>::Instance()->AddScript(this); } +ServerScript::~ServerScript() = default; + WorldScript::WorldScript(char const* name) : ScriptObject(name) { ScriptRegistry<WorldScript>::Instance()->AddScript(this); } +WorldScript::~WorldScript() = default; + FormulaScript::FormulaScript(char const* name) : ScriptObject(name) { ScriptRegistry<FormulaScript>::Instance()->AddScript(this); } +FormulaScript::~FormulaScript() = default; + UnitScript::UnitScript(char const* name) : ScriptObject(name) { ScriptRegistry<UnitScript>::Instance()->AddScript(this); } +UnitScript::~UnitScript() = default; + WorldMapScript::WorldMapScript(char const* name, uint32 mapId) : ScriptObject(name), MapScript<Map>(sMapStore.LookupEntry(mapId)) { @@ -2404,6 +2412,8 @@ WorldMapScript::WorldMapScript(char const* name, uint32 mapId) ScriptRegistry<WorldMapScript>::Instance()->AddScript(this); } +WorldMapScript::~WorldMapScript() = default; + InstanceMapScript::InstanceMapScript(char const* name, uint32 mapId) : ScriptObject(name), MapScript<InstanceMap>(sMapStore.LookupEntry(mapId)) { @@ -2416,6 +2426,8 @@ InstanceMapScript::InstanceMapScript(char const* name, uint32 mapId) ScriptRegistry<InstanceMapScript>::Instance()->AddScript(this); } +InstanceMapScript::~InstanceMapScript() = default; + BattlegroundMapScript::BattlegroundMapScript(char const* name, uint32 mapId) : ScriptObject(name), MapScript<BattlegroundMap>(sMapStore.LookupEntry(mapId)) { @@ -2428,30 +2440,42 @@ BattlegroundMapScript::BattlegroundMapScript(char const* name, uint32 mapId) ScriptRegistry<BattlegroundMapScript>::Instance()->AddScript(this); } +BattlegroundMapScript::~BattlegroundMapScript() = default; + ItemScript::ItemScript(char const* name) : ScriptObject(name) { ScriptRegistry<ItemScript>::Instance()->AddScript(this); } +ItemScript::~ItemScript() = default; + CreatureScript::CreatureScript(char const* name) : ScriptObject(name) { ScriptRegistry<CreatureScript>::Instance()->AddScript(this); } +CreatureScript::~CreatureScript() = default; + GameObjectScript::GameObjectScript(char const* name) : ScriptObject(name) { ScriptRegistry<GameObjectScript>::Instance()->AddScript(this); } +GameObjectScript::~GameObjectScript() = default; + AreaTriggerScript::AreaTriggerScript(char const* name) : ScriptObject(name) { ScriptRegistry<AreaTriggerScript>::Instance()->AddScript(this); } +AreaTriggerScript::~AreaTriggerScript() = default; + +OnlyOnceAreaTriggerScript::~OnlyOnceAreaTriggerScript() = default; + bool OnlyOnceAreaTriggerScript::OnTrigger(Player* player, AreaTriggerEntry const* trigger) { uint32 const triggerId = trigger->ID; @@ -2473,95 +2497,111 @@ BattlefieldScript::BattlefieldScript(char const* name) ScriptRegistry<BattlefieldScript>::Instance()->AddScript(this); } +BattlefieldScript::~BattlefieldScript() = default; + BattlegroundScript::BattlegroundScript(char const* name) : ScriptObject(name) { ScriptRegistry<BattlegroundScript>::Instance()->AddScript(this); } +BattlegroundScript::~BattlegroundScript() = default; + OutdoorPvPScript::OutdoorPvPScript(char const* name) : ScriptObject(name) { ScriptRegistry<OutdoorPvPScript>::Instance()->AddScript(this); } +OutdoorPvPScript::~OutdoorPvPScript() = default; + CommandScript::CommandScript(char const* name) : ScriptObject(name) { ScriptRegistry<CommandScript>::Instance()->AddScript(this); } +CommandScript::~CommandScript() = default; + WeatherScript::WeatherScript(char const* name) : ScriptObject(name) { ScriptRegistry<WeatherScript>::Instance()->AddScript(this); } +WeatherScript::~WeatherScript() = default; + AuctionHouseScript::AuctionHouseScript(char const* name) : ScriptObject(name) { ScriptRegistry<AuctionHouseScript>::Instance()->AddScript(this); } +AuctionHouseScript::~AuctionHouseScript() = default; + ConditionScript::ConditionScript(char const* name) : ScriptObject(name) { ScriptRegistry<ConditionScript>::Instance()->AddScript(this); } +ConditionScript::~ConditionScript() = default; + VehicleScript::VehicleScript(char const* name) : ScriptObject(name) { ScriptRegistry<VehicleScript>::Instance()->AddScript(this); } +VehicleScript::~VehicleScript() = default; + DynamicObjectScript::DynamicObjectScript(char const* name) : ScriptObject(name) { ScriptRegistry<DynamicObjectScript>::Instance()->AddScript(this); } +DynamicObjectScript::~DynamicObjectScript() = default; + TransportScript::TransportScript(char const* name) : ScriptObject(name) { ScriptRegistry<TransportScript>::Instance()->AddScript(this); } +TransportScript::~TransportScript() = default; + AchievementScript::AchievementScript(char const* name) : ScriptObject(name) { ScriptRegistry<AchievementScript>::Instance()->AddScript(this); } +AchievementScript::~AchievementScript() = default; + AchievementCriteriaScript::AchievementCriteriaScript(char const* name) : ScriptObject(name) { ScriptRegistry<AchievementCriteriaScript>::Instance()->AddScript(this); } +AchievementCriteriaScript::~AchievementCriteriaScript() = default; + PlayerScript::PlayerScript(char const* name) : ScriptObject(name) { ScriptRegistry<PlayerScript>::Instance()->AddScript(this); } +PlayerScript::~PlayerScript() = default; + AccountScript::AccountScript(char const* name) : ScriptObject(name) { ScriptRegistry<AccountScript>::Instance()->AddScript(this); } -SceneScript::SceneScript(char const* name) - : ScriptObject(name) -{ - ScriptRegistry<SceneScript>::Instance()->AddScript(this); -} - -QuestScript::QuestScript(char const* name) - : ScriptObject(name) -{ - ScriptRegistry<QuestScript>::Instance()->AddScript(this); -} +AccountScript::~AccountScript() = default; GuildScript::GuildScript(char const* name) : ScriptObject(name) @@ -2569,24 +2609,48 @@ GuildScript::GuildScript(char const* name) ScriptRegistry<GuildScript>::Instance()->AddScript(this); } +GuildScript::~GuildScript() = default; + GroupScript::GroupScript(char const* name) : ScriptObject(name) { ScriptRegistry<GroupScript>::Instance()->AddScript(this); } +GroupScript::~GroupScript() = default; + AreaTriggerEntityScript::AreaTriggerEntityScript(char const* name) : ScriptObject(name) { ScriptRegistry<AreaTriggerEntityScript>::Instance()->AddScript(this); } +AreaTriggerEntityScript::~AreaTriggerEntityScript() = default; + ConversationScript::ConversationScript(char const* name) : ScriptObject(name) { ScriptRegistry<ConversationScript>::Instance()->AddScript(this); } +ConversationScript::~ConversationScript() = default; + +SceneScript::SceneScript(char const* name) + : ScriptObject(name) +{ + ScriptRegistry<SceneScript>::Instance()->AddScript(this); +} + +SceneScript::~SceneScript() = default; + +QuestScript::QuestScript(char const* name) + : ScriptObject(name) +{ + ScriptRegistry<QuestScript>::Instance()->AddScript(this); +} + +QuestScript::~QuestScript() = default; + // Specialize for each script type class like so: template class TC_GAME_API ScriptRegistry<SpellScriptLoader>; template class TC_GAME_API ScriptRegistry<ServerScript>; diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 7aae463cd86..9d420542cae 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -176,6 +176,11 @@ class TC_GAME_API ScriptObject public: + ScriptObject(ScriptObject const& right) = delete; + ScriptObject(ScriptObject&& right) = delete; + ScriptObject& operator=(ScriptObject const& right) = delete; + ScriptObject& operator=(ScriptObject&& right) = delete; + const std::string& GetName() const { return _name; } protected: @@ -200,6 +205,11 @@ template<class TObject> class UpdatableScript public: + UpdatableScript(UpdatableScript const& right) = delete; + UpdatableScript(UpdatableScript&& right) = delete; + UpdatableScript& operator=(UpdatableScript const& right) = delete; + UpdatableScript& operator=(UpdatableScript&& right) = delete; + virtual void OnUpdate(TObject* /*obj*/, uint32 /*diff*/) { } }; @@ -226,6 +236,8 @@ class TC_GAME_API ServerScript : public ScriptObject public: + ~ServerScript(); + // Called when reactive socket I/O is started (WorldTcpSessionMgr). virtual void OnNetworkStart() { } @@ -256,6 +268,8 @@ class TC_GAME_API WorldScript : public ScriptObject public: + ~WorldScript(); + // Called when the open/closed state of the world changes. virtual void OnOpenStateChange(bool /*open*/) { } @@ -289,6 +303,8 @@ class TC_GAME_API FormulaScript : public ScriptObject public: + ~FormulaScript(); + // Called after calculating honor. virtual void OnHonorCalculation(float& /*honor*/, uint8 /*level*/, float /*multiplier*/) { } @@ -349,6 +365,10 @@ class TC_GAME_API WorldMapScript : public ScriptObject, public MapScript<Map> protected: WorldMapScript(char const* name, uint32 mapId); + + public: + + ~WorldMapScript(); }; class TC_GAME_API InstanceMapScript @@ -360,6 +380,8 @@ class TC_GAME_API InstanceMapScript public: + ~InstanceMapScript(); + // Gets an InstanceScript object for this instance. virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return nullptr; } }; @@ -369,6 +391,10 @@ class TC_GAME_API BattlegroundMapScript : public ScriptObject, public MapScript< protected: BattlegroundMapScript(char const* name, uint32 mapId); + + public: + + ~BattlegroundMapScript(); }; class TC_GAME_API ItemScript : public ScriptObject @@ -379,6 +405,8 @@ class TC_GAME_API ItemScript : public ScriptObject public: + ~ItemScript(); + // Called when a player accepts a quest from the item. virtual bool OnQuestAccept(Player* /*player*/, Item* /*item*/, Quest const* /*quest*/) { return false; } @@ -402,6 +430,9 @@ class TC_GAME_API UnitScript : public ScriptObject UnitScript(char const* name); public: + + ~UnitScript(); + // Called when a unit deals healing to another unit virtual void OnHeal(Unit* /*healer*/, Unit* /*reciever*/, uint32& /*gain*/) { } @@ -428,6 +459,9 @@ class TC_GAME_API CreatureScript : public ScriptObject CreatureScript(char const* name); public: + + ~CreatureScript(); + // Called when an unit exits a vehicle virtual void ModifyVehiclePassengerExitPos(Unit* /*passenger*/, Vehicle* /*vehicle*/, Position& /*pos*/) { } @@ -443,6 +477,8 @@ class TC_GAME_API GameObjectScript : public ScriptObject public: + ~GameObjectScript(); + // Called when a GameObjectAI object is needed for the gameobject. virtual GameObjectAI* GetAI(GameObject* /*go*/) const = 0; }; @@ -455,6 +491,8 @@ class TC_GAME_API AreaTriggerScript : public ScriptObject public: + ~AreaTriggerScript(); + // Called when the area trigger is activated by a player. virtual bool OnTrigger(Player* /*player*/, AreaTriggerEntry const* /*trigger*/) { return false; } @@ -464,9 +502,12 @@ class TC_GAME_API AreaTriggerScript : public ScriptObject class TC_GAME_API OnlyOnceAreaTriggerScript : public AreaTriggerScript { - using AreaTriggerScript::AreaTriggerScript; + using AreaTriggerScript::AreaTriggerScript; public: + + ~OnlyOnceAreaTriggerScript(); + bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) final; protected: @@ -484,6 +525,8 @@ class TC_GAME_API BattlefieldScript : public ScriptObject public: + ~BattlefieldScript(); + virtual Battlefield* GetBattlefield() const = 0; }; @@ -495,6 +538,8 @@ class TC_GAME_API BattlegroundScript : public ScriptObject public: + ~BattlegroundScript(); + // Should return a fully valid Battleground object for the type ID. virtual Battleground* GetBattleground() const = 0; }; @@ -507,6 +552,8 @@ class TC_GAME_API OutdoorPvPScript : public ScriptObject public: + ~OutdoorPvPScript(); + // Should return a fully valid OutdoorPvP object for the type ID. virtual OutdoorPvP* GetOutdoorPvP() const = 0; }; @@ -519,6 +566,8 @@ class TC_GAME_API CommandScript : public ScriptObject public: + ~CommandScript(); + // Should return a pointer to a valid command table (ChatCommand array) to be used by ChatHandler. virtual std::vector<ChatCommand> GetCommands() const = 0; }; @@ -531,6 +580,8 @@ class TC_GAME_API WeatherScript : public ScriptObject, public UpdatableScript<We public: + ~WeatherScript(); + // Called when the weather changes in the zone this script is associated with. virtual void OnChange(Weather* /*weather*/, WeatherState /*state*/, float /*grade*/) { } }; @@ -543,6 +594,8 @@ class TC_GAME_API AuctionHouseScript : public ScriptObject public: + ~AuctionHouseScript(); + // Called when an auction is added to an auction house. virtual void OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionPosting* /*auction*/) { } @@ -564,6 +617,8 @@ class TC_GAME_API ConditionScript : public ScriptObject public: + ~ConditionScript(); + // Called when a single condition is checked for a player. virtual bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; } }; @@ -576,6 +631,8 @@ class TC_GAME_API VehicleScript : public ScriptObject public: + ~VehicleScript(); + // Called after a vehicle is installed. virtual void OnInstall(Vehicle* /*veh*/) { } @@ -600,6 +657,10 @@ class TC_GAME_API DynamicObjectScript : public ScriptObject, public UpdatableScr protected: DynamicObjectScript(char const* name); + + public: + + ~DynamicObjectScript(); }; class TC_GAME_API TransportScript : public ScriptObject, public UpdatableScript<Transport> @@ -610,6 +671,8 @@ class TC_GAME_API TransportScript : public ScriptObject, public UpdatableScript< public: + ~TransportScript(); + // Called when a player boards the transport. virtual void OnAddPassenger(Transport* /*transport*/, Player* /*player*/) { } @@ -631,6 +694,8 @@ class TC_GAME_API AchievementScript : public ScriptObject public: + ~AchievementScript(); + // Called when an achievement is completed. virtual void OnCompleted(Player* /*player*/, AchievementEntry const* /*achievement*/) { } }; @@ -643,6 +708,8 @@ class TC_GAME_API AchievementCriteriaScript : public ScriptObject public: + ~AchievementCriteriaScript(); + // Called when an additional criteria is checked. virtual bool OnCheck(Player* source, Unit* target) = 0; }; @@ -655,6 +722,8 @@ class TC_GAME_API PlayerScript : public ScriptObject public: + ~PlayerScript(); + // Called when a player kills another player virtual void OnPVPKill(Player* /*killer*/, Player* /*killed*/) { } @@ -761,6 +830,8 @@ class TC_GAME_API AccountScript : public ScriptObject public: + ~AccountScript(); + // Called when an account logged in succesfully virtual void OnAccountLogin(uint32 /*accountId*/) {} @@ -788,6 +859,8 @@ class TC_GAME_API GuildScript : public ScriptObject public: + ~GuildScript(); + // Called when a member is added to the guild. virtual void OnAddMember(Guild* /*guild*/, Player* /*player*/, uint8 /*plRank*/) { } @@ -829,6 +902,8 @@ class TC_GAME_API GroupScript : public ScriptObject public: + ~GroupScript(); + // Called when a member is added to a group. virtual void OnAddMember(Group* /*group*/, ObjectGuid /*guid*/) { } @@ -853,6 +928,8 @@ class TC_GAME_API AreaTriggerEntityScript : public ScriptObject public: + ~AreaTriggerEntityScript(); + // Called when a AreaTriggerAI object is needed for the areatrigger. virtual AreaTriggerAI* GetAI(AreaTrigger* /*at*/) const { return nullptr; } }; @@ -864,6 +941,8 @@ class TC_GAME_API ConversationScript : public ScriptObject public: + ~ConversationScript(); + // Called when Conversation is created but not added to Map yet. virtual void OnConversationCreate(Conversation* /*conversation*/, Unit* /*creator*/) { } @@ -878,6 +957,9 @@ class TC_GAME_API SceneScript : public ScriptObject SceneScript(char const* name); public: + + ~SceneScript(); + // Called when a player start a scene virtual void OnSceneStart(Player* /*player*/, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) { } @@ -898,6 +980,9 @@ class TC_GAME_API QuestScript : public ScriptObject QuestScript(char const* name); public: + + ~QuestScript(); + // Called when a quest status change virtual void OnQuestStatusChange(Player* /*player*/, Quest const* /*quest*/, QuestStatus /*oldStatus*/, QuestStatus /*newStatus*/) { } @@ -915,7 +1000,12 @@ class TC_GAME_API ScriptMgr private: ScriptMgr(); - virtual ~ScriptMgr(); + ~ScriptMgr(); + + ScriptMgr(ScriptMgr const& right) = delete; + ScriptMgr(ScriptMgr&& right) = delete; + ScriptMgr& operator=(ScriptMgr const& right) = delete; + ScriptMgr& operator=(ScriptMgr&& right) = delete; void FillSpellSummary(); void LoadDatabase(); |