mirror of
https://github.com/mangosfour/server.git
synced 2025-12-24 01:37:02 +00:00
[10935] Move script calls to ScriptMgr
- Script library presence is now optional. - Some script hooks have new names. Scripting libraries need to be adjusted accordingly. Signed-off-by: zergtmn <zerg@myisp.com>
This commit is contained in:
parent
918e646ca2
commit
ec6089bbd8
32 changed files with 454 additions and 435 deletions
|
|
@ -22,6 +22,21 @@
|
|||
#include "Common.h"
|
||||
#include "Policies/Singleton.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "DBCEnums.h"
|
||||
|
||||
struct AreaTriggerEntry;
|
||||
class Aura;
|
||||
class Creature;
|
||||
class CreatureAI;
|
||||
class GameObject;
|
||||
class InstanceData;
|
||||
class Item;
|
||||
class Map;
|
||||
class Player;
|
||||
class Quest;
|
||||
class SpellCastTargets;
|
||||
class Unit;
|
||||
class WorldObject;
|
||||
|
||||
enum eScriptCommand
|
||||
{
|
||||
|
|
@ -294,8 +309,6 @@ public:
|
|||
ScriptMgr();
|
||||
~ScriptMgr();
|
||||
|
||||
typedef std::vector<std::string> ScriptNameMap;
|
||||
|
||||
void LoadGameObjectScripts();
|
||||
void LoadQuestEndScripts();
|
||||
void LoadQuestStartScripts();
|
||||
|
|
@ -313,13 +326,47 @@ public:
|
|||
uint32 GetAreaTriggerScriptId(uint32 triggerId) const;
|
||||
uint32 GetEventIdScriptId(uint32 eventId) const;
|
||||
|
||||
ScriptNameMap const& GetScriptNames() { return m_scriptNames; }
|
||||
const char* GetScriptName(uint32 id) const { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; }
|
||||
uint32 GetScriptId(const char *name) const;
|
||||
|
||||
bool LoadScriptLibrary(const char* libName);
|
||||
void UnloadScriptLibrary();
|
||||
|
||||
CreatureAI* GetCreatureAI(Creature* pCreature);
|
||||
InstanceData* CreateInstanceData(Map* pMap);
|
||||
|
||||
bool OnGossipHello(Player* pPlayer, Creature* pCreature);
|
||||
bool OnGossipHello(Player* pPlayer, GameObject* pGameObject);
|
||||
bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code);
|
||||
bool OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code);
|
||||
bool OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
|
||||
bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
|
||||
bool OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest);
|
||||
bool OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
|
||||
bool OnQuestChooseReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest, uint32 opt);
|
||||
bool OnQuestChooseReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest, uint32 opt);
|
||||
uint32 OnDialogStatus(Player* pPlayer, Creature* pCreature);
|
||||
uint32 OnDialogStatus(Player* pPlayer, GameObject* pGameObject);
|
||||
bool OnGameObjectUse(Player* pPlayer, GameObject* pGameObject);
|
||||
bool OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
|
||||
bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry);
|
||||
bool OnProcessEvent(uint32 eventId, WorldObject* pSource, WorldObject* pTarget, bool isStart);
|
||||
bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget);
|
||||
bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, GameObject* pTarget);
|
||||
bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Item* pTarget);
|
||||
bool OnAuraDummy(Aura const* pAura, bool apply);
|
||||
|
||||
private:
|
||||
void LoadScripts(ScriptMapMap& scripts, const char* tablename);
|
||||
void CheckScriptTexts(ScriptMapMap const& scripts, std::set<int32>& ids);
|
||||
|
||||
template<class T>
|
||||
void GetScriptHookPtr(T& ptr, const char* name)
|
||||
{
|
||||
ptr = (T)MANGOS_GET_PROC_ADDR(m_hScriptLib, name);
|
||||
}
|
||||
|
||||
typedef std::vector<std::string> ScriptNameMap;
|
||||
typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
|
||||
typedef UNORDERED_MAP<uint32, uint32> EventIdScriptMap;
|
||||
|
||||
|
|
@ -327,6 +374,37 @@ private:
|
|||
EventIdScriptMap m_EventIdScripts;
|
||||
|
||||
ScriptNameMap m_scriptNames;
|
||||
MANGOS_LIBRARY_HANDLE m_hScriptLib;
|
||||
|
||||
void (MANGOS_IMPORT* m_pOnInitScriptLibrary)();
|
||||
void (MANGOS_IMPORT* m_pOnFreeScriptLibrary)();
|
||||
const char* (MANGOS_IMPORT* m_pGetScriptLibraryVersion)();
|
||||
|
||||
CreatureAI* (MANGOS_IMPORT* m_pGetCreatureAI) (Creature*);
|
||||
InstanceData* (MANGOS_IMPORT* m_pCreateInstanceData) (Map*);
|
||||
|
||||
bool (MANGOS_IMPORT* m_pOnGossipHello) (Player*, Creature*);
|
||||
bool (MANGOS_IMPORT* m_pOnGOGossipHello) (Player*, GameObject*);
|
||||
bool (MANGOS_IMPORT* m_pOnGossipSelect) (Player*, Creature*, uint32, uint32);
|
||||
bool (MANGOS_IMPORT* m_pOnGOGossipSelect) (Player*, GameObject*, uint32, uint32);
|
||||
bool (MANGOS_IMPORT* m_pOnGossipSelectWithCode) (Player*, Creature*, uint32, uint32, const char*);
|
||||
bool (MANGOS_IMPORT* m_pOnGOGossipSelectWithCode) (Player*, GameObject*, uint32, uint32, const char*);
|
||||
bool (MANGOS_IMPORT* m_pOnQuestAccept) (Player*, Creature*, Quest const*);
|
||||
bool (MANGOS_IMPORT* m_pOnGOQuestAccept) (Player*, GameObject*, Quest const*);
|
||||
bool (MANGOS_IMPORT* m_pOnItemQuestAccept) (Player*, Item*pItem, Quest const*);
|
||||
bool (MANGOS_IMPORT* m_pOnQuestComplete) (Player*, Creature* pCreature, Quest const*);
|
||||
bool (MANGOS_IMPORT* m_pOnQuestChooseReward) (Player*, Creature*, Quest const*, uint32);
|
||||
bool (MANGOS_IMPORT* m_pOnGOQuestChooseReward) (Player*, GameObject*, Quest const*, uint32);
|
||||
uint32 (MANGOS_IMPORT* m_pOnNPCDialogStatus) (Player*, Creature*);
|
||||
uint32 (MANGOS_IMPORT* m_pOnGODialogStatus) (Player*, GameObject*);
|
||||
bool (MANGOS_IMPORT* m_pOnGOUse) (Player*, GameObject*);
|
||||
bool (MANGOS_IMPORT* m_pOnItemUse) (Player*, Item*, SpellCastTargets const&);
|
||||
bool (MANGOS_IMPORT* m_pOnAreaTrigger) (Player*, AreaTriggerEntry const*);
|
||||
bool (MANGOS_IMPORT* m_pOnProcessEvent)(uint32, WorldObject*, WorldObject*, bool);
|
||||
bool (MANGOS_IMPORT* m_pOnEffectDummyCreature) (Unit*, uint32, SpellEffectIndex, Creature*);
|
||||
bool (MANGOS_IMPORT* m_pOnEffectDummyGO) (Unit*, uint32, SpellEffectIndex, GameObject*);
|
||||
bool (MANGOS_IMPORT* m_pOnEffectDummyItem) (Unit*, uint32, SpellEffectIndex, Item*);
|
||||
bool (MANGOS_IMPORT* m_pOnAuraDummy) (Aura const*, bool);
|
||||
};
|
||||
|
||||
#define sScriptMgr MaNGOS::Singleton<ScriptMgr>::Instance()
|
||||
|
|
@ -334,6 +412,5 @@ private:
|
|||
MANGOS_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 triggerId);
|
||||
MANGOS_DLL_SPEC uint32 GetEventIdScriptId(uint32 eventId);
|
||||
MANGOS_DLL_SPEC uint32 GetScriptId(const char *name);
|
||||
MANGOS_DLL_SPEC ScriptMgr::ScriptNameMap const& GetScriptNames();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue