Core/Hooks: Adds hooks for start and stop game events (#1472)
This commit is contained in:
committed by
Kargatum
parent
23d78ce6bc
commit
3a39aaeed5
@@ -18,6 +18,7 @@
|
|||||||
#include "UnitAI.h"
|
#include "UnitAI.h"
|
||||||
#include "GameObjectAI.h"
|
#include "GameObjectAI.h"
|
||||||
#include "Transport.h"
|
#include "Transport.h"
|
||||||
|
#include "ScriptMgr.h"
|
||||||
#ifdef ELUNA
|
#ifdef ELUNA
|
||||||
#include "LuaEngine.h"
|
#include "LuaEngine.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -127,10 +128,10 @@ bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite)
|
|||||||
if (data.end <= data.start)
|
if (data.end <= data.start)
|
||||||
data.end = data.start + data.length;
|
data.end = data.start + data.length;
|
||||||
}
|
}
|
||||||
#ifdef ELUNA
|
|
||||||
if (IsActiveEvent(event_id))
|
if (IsActiveEvent(event_id))
|
||||||
sEluna->OnGameEventStart(event_id);
|
sScriptMgr->OnGameEventStart(event_id);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -153,10 +154,10 @@ bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite)
|
|||||||
// or to scedule another update where the next event will be started
|
// or to scedule another update where the next event will be started
|
||||||
if (overwrite && conditions_met)
|
if (overwrite && conditions_met)
|
||||||
sWorld->ForceGameEventUpdate();
|
sWorld->ForceGameEventUpdate();
|
||||||
#ifdef ELUNA
|
|
||||||
if (IsActiveEvent(event_id))
|
if (IsActiveEvent(event_id))
|
||||||
sEluna->OnGameEventStart(event_id);
|
sScriptMgr->OnGameEventStart(event_id);
|
||||||
#endif
|
|
||||||
return conditions_met;
|
return conditions_met;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,10 +200,9 @@ void GameEventMgr::StopEvent(uint16 event_id, bool overwrite)
|
|||||||
CharacterDatabase.CommitTransaction(trans);
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ELUNA
|
|
||||||
if (!IsActiveEvent(event_id))
|
if (!IsActiveEvent(event_id))
|
||||||
sEluna->OnGameEventStop(event_id);
|
sScriptMgr->OnGameEventStop(event_id);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEventMgr::LoadFromDB()
|
void GameEventMgr::LoadFromDB()
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ template class ScriptRegistry<MovementHandlerScript>;
|
|||||||
template class ScriptRegistry<BGScript>;
|
template class ScriptRegistry<BGScript>;
|
||||||
template class ScriptRegistry<SpellSC>;
|
template class ScriptRegistry<SpellSC>;
|
||||||
template class ScriptRegistry<AccountScript>;
|
template class ScriptRegistry<AccountScript>;
|
||||||
|
template class ScriptRegistry<GameEventScript>;
|
||||||
|
|
||||||
#include "ScriptMgrMacros.h"
|
#include "ScriptMgrMacros.h"
|
||||||
|
|
||||||
@@ -213,6 +214,7 @@ void ScriptMgr::Unload()
|
|||||||
SCR_CLEAR(ModuleScript);
|
SCR_CLEAR(ModuleScript);
|
||||||
SCR_CLEAR(BGScript);
|
SCR_CLEAR(BGScript);
|
||||||
SCR_CLEAR(SpellSC);
|
SCR_CLEAR(SpellSC);
|
||||||
|
SCR_CLEAR(GameEventScript);
|
||||||
|
|
||||||
#undef SCR_CLEAR
|
#undef SCR_CLEAR
|
||||||
}
|
}
|
||||||
@@ -2058,6 +2060,22 @@ void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration)
|
|||||||
FOREACH_SCRIPT(SpellSC)->OnCalcMaxDuration(aura, maxDuration);
|
FOREACH_SCRIPT(SpellSC)->OnCalcMaxDuration(aura, maxDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGameEventStart(uint16 EventID)
|
||||||
|
{
|
||||||
|
#ifdef ELUNA
|
||||||
|
sEluna->OnGameEventStart(EventId);
|
||||||
|
#endif
|
||||||
|
FOREACH_SCRIPT(GameEventScript)->OnStart(EventID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGameEventStop(uint16 EventID)
|
||||||
|
{
|
||||||
|
#ifdef ELUNA
|
||||||
|
sEluna->OnGameEventStop(EventID);
|
||||||
|
#endif
|
||||||
|
FOREACH_SCRIPT(GameEventScript)->OnStop(EventID);
|
||||||
|
}
|
||||||
|
|
||||||
AllMapScript::AllMapScript(const char* name)
|
AllMapScript::AllMapScript(const char* name)
|
||||||
: ScriptObject(name)
|
: ScriptObject(name)
|
||||||
{
|
{
|
||||||
@@ -2257,3 +2275,9 @@ ModuleScript::ModuleScript(const char* name)
|
|||||||
ScriptRegistry<ModuleScript>::AddScript(this);
|
ScriptRegistry<ModuleScript>::AddScript(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameEventScript::GameEventScript(const char* name)
|
||||||
|
: ScriptObject(name)
|
||||||
|
{
|
||||||
|
ScriptRegistry<GameEventScript>::AddScript(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "AchievementMgr.h"
|
#include "AchievementMgr.h"
|
||||||
#include "DynamicObject.h"
|
#include "DynamicObject.h"
|
||||||
#include "ArenaTeam.h"
|
#include "ArenaTeam.h"
|
||||||
|
#include "GameEventMgr.h"
|
||||||
|
|
||||||
class AuctionHouseObject;
|
class AuctionHouseObject;
|
||||||
class AuraScript;
|
class AuraScript;
|
||||||
@@ -1135,6 +1136,19 @@ class ModuleScript : public ScriptObject
|
|||||||
ModuleScript(const char* name);
|
ModuleScript(const char* name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GameEventScript : public ScriptObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
GameEventScript(const char* name);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Runs on start event
|
||||||
|
virtual void OnStart(uint16 /*EventID*/) { }
|
||||||
|
|
||||||
|
// Runs on stop event
|
||||||
|
virtual void OnStop(uint16 /*EventID*/) { }
|
||||||
|
};
|
||||||
|
|
||||||
// Placed here due to ScriptRegistry::AddScript dependency.
|
// Placed here due to ScriptRegistry::AddScript dependency.
|
||||||
#define sScriptMgr ACE_Singleton<ScriptMgr, ACE_Null_Mutex>::instance()
|
#define sScriptMgr ACE_Singleton<ScriptMgr, ACE_Null_Mutex>::instance()
|
||||||
|
|
||||||
@@ -1471,6 +1485,11 @@ class ScriptMgr
|
|||||||
|
|
||||||
void OnCalcMaxDuration(Aura const* aura, int32& maxDuration);
|
void OnCalcMaxDuration(Aura const* aura, int32& maxDuration);
|
||||||
|
|
||||||
|
public: /* GameEventScript */
|
||||||
|
|
||||||
|
void OnGameEventStart(uint16 EventID);
|
||||||
|
void OnGameEventStop(uint16 EventID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
uint32 _scriptCount;
|
uint32 _scriptCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user