From 86297882d537f3488dd3a9da5dd98812fd20e339 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 23 May 2016 03:51:44 +0300 Subject: [PATCH] Implement the custom event functions. --- source/Core.hpp | 5 +++++ source/CoreEvents.cpp | 6 ++++++ source/Misc.cpp | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/source/Core.hpp b/source/Core.hpp index 8fcaa3ef..851915b3 100644 --- a/source/Core.hpp +++ b/source/Core.hpp @@ -642,6 +642,11 @@ public: void ConnectPlayer(Int32 id, Int32 header, Object & payload); void DisconnectPlayer(Int32 id, Int32 header, Object & payload); + /* -------------------------------------------------------------------------------------------- + * Emit a custom event. + */ + void EmitCustomEvent(Int32 group, Int32 header, Object & payload); + /* -------------------------------------------------------------------------------------------- * Server events. */ diff --git a/source/CoreEvents.cpp b/source/CoreEvents.cpp index a82596f3..7456a5ce 100644 --- a/source/CoreEvents.cpp +++ b/source/CoreEvents.cpp @@ -11,6 +11,12 @@ namespace SqMod { // ------------------------------------------------------------------------------------------------ extern void ProcessRoutines(); +// ------------------------------------------------------------------------------------------------ +void Core::EmitCustomEvent(Int32 group, Int32 header, Object & payload) +{ + Emit(mOnCustomEvent, group, header, payload); +} + // ------------------------------------------------------------------------------------------------ void Core::EmitBlipCreated(Int32 blip, Int32 header, Object & payload) { diff --git a/source/Misc.cpp b/source/Misc.cpp index 011b628e..d6e0389b 100644 --- a/source/Misc.cpp +++ b/source/Misc.cpp @@ -60,6 +60,12 @@ static void BindEvent(Int32 id, Object & env, Function & func) Core::Get().BindEvent(id, env, func); } +// ------------------------------------------------------------------------------------------------ +static void CustomEvent(Int32 group, Int32 header, Object & payload) +{ + Core::Get().EmitCustomEvent(group, header, payload); +} + // ------------------------------------------------------------------------------------------------ static Int32 GetState() { @@ -118,6 +124,7 @@ void Register_Core(HSQUIRRELVM vm) RootTable(vm) .Bind(_SC("SqCore"), Table(vm) .Func(_SC("Bind"), &BindEvent) + .Func(_SC("CustomEvent"), &CustomEvent) .Func(_SC("Reload"), &SetReload) .Func(_SC("ReloadBecause"), &SetReloadBecause) .Func(_SC("Reloading"), &IsReloading)