diff --git a/source/Config.hpp b/source/Config.hpp index 1c733f6a..64321cab 100644 --- a/source/Config.hpp +++ b/source/Config.hpp @@ -201,7 +201,6 @@ template < class T > class Ent; template < class T > class EntMan; template < class T > class Reference; - // ------------------------------------------------------------------------------------------------ class CBlip; class CCheckpoint; @@ -217,10 +216,17 @@ class CVehicle; // ------------------------------------------------------------------------------------------------ struct CAutomobile; struct CModel; +struct CPlayerImmunity; +struct CRadio; +struct CSkin; +struct CSound; +struct CVehicleImmunity; +struct CWastedSettings; +struct CWeapon; +struct CWorldBounds; // ------------------------------------------------------------------------------------------------ - } // Namespace:: SqMod /* ------------------------------------------------------------------------------------------------ @@ -298,8 +304,10 @@ struct CModel; #define _SCU32(v) static_cast(v) #define _SCI64(v) static_cast(v) #define _SCU64(v) static_cast(v) +#define _SCSQI(v) static_cast(v) #define _SCF32(v) static_cast(v) #define _SCF64(v) static_cast(v) +#define _SCSQF(v) static_cast(v) // Short notation for getting the minimum and maxmimum value of primitives #define _NLMIN(t) std::numeric_limits::min() diff --git a/source/Core.cpp b/source/Core.cpp index 06c89948..829df6dc 100644 --- a/source/Core.cpp +++ b/source/Core.cpp @@ -70,6 +70,7 @@ Core::Pointer Core::Inst() noexcept { return Pointer(new Core(), &Core::_Finalizer); } + return Pointer(nullptr, &Core::_Finalizer); } @@ -362,7 +363,11 @@ bool Core::CreateVM() noexcept void Core::DestroyVM() noexcept { - if (m_VM) sq_close(m_VM); + if (m_VM != nullptr) + { + sq_close(m_VM); + m_VM = nullptr; + } } // ------------------------------------------------------------------------------------------------ @@ -1427,7 +1432,7 @@ void Core::OnSphereExited(SQInt32 sphere, SQInt32 player) noexcept // ------------------------------------------------------------------------------------------------ void Core::OnServerFrame(SQFloat delta) noexcept { - + ServerFrame.Emit(std::forward< SQFloat >(delta)); } // ------------------------------------------------------------------------------------------------ diff --git a/source/Core.hpp b/source/Core.hpp index 26732152..3b97c575 100644 --- a/source/Core.hpp +++ b/source/Core.hpp @@ -613,6 +613,12 @@ public: // -------------------------------------------------------------------------------------------- EWorldOption WorldOption; EWorldToggle WorldToggle; + + // -------------------------------------------------------------------------------------------- + EScriptReload ScriptReload; + + // -------------------------------------------------------------------------------------------- + ELogMessage LogMessage; }; // ------------------------------------------------------------------------------------------------ diff --git a/source/Entity.hpp b/source/Entity.hpp index 06684306..2bd90007 100644 --- a/source/Entity.hpp +++ b/source/Entity.hpp @@ -1317,7 +1317,8 @@ public: /* -------------------------------------------------------------------------------------------- * Counts the number of persistent references for this entity - */ SQUint32 CountPersistentRefs() const noexcept + */ + SQUint32 CountPersistentRefs() const noexcept { SQUint32 refs = 0; // Make sure the reference is valid @@ -1379,9 +1380,8 @@ private: if (RefType::Verify(id)) { RefType * ref = 0, bkp = 0; - + // Get the pointer to the first backward reference ref = RefType::s_Instances[id].Root->m_Prev; - // Deactivate backward references while (ref) { @@ -1402,9 +1402,8 @@ private: bkp->RemoveFromChain(); } } - + // Get the pointer to the first forward reference ref = RefType::s_Instances[id].Root->m_Next; - // Deactivate forward references while (ref) { @@ -1459,10 +1458,12 @@ private: // See if there's any persistent references to activate if (RefType::s_Instances[id].Root) { + // @TODO Remove the reference from the chain, if somehow + // is present there without being persistent + // Resurect backward references for (RefType * ref = RefType::s_Instances[id].Root->m_Prev; ref; ref = ref->m_Prev) { - // Unnecessary check, but just to be sure if (ref->m_Persistent) { ref->m_ID = id; @@ -1471,7 +1472,6 @@ private: // Resurect forward references for (RefType * ref = RefType::s_Instances[id].Root->m_Next; ref; ref = ref->m_Next) { - // Unnecessary check, but just to be sure if (ref->m_Persistent) { ref->m_ID = id; diff --git a/source/Event/Basic.cpp b/source/Event/Basic.cpp new file mode 100644 index 00000000..46f56b93 --- /dev/null +++ b/source/Event/Basic.cpp @@ -0,0 +1,1920 @@ +#include "Event/Basic.hpp" +#include "Register.hpp" +#include "Entity.hpp" +#include "Core.hpp" + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +// ------------------------------------------------------------------------------------------------ +BasicEvent::BasicEvent() noexcept + : BasicEvent(EVT_UNKNOWN, false) +{ + +} + +// ------------------------------------------------------------------------------------------------ +BasicEvent::BasicEvent(SQInt32 type) noexcept + : BasicEvent(type, false) +{ + +} + +// ------------------------------------------------------------------------------------------------ +BasicEvent::BasicEvent(SQInt32 type, bool suspended) noexcept + : m_Type(static_cast(type)) + , m_Stride(0) + , m_Ignore(0) + , m_Primary(SQMOD_UNKNOWN) + , m_Secondary(SQMOD_UNKNOWN) + , m_Idle() + , m_OnTrigger() + , m_Tag() + , m_Data() + , m_Suspended(suspended) +{ + Attach(m_Type); +} + +// ------------------------------------------------------------------------------------------------ +BasicEvent::BasicEvent(const BasicEvent & o) noexcept + : m_Type(o.m_Type) + , m_Stride(o.m_Stride) + , m_Ignore(o.m_Ignore) + , m_Primary(o.m_Primary) + , m_Secondary(o.m_Secondary) + , m_Idle(o.m_Idle) + , m_OnTrigger(o.m_OnTrigger) + , m_Tag(o.m_Tag) + , m_Data(o.m_Data) + , m_Suspended(o.m_Suspended) +{ + Attach(m_Type); +} + +// ------------------------------------------------------------------------------------------------ +BasicEvent::BasicEvent(BasicEvent && o) noexcept + : m_Type(o.m_Type) + , m_Stride(o.m_Stride) + , m_Ignore(o.m_Ignore) + , m_Primary(o.m_Primary) + , m_Secondary(o.m_Secondary) + , m_Idle(o.m_Idle) + , m_OnTrigger(o.m_OnTrigger) + , m_Tag(o.m_Tag) + , m_Data(o.m_Data) + , m_Suspended(o.m_Suspended) +{ + Attach(m_Type); +} + +// ------------------------------------------------------------------------------------------------ +BasicEvent::~BasicEvent() +{ + Detach(m_Type); +} + +// ------------------------------------------------------------------------------------------------ +BasicEvent & BasicEvent::operator = (const BasicEvent & o) noexcept +{ + if (this != &o) + { + Detach(m_Type); + + m_Type = o.m_Type; + m_Stride = o.m_Stride; + m_Ignore = o.m_Ignore; + m_Primary = o.m_Primary; + m_Secondary = o.m_Secondary; + m_Idle = o.m_Idle; + m_OnTrigger = o.m_OnTrigger; + m_Tag = o.m_Tag; + m_Data = o.m_Data; + m_Suspended = o.m_Suspended; + + Attach(m_Type); + } + + return *this; +} + +// ------------------------------------------------------------------------------------------------ +BasicEvent & BasicEvent::operator = (BasicEvent && o) noexcept +{ + if (this != &o) + { + Detach(m_Type); + + m_Type = o.m_Type; + m_Stride = o.m_Stride; + m_Ignore = o.m_Ignore; + m_Primary = o.m_Primary; + m_Secondary = o.m_Secondary; + m_Idle = o.m_Idle; + m_OnTrigger = o.m_OnTrigger; + m_Tag = o.m_Tag; + m_Data = o.m_Data; + m_Suspended = o.m_Suspended; + + Attach(m_Type); + } + + return *this; +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::operator == (const BasicEvent & o) const noexcept +{ + return (m_Type == o.m_Type); +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::operator != (const BasicEvent & o) const noexcept +{ + return (m_Type != o.m_Type); +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::operator < (const BasicEvent & o) const noexcept +{ + return (m_Type < o.m_Type); +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::operator > (const BasicEvent & o) const noexcept +{ + return (m_Type > o.m_Type); +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::operator <= (const BasicEvent & o) const noexcept +{ + return (m_Type <= o.m_Type); +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::operator >= (const BasicEvent & o) const noexcept +{ + return (m_Type >= o.m_Type); +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 BasicEvent::Cmp(const BasicEvent & o) const noexcept +{ + return m_Type == o.m_Type ? 0 : (m_Type > o.m_Type ? 1 : -1); +} + +// ------------------------------------------------------------------------------------------------ +const SQChar * BasicEvent::GetName() const noexcept +{ + return GetEventName(m_Type); +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 BasicEvent::GetType() const noexcept +{ + return m_Type; +} + +// ------------------------------------------------------------------------------------------------ +const SQChar * BasicEvent::GetTag() const noexcept +{ + return m_Tag.c_str(); +} + +void BasicEvent::SetTag(const SQChar * tag) noexcept +{ + m_Tag = tag; +} + +// ------------------------------------------------------------------------------------------------ +SqObj & BasicEvent::GetData() noexcept +{ + return m_Data; +} + +void BasicEvent::SetData(SqObj & data) noexcept +{ + m_Data = data; +} + +// ------------------------------------------------------------------------------------------------ +SQInteger BasicEvent::GetIdle() const noexcept +{ + return _SCSQI(std::chrono::duration_cast(m_Idle - std::chrono::steady_clock::now()).count()); +} + +void BasicEvent::SetIdle(SQInteger millis) noexcept +{ + m_Idle = (std::chrono::steady_clock::now() + std::chrono::milliseconds(_SCI64(millis))); +} + +bool BasicEvent::IsIdle() const noexcept +{ + return (m_Idle > std::chrono::steady_clock::now()); +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 BasicEvent::GetStride() const noexcept +{ + return m_Stride; +} + +void BasicEvent::SetStride(SQInt32 stride) noexcept +{ + m_Stride = stride > 0 ? stride : 0; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 BasicEvent::GetIgnore() const noexcept +{ + return m_Ignore; +} + +void BasicEvent::SetIgnore(SQInt32 ignore) noexcept +{ + m_Ignore = ignore > 0 ? ignore : 0; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 BasicEvent::GetPrimary() const noexcept +{ + return m_Primary; +} + +void BasicEvent::SetPrimary(SQInt32 subset) noexcept +{ + m_Primary = subset; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 BasicEvent::GetSecondary() const noexcept +{ + return m_Secondary; +} + +void BasicEvent::SetSecondary(SQInt32 subset) noexcept +{ + m_Secondary = subset; +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::GetSuspended() const noexcept +{ + return m_Suspended; +} + +void BasicEvent::SetSuspended(bool toggle) noexcept +{ + m_Suspended = toggle; +} + +// ------------------------------------------------------------------------------------------------ +Function BasicEvent::GetOnTrigger() const noexcept +{ + return m_OnTrigger; +} + +void BasicEvent::SetOnTrigger(const Function & func) noexcept +{ + m_OnTrigger = func; +} +// ------------------------------------------------------------------------------------------------ +void BasicEvent::BlipCreated(SQInt32 blip, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(blip, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::CheckpointCreated(SQInt32 checkpoint, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(checkpoint, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::KeybindCreated(SQInt32 keybind, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(keybind, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ObjectCreated(SQInt32 object, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(object, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PickupCreated(SQInt32 pickup, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(pickup, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerCreated(SQInt32 player, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(player, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SphereCreated(SQInt32 sphere, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(sphere, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SpriteCreated(SQInt32 sprite, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(sprite, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::TextdrawCreated(SQInt32 textdraw, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(textdraw, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleCreated(SQInt32 vehicle, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(vehicle, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::BlipDestroyed(SQInt32 blip, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(blip, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::CheckpointDestroyed(SQInt32 checkpoint, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(checkpoint, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::KeybindDestroyed(SQInt32 keybind, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(keybind, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ObjectDestroyed(SQInt32 object, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(object, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PickupDestroyed(SQInt32 pickup, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(pickup, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerDestroyed(SQInt32 player, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(player, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SphereDestroyed(SQInt32 sphere, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(sphere, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SpriteDestroyed(SQInt32 sprite, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(sprite, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::TextdrawDestroyed(SQInt32 textdraw, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(textdraw, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleDestroyed(SQInt32 vehicle, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(vehicle, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::BlipCustom(SQInt32 blip, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(blip, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::CheckpointCustom(SQInt32 checkpoint, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(checkpoint, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::KeybindCustom(SQInt32 keybind, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(keybind, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ObjectCustom(SQInt32 object, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(object, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PickupCustom(SQInt32 pickup, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(pickup, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerCustom(SQInt32 player, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(player, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SphereCustom(SQInt32 sphere, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(sphere, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SpriteCustom(SQInt32 sprite, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(sprite, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::TextdrawCustom(SQInt32 textdraw, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(textdraw, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleCustom(SQInt32 vehicle, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(vehicle, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerAway(SQInt32 player, bool status) noexcept +{ + if (Trigger() && (m_Primary < 0 || status == m_Primary) && (m_Secondary < 0 || status == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, bool >(player, status); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerGameKeys(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || current == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerRename(SQInt32 player, const SQChar * previous, const SQChar * current) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, const SQChar *, const SQChar * >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerRequestClass(SQInt32 player, SQInt32 offset) noexcept +{ + if (Trigger() && (m_Primary < 0 || offset == m_Primary) && (m_Secondary < 0 || offset == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, offset); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerRequestSpawn(SQInt32 player) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32 >(player); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerSpawn(SQInt32 player) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32 >(player); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerStartTyping(SQInt32 player) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32 >(player); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerStopTyping(SQInt32 player) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32 >(player); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerChat(SQInt32 player, const SQChar * message) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, const SQChar * >(player, message); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerCommand(SQInt32 player, const SQChar * command) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, const SQChar * >(player, command); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerMessage(SQInt32 player, SQInt32 receiver, const SQChar * message) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32, const SQChar * >(player, receiver, message); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerHealth(SQInt32 player, SQFloat previous, SQFloat current) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQFloat, SQFloat >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerArmour(SQInt32 player, SQFloat previous, SQFloat current) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQFloat, SQFloat >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerWeapon(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || current == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerMove(SQInt32 player, const Vector3 & previous, const Vector3 & current) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, const Vector3 &, const Vector3 & >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerWasted(SQInt32 player, SQInt32 reason) noexcept +{ + if (Trigger() && (m_Primary < 0 || reason == m_Primary) && (m_Secondary < 0 || reason == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, reason); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerKilled(SQInt32 player, SQInt32 killer, SQInt32 reason, SQInt32 body_part) noexcept +{ + if (Trigger() && (m_Primary < 0 || reason == m_Primary) && (m_Secondary < 0 || body_part == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, reason, body_part); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerTeamKill(SQInt32 player, SQInt32 killer, SQInt32 reason, SQInt32 body_part) noexcept +{ + if (Trigger() && (m_Primary < 0 || reason == m_Primary) && (m_Secondary < 0 || body_part == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, reason, body_part); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerSpectate(SQInt32 player, SQInt32 target) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, target); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerCrashreport(SQInt32 player, const SQChar * report) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, const SQChar * >(player, report); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerBurning(SQInt32 player, bool state) noexcept +{ + if (Trigger() && (m_Primary < 0 || state == m_Primary) && (m_Secondary < 0 || state == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, bool >(player, state); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerCrouching(SQInt32 player, bool state) noexcept +{ + if (Trigger() && (m_Primary < 0 || state == m_Primary) && (m_Secondary < 0 || state == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, bool >(player, state); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerState(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || current == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PlayerAction(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || current == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateNone(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateNormal(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateShooting(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateDriver(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StatePassenger(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateEnterDriver(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateEnterPassenger(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateExitVehicle(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::StateUnspawned(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionNone(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionNormal(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionAiming(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionShooting(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionJumping(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionLieDown(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionGettingUp(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionJumpVehicle(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionDriving(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionDying(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionWasted(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionEmbarking(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ActionDisembarking(SQInt32 player, SQInt32 previous) noexcept +{ + if (Trigger() && (m_Primary < 0 || previous == m_Primary) && (m_Secondary < 0 || previous == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, previous); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleRespawn(SQInt32 vehicle) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32 >(vehicle); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleExplode(SQInt32 vehicle) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32 >(vehicle); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleHealth(SQInt32 vehicle, SQFloat previous, SQFloat current) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQFloat, SQFloat >(vehicle, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleMove(SQInt32 vehicle, const Vector3 & previous, const Vector3 ¤t) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, const Vector3 &, const Vector3 & >(vehicle, previous, current); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PickupRespawn(SQInt32 pickup) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32 >(pickup); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::KeybindKeyPress(SQInt32 player, SQInt32 keybind) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, keybind); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::KeybindKeyRelease(SQInt32 player, SQInt32 keybind) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, keybind); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleEmbarking(SQInt32 player, SQInt32 vehicle, SQInt32 slot) noexcept +{ + if (Trigger() && (m_Primary < 0 || slot == m_Primary) && (m_Secondary < 0 || slot == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, vehicle, slot); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleEmbarked(SQInt32 player, SQInt32 vehicle, SQInt32 slot) noexcept +{ + if (Trigger() && (m_Primary < 0 || slot == m_Primary) && (m_Secondary < 0 || slot == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, vehicle, slot); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::VehicleDisembark(SQInt32 player, SQInt32 vehicle) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, vehicle); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PickupClaimed(SQInt32 player, SQInt32 pickup) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, pickup); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::PickupCollected(SQInt32 player, SQInt32 pickup) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, pickup); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ObjectShot(SQInt32 player, SQInt32 object, SQInt32 weapon) noexcept +{ + if (Trigger() && (m_Primary < 0 || weapon == m_Primary) && (m_Secondary < 0 || weapon == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, SQInt32 >(player, object, weapon); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ObjectBump(SQInt32 player, SQInt32 object) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, object); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::CheckpointEntered(SQInt32 player, SQInt32 checkpoint) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, checkpoint); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::CheckpointExited(SQInt32 player, SQInt32 checkpoint) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, checkpoint); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SphereEntered(SQInt32 player, SQInt32 sphere) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, sphere); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::SphereExited(SQInt32 player, SQInt32 sphere) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQInt32, SQInt32 >(player, sphere); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ServerFrame(SQFloat delta) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< SQFloat >(delta); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ServerStartup() noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute(); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ServerShutdown() noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute(); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::InternalCommand(SQInt32 type, const SQChar * text) noexcept +{ + if (Trigger() && (m_Primary < 0 || type == m_Primary) && (m_Secondary < 0 || type == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, const SQChar * >(type, text); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::LoginAttempt(const SQChar * name, const SQChar * pass, const SQChar * addr) noexcept +{ + if (Trigger()) + { + m_OnTrigger.Execute< const SQChar *, const SQChar *, const SQChar * >(name, pass, addr); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::CustomEvent(SQInt32 group, SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || group == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, SQInt32, Object & >(group, header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::WorldOption(SQInt32 option, Object & value) noexcept +{ + if (Trigger() && (m_Primary < 0 || option == m_Primary) && (m_Secondary < 0 || option == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, Object & >(option, value); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::WorldToggle(SQInt32 option, bool value) noexcept +{ + if (Trigger() && (m_Primary < 0 || option == m_Primary) && (m_Secondary < 0 || value == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, bool >(option, value); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::ScriptReload(SQInt32 header, Object & payload) noexcept +{ + if (Trigger() && (m_Primary < 0 || header == m_Primary) && (m_Secondary < 0 || header == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, Object & >(header, payload); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::LogMessage(SQInt32 type, const SQChar * message) noexcept +{ + if (Trigger() && (m_Primary < 0 || type == m_Primary) && (m_Secondary < 0 || type == m_Secondary)) + { + m_OnTrigger.Execute< SQInt32, const SQChar * >(type, message); + } +} + +// ------------------------------------------------------------------------------------------------ +bool BasicEvent::Trigger() noexcept +{ + if (m_Suspended || (m_Idle > std::chrono::steady_clock::now())) + { + return false; + } + else if (m_Ignore > 0) + { + --m_Ignore; + return false; + } + else if (m_OnTrigger.IsNull()) + { + return false; + } + + if (m_Stride > 0 && m_Ignore < 1) + { + m_Ignore = m_Stride; + } + + return true; +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::Attach(EventType evt) noexcept +{ + switch (evt) + { + case EVT_BLIPCREATED: + _Core->BlipCreated.Connect< BasicEvent, &BasicEvent::BlipCreated >(this); + break; + case EVT_CHECKPOINTCREATED: + _Core->CheckpointCreated.Connect< BasicEvent, &BasicEvent::CheckpointCreated >(this); + break; + case EVT_KEYBINDCREATED: + _Core->KeybindCreated.Connect< BasicEvent, &BasicEvent::KeybindCreated >(this); + break; + case EVT_OBJECTCREATED: + _Core->ObjectCreated.Connect< BasicEvent, &BasicEvent::ObjectCreated >(this); + break; + case EVT_PICKUPCREATED: + _Core->PickupCreated.Connect< BasicEvent, &BasicEvent::PickupCreated >(this); + break; + case EVT_PLAYERCREATED: + _Core->PlayerCreated.Connect< BasicEvent, &BasicEvent::PlayerCreated >(this); + break; + case EVT_SPHERECREATED: + _Core->SphereCreated.Connect< BasicEvent, &BasicEvent::SphereCreated >(this); + break; + case EVT_SPRITECREATED: + _Core->SpriteCreated.Connect< BasicEvent, &BasicEvent::SpriteCreated >(this); + break; + case EVT_TEXTDRAWCREATED: + _Core->TextdrawCreated.Connect< BasicEvent, &BasicEvent::TextdrawCreated >(this); + break; + case EVT_VEHICLECREATED: + _Core->VehicleCreated.Connect< BasicEvent, &BasicEvent::VehicleCreated >(this); + break; + case EVT_BLIPDESTROYED: + _Core->BlipDestroyed.Connect< BasicEvent, &BasicEvent::BlipDestroyed >(this); + break; + case EVT_CHECKPOINTDESTROYED: + _Core->CheckpointDestroyed.Connect< BasicEvent, &BasicEvent::CheckpointDestroyed >(this); + break; + case EVT_KEYBINDDESTROYED: + _Core->KeybindDestroyed.Connect< BasicEvent, &BasicEvent::KeybindDestroyed >(this); + break; + case EVT_OBJECTDESTROYED: + _Core->ObjectDestroyed.Connect< BasicEvent, &BasicEvent::ObjectDestroyed >(this); + break; + case EVT_PICKUPDESTROYED: + _Core->PickupDestroyed.Connect< BasicEvent, &BasicEvent::PickupDestroyed >(this); + break; + case EVT_PLAYERDESTROYED: + _Core->PlayerDestroyed.Connect< BasicEvent, &BasicEvent::PlayerDestroyed >(this); + break; + case EVT_SPHEREDESTROYED: + _Core->SphereDestroyed.Connect< BasicEvent, &BasicEvent::SphereDestroyed >(this); + break; + case EVT_SPRITEDESTROYED: + _Core->SpriteDestroyed.Connect< BasicEvent, &BasicEvent::SpriteDestroyed >(this); + break; + case EVT_TEXTDRAWDESTROYED: + _Core->TextdrawDestroyed.Connect< BasicEvent, &BasicEvent::TextdrawDestroyed >(this); + break; + case EVT_VEHICLEDESTROYED: + _Core->VehicleDestroyed.Connect< BasicEvent, &BasicEvent::VehicleDestroyed >(this); + break; + case EVT_BLIPCUSTOM: + _Core->BlipCustom.Connect< BasicEvent, &BasicEvent::BlipCustom >(this); + break; + case EVT_CHECKPOINTCUSTOM: + _Core->CheckpointCustom.Connect< BasicEvent, &BasicEvent::CheckpointCustom >(this); + break; + case EVT_KEYBINDCUSTOM: + _Core->KeybindCustom.Connect< BasicEvent, &BasicEvent::KeybindCustom >(this); + break; + case EVT_OBJECTCUSTOM: + _Core->ObjectCustom.Connect< BasicEvent, &BasicEvent::ObjectCustom >(this); + break; + case EVT_PICKUPCUSTOM: + _Core->PickupCustom.Connect< BasicEvent, &BasicEvent::PickupCustom >(this); + break; + case EVT_PLAYERCUSTOM: + _Core->PlayerCustom.Connect< BasicEvent, &BasicEvent::PlayerCustom >(this); + break; + case EVT_SPHERECUSTOM: + _Core->SphereCustom.Connect< BasicEvent, &BasicEvent::SphereCustom >(this); + break; + case EVT_SPRITECUSTOM: + _Core->SpriteCustom.Connect< BasicEvent, &BasicEvent::SpriteCustom >(this); + break; + case EVT_TEXTDRAWCUSTOM: + _Core->TextdrawCustom.Connect< BasicEvent, &BasicEvent::TextdrawCustom >(this); + break; + case EVT_VEHICLECUSTOM: + _Core->VehicleCustom.Connect< BasicEvent, &BasicEvent::VehicleCustom >(this); + break; + case EVT_PLAYERAWAY: + _Core->PlayerAway.Connect< BasicEvent, &BasicEvent::PlayerAway >(this); + break; + case EVT_PLAYERGAMEKEYS: + _Core->PlayerGameKeys.Connect< BasicEvent, &BasicEvent::PlayerGameKeys >(this); + break; + case EVT_PLAYERRENAME: + _Core->PlayerRename.Connect< BasicEvent, &BasicEvent::PlayerRename >(this); + break; + case EVT_PLAYERREQUESTCLASS: + _Core->PlayerRequestClass.Connect< BasicEvent, &BasicEvent::PlayerRequestClass >(this); + break; + case EVT_PLAYERREQUESTSPAWN: + _Core->PlayerRequestSpawn.Connect< BasicEvent, &BasicEvent::PlayerRequestSpawn >(this); + break; + case EVT_PLAYERSPAWN: + _Core->PlayerSpawn.Connect< BasicEvent, &BasicEvent::PlayerSpawn >(this); + break; + case EVT_PLAYERSTARTTYPING: + _Core->PlayerStartTyping.Connect< BasicEvent, &BasicEvent::PlayerStartTyping >(this); + break; + case EVT_PLAYERSTOPTYPING: + _Core->PlayerStopTyping.Connect< BasicEvent, &BasicEvent::PlayerStopTyping >(this); + break; + case EVT_PLAYERCHAT: + _Core->PlayerChat.Connect< BasicEvent, &BasicEvent::PlayerChat >(this); + break; + case EVT_PLAYERCOMMAND: + _Core->PlayerCommand.Connect< BasicEvent, &BasicEvent::PlayerCommand >(this); + break; + case EVT_PLAYERMESSAGE: + _Core->PlayerMessage.Connect< BasicEvent, &BasicEvent::PlayerMessage >(this); + break; + case EVT_PLAYERHEALTH: + _Core->PlayerHealth.Connect< BasicEvent, &BasicEvent::PlayerHealth >(this); + break; + case EVT_PLAYERARMOUR: + _Core->PlayerArmour.Connect< BasicEvent, &BasicEvent::PlayerArmour >(this); + break; + case EVT_PLAYERWEAPON: + _Core->PlayerWeapon.Connect< BasicEvent, &BasicEvent::PlayerWeapon >(this); + break; + case EVT_PLAYERMOVE: + _Core->PlayerMove.Connect< BasicEvent, &BasicEvent::PlayerMove >(this); + break; + case EVT_PLAYERWASTED: + _Core->PlayerWasted.Connect< BasicEvent, &BasicEvent::PlayerWasted >(this); + break; + case EVT_PLAYERKILLED: + _Core->PlayerKilled.Connect< BasicEvent, &BasicEvent::PlayerKilled >(this); + break; + case EVT_PLAYERTEAMKILL: + _Core->PlayerTeamKill.Connect< BasicEvent, &BasicEvent::PlayerTeamKill >(this); + break; + case EVT_PLAYERSPECTATE: + _Core->PlayerSpectate.Connect< BasicEvent, &BasicEvent::PlayerSpectate >(this); + break; + case EVT_PLAYERCRASHREPORT: + _Core->PlayerCrashreport.Connect< BasicEvent, &BasicEvent::PlayerCrashreport >(this); + break; + case EVT_PLAYERBURNING: + _Core->PlayerBurning.Connect< BasicEvent, &BasicEvent::PlayerBurning >(this); + break; + case EVT_PLAYERCROUCHING: + _Core->PlayerCrouching.Connect< BasicEvent, &BasicEvent::PlayerCrouching >(this); + break; + case EVT_PLAYERSTATE: + _Core->PlayerState.Connect< BasicEvent, &BasicEvent::PlayerState >(this); + break; + case EVT_PLAYERACTION: + _Core->PlayerAction.Connect< BasicEvent, &BasicEvent::PlayerAction >(this); + break; + case EVT_STATENONE: + _Core->StateNone.Connect< BasicEvent, &BasicEvent::StateNone >(this); + break; + case EVT_STATENORMAL: + _Core->StateNormal.Connect< BasicEvent, &BasicEvent::StateNormal >(this); + break; + case EVT_STATESHOOTING: + _Core->StateShooting.Connect< BasicEvent, &BasicEvent::StateShooting >(this); + break; + case EVT_STATEDRIVER: + _Core->StateDriver.Connect< BasicEvent, &BasicEvent::StateDriver >(this); + break; + case EVT_STATEPASSENGER: + _Core->StatePassenger.Connect< BasicEvent, &BasicEvent::StatePassenger >(this); + break; + case EVT_STATEENTERDRIVER: + _Core->StateEnterDriver.Connect< BasicEvent, &BasicEvent::StateEnterDriver >(this); + break; + case EVT_STATEENTERPASSENGER: + _Core->StateEnterPassenger.Connect< BasicEvent, &BasicEvent::StateEnterPassenger >(this); + break; + case EVT_STATEEXITVEHICLE: + _Core->StateExitVehicle.Connect< BasicEvent, &BasicEvent::StateExitVehicle >(this); + break; + case EVT_STATEUNSPAWNED: + _Core->StateUnspawned.Connect< BasicEvent, &BasicEvent::StateUnspawned >(this); + break; + case EVT_ACTIONNONE: + _Core->ActionNone.Connect< BasicEvent, &BasicEvent::ActionNone >(this); + break; + case EVT_ACTIONNORMAL: + _Core->ActionNormal.Connect< BasicEvent, &BasicEvent::ActionNormal >(this); + break; + case EVT_ACTIONAIMING: + _Core->ActionAiming.Connect< BasicEvent, &BasicEvent::ActionAiming >(this); + break; + case EVT_ACTIONSHOOTING: + _Core->ActionShooting.Connect< BasicEvent, &BasicEvent::ActionShooting >(this); + break; + case EVT_ACTIONJUMPING: + _Core->ActionJumping.Connect< BasicEvent, &BasicEvent::ActionJumping >(this); + break; + case EVT_ACTIONLIEDOWN: + _Core->ActionLieDown.Connect< BasicEvent, &BasicEvent::ActionLieDown >(this); + break; + case EVT_ACTIONGETTINGUP: + _Core->ActionGettingUp.Connect< BasicEvent, &BasicEvent::ActionGettingUp >(this); + break; + case EVT_ACTIONJUMPVEHICLE: + _Core->ActionJumpVehicle.Connect< BasicEvent, &BasicEvent::ActionJumpVehicle >(this); + break; + case EVT_ACTIONDRIVING: + _Core->ActionDriving.Connect< BasicEvent, &BasicEvent::ActionDriving >(this); + break; + case EVT_ACTIONDYING: + _Core->ActionDying.Connect< BasicEvent, &BasicEvent::ActionDying >(this); + break; + case EVT_ACTIONWASTED: + _Core->ActionWasted.Connect< BasicEvent, &BasicEvent::ActionWasted >(this); + break; + case EVT_ACTIONEMBARKING: + _Core->ActionEmbarking.Connect< BasicEvent, &BasicEvent::ActionEmbarking >(this); + break; + case EVT_ACTIONDISEMBARKING: + _Core->ActionDisembarking.Connect< BasicEvent, &BasicEvent::ActionDisembarking >(this); + break; + case EVT_VEHICLERESPAWN: + _Core->VehicleRespawn.Connect< BasicEvent, &BasicEvent::VehicleRespawn >(this); + break; + case EVT_VEHICLEEXPLODE: + _Core->VehicleExplode.Connect< BasicEvent, &BasicEvent::VehicleExplode >(this); + break; + case EVT_VEHICLEHEALTH: + _Core->VehicleHealth.Connect< BasicEvent, &BasicEvent::VehicleHealth >(this); + break; + case EVT_VEHICLEMOVE: + _Core->VehicleMove.Connect< BasicEvent, &BasicEvent::VehicleMove >(this); + break; + case EVT_PICKUPRESPAWN: + _Core->PickupRespawn.Connect< BasicEvent, &BasicEvent::PickupRespawn >(this); + break; + case EVT_KEYBINDKEYPRESS: + _Core->KeybindKeyPress.Connect< BasicEvent, &BasicEvent::KeybindKeyPress >(this); + break; + case EVT_KEYBINDKEYRELEASE: + _Core->KeybindKeyRelease.Connect< BasicEvent, &BasicEvent::KeybindKeyRelease >(this); + break; + case EVT_VEHICLEEMBARKING: + _Core->VehicleEmbarking.Connect< BasicEvent, &BasicEvent::VehicleEmbarking >(this); + break; + case EVT_VEHICLEEMBARKED: + _Core->VehicleEmbarked.Connect< BasicEvent, &BasicEvent::VehicleEmbarked >(this); + break; + case EVT_VEHICLEDISEMBARK: + _Core->VehicleDisembark.Connect< BasicEvent, &BasicEvent::VehicleDisembark >(this); + break; + case EVT_PICKUPCLAIMED: + _Core->PickupClaimed.Connect< BasicEvent, &BasicEvent::PickupClaimed >(this); + break; + case EVT_PICKUPCOLLECTED: + _Core->PickupCollected.Connect< BasicEvent, &BasicEvent::PickupCollected >(this); + break; + case EVT_OBJECTSHOT: + _Core->ObjectShot.Connect< BasicEvent, &BasicEvent::ObjectShot >(this); + break; + case EVT_OBJECTBUMP: + _Core->ObjectBump.Connect< BasicEvent, &BasicEvent::ObjectBump >(this); + break; + case EVT_CHECKPOINTENTERED: + _Core->CheckpointEntered.Connect< BasicEvent, &BasicEvent::CheckpointEntered >(this); + break; + case EVT_CHECKPOINTEXITED: + _Core->CheckpointExited.Connect< BasicEvent, &BasicEvent::CheckpointExited >(this); + break; + case EVT_SPHEREENTERED: + _Core->SphereEntered.Connect< BasicEvent, &BasicEvent::SphereEntered >(this); + break; + case EVT_SPHEREEXITED: + _Core->SphereExited.Connect< BasicEvent, &BasicEvent::SphereExited >(this); + break; + case EVT_SERVERFRAME: + _Core->ServerFrame.Connect< BasicEvent, &BasicEvent::ServerFrame >(this); + break; + case EVT_SERVERSTARTUP: + _Core->ServerStartup.Connect< BasicEvent, &BasicEvent::ServerStartup >(this); + break; + case EVT_SERVERSHUTDOWN: + _Core->ServerShutdown.Connect< BasicEvent, &BasicEvent::ServerShutdown >(this); + break; + case EVT_INTERNALCOMMAND: + _Core->InternalCommand.Connect< BasicEvent, &BasicEvent::InternalCommand >(this); + break; + case EVT_LOGINATTEMPT: + _Core->LoginAttempt.Connect< BasicEvent, &BasicEvent::LoginAttempt >(this); + break; + case EVT_CUSTOMEVENT: + _Core->CustomEvent.Connect< BasicEvent, &BasicEvent::CustomEvent >(this); + break; + case EVT_WORLDOPTION: + _Core->WorldOption.Connect< BasicEvent, &BasicEvent::WorldOption >(this); + break; + case EVT_WORLDTOGGLE: + _Core->WorldToggle.Connect< BasicEvent, &BasicEvent::WorldToggle >(this); + break; + case EVT_SCRIPTRELOAD: + _Core->ScriptReload.Connect< BasicEvent, &BasicEvent::ScriptReload >(this); + break; + case EVT_LOGMESSAGE: + _Core->LogMessage.Connect< BasicEvent, &BasicEvent::LogMessage >(this); + break; + default: + LogErr("Attempting to to an unknown event type: %d", _SCI32(evt)); + } +} + +// ------------------------------------------------------------------------------------------------ +void BasicEvent::Detach(EventType evt) noexcept +{ + switch (evt) + { + case EVT_BLIPCREATED: + _Core->BlipCreated.Disconnect< BasicEvent, &BasicEvent::BlipCreated >(this); + break; + case EVT_CHECKPOINTCREATED: + _Core->CheckpointCreated.Disconnect< BasicEvent, &BasicEvent::CheckpointCreated >(this); + break; + case EVT_KEYBINDCREATED: + _Core->KeybindCreated.Disconnect< BasicEvent, &BasicEvent::KeybindCreated >(this); + break; + case EVT_OBJECTCREATED: + _Core->ObjectCreated.Disconnect< BasicEvent, &BasicEvent::ObjectCreated >(this); + break; + case EVT_PICKUPCREATED: + _Core->PickupCreated.Disconnect< BasicEvent, &BasicEvent::PickupCreated >(this); + break; + case EVT_PLAYERCREATED: + _Core->PlayerCreated.Disconnect< BasicEvent, &BasicEvent::PlayerCreated >(this); + break; + case EVT_SPHERECREATED: + _Core->SphereCreated.Disconnect< BasicEvent, &BasicEvent::SphereCreated >(this); + break; + case EVT_SPRITECREATED: + _Core->SpriteCreated.Disconnect< BasicEvent, &BasicEvent::SpriteCreated >(this); + break; + case EVT_TEXTDRAWCREATED: + _Core->TextdrawCreated.Disconnect< BasicEvent, &BasicEvent::TextdrawCreated >(this); + break; + case EVT_VEHICLECREATED: + _Core->VehicleCreated.Disconnect< BasicEvent, &BasicEvent::VehicleCreated >(this); + break; + case EVT_BLIPDESTROYED: + _Core->BlipDestroyed.Disconnect< BasicEvent, &BasicEvent::BlipDestroyed >(this); + break; + case EVT_CHECKPOINTDESTROYED: + _Core->CheckpointDestroyed.Disconnect< BasicEvent, &BasicEvent::CheckpointDestroyed >(this); + break; + case EVT_KEYBINDDESTROYED: + _Core->KeybindDestroyed.Disconnect< BasicEvent, &BasicEvent::KeybindDestroyed >(this); + break; + case EVT_OBJECTDESTROYED: + _Core->ObjectDestroyed.Disconnect< BasicEvent, &BasicEvent::ObjectDestroyed >(this); + break; + case EVT_PICKUPDESTROYED: + _Core->PickupDestroyed.Disconnect< BasicEvent, &BasicEvent::PickupDestroyed >(this); + break; + case EVT_PLAYERDESTROYED: + _Core->PlayerDestroyed.Disconnect< BasicEvent, &BasicEvent::PlayerDestroyed >(this); + break; + case EVT_SPHEREDESTROYED: + _Core->SphereDestroyed.Disconnect< BasicEvent, &BasicEvent::SphereDestroyed >(this); + break; + case EVT_SPRITEDESTROYED: + _Core->SpriteDestroyed.Disconnect< BasicEvent, &BasicEvent::SpriteDestroyed >(this); + break; + case EVT_TEXTDRAWDESTROYED: + _Core->TextdrawDestroyed.Disconnect< BasicEvent, &BasicEvent::TextdrawDestroyed >(this); + break; + case EVT_VEHICLEDESTROYED: + _Core->VehicleDestroyed.Disconnect< BasicEvent, &BasicEvent::VehicleDestroyed >(this); + break; + case EVT_BLIPCUSTOM: + _Core->BlipCustom.Disconnect< BasicEvent, &BasicEvent::BlipCustom >(this); + break; + case EVT_CHECKPOINTCUSTOM: + _Core->CheckpointCustom.Disconnect< BasicEvent, &BasicEvent::CheckpointCustom >(this); + break; + case EVT_KEYBINDCUSTOM: + _Core->KeybindCustom.Disconnect< BasicEvent, &BasicEvent::KeybindCustom >(this); + break; + case EVT_OBJECTCUSTOM: + _Core->ObjectCustom.Disconnect< BasicEvent, &BasicEvent::ObjectCustom >(this); + break; + case EVT_PICKUPCUSTOM: + _Core->PickupCustom.Disconnect< BasicEvent, &BasicEvent::PickupCustom >(this); + break; + case EVT_PLAYERCUSTOM: + _Core->PlayerCustom.Disconnect< BasicEvent, &BasicEvent::PlayerCustom >(this); + break; + case EVT_SPHERECUSTOM: + _Core->SphereCustom.Disconnect< BasicEvent, &BasicEvent::SphereCustom >(this); + break; + case EVT_SPRITECUSTOM: + _Core->SpriteCustom.Disconnect< BasicEvent, &BasicEvent::SpriteCustom >(this); + break; + case EVT_TEXTDRAWCUSTOM: + _Core->TextdrawCustom.Disconnect< BasicEvent, &BasicEvent::TextdrawCustom >(this); + break; + case EVT_VEHICLECUSTOM: + _Core->VehicleCustom.Disconnect< BasicEvent, &BasicEvent::VehicleCustom >(this); + break; + case EVT_PLAYERAWAY: + _Core->PlayerAway.Disconnect< BasicEvent, &BasicEvent::PlayerAway >(this); + break; + case EVT_PLAYERGAMEKEYS: + _Core->PlayerGameKeys.Disconnect< BasicEvent, &BasicEvent::PlayerGameKeys >(this); + break; + case EVT_PLAYERRENAME: + _Core->PlayerRename.Disconnect< BasicEvent, &BasicEvent::PlayerRename >(this); + break; + case EVT_PLAYERREQUESTCLASS: + _Core->PlayerRequestClass.Disconnect< BasicEvent, &BasicEvent::PlayerRequestClass >(this); + break; + case EVT_PLAYERREQUESTSPAWN: + _Core->PlayerRequestSpawn.Disconnect< BasicEvent, &BasicEvent::PlayerRequestSpawn >(this); + break; + case EVT_PLAYERSPAWN: + _Core->PlayerSpawn.Disconnect< BasicEvent, &BasicEvent::PlayerSpawn >(this); + break; + case EVT_PLAYERSTARTTYPING: + _Core->PlayerStartTyping.Disconnect< BasicEvent, &BasicEvent::PlayerStartTyping >(this); + break; + case EVT_PLAYERSTOPTYPING: + _Core->PlayerStopTyping.Disconnect< BasicEvent, &BasicEvent::PlayerStopTyping >(this); + break; + case EVT_PLAYERCHAT: + _Core->PlayerChat.Disconnect< BasicEvent, &BasicEvent::PlayerChat >(this); + break; + case EVT_PLAYERCOMMAND: + _Core->PlayerCommand.Disconnect< BasicEvent, &BasicEvent::PlayerCommand >(this); + break; + case EVT_PLAYERMESSAGE: + _Core->PlayerMessage.Disconnect< BasicEvent, &BasicEvent::PlayerMessage >(this); + break; + case EVT_PLAYERHEALTH: + _Core->PlayerHealth.Disconnect< BasicEvent, &BasicEvent::PlayerHealth >(this); + break; + case EVT_PLAYERARMOUR: + _Core->PlayerArmour.Disconnect< BasicEvent, &BasicEvent::PlayerArmour >(this); + break; + case EVT_PLAYERWEAPON: + _Core->PlayerWeapon.Disconnect< BasicEvent, &BasicEvent::PlayerWeapon >(this); + break; + case EVT_PLAYERMOVE: + _Core->PlayerMove.Disconnect< BasicEvent, &BasicEvent::PlayerMove >(this); + break; + case EVT_PLAYERWASTED: + _Core->PlayerWasted.Disconnect< BasicEvent, &BasicEvent::PlayerWasted >(this); + break; + case EVT_PLAYERKILLED: + _Core->PlayerKilled.Disconnect< BasicEvent, &BasicEvent::PlayerKilled >(this); + break; + case EVT_PLAYERTEAMKILL: + _Core->PlayerTeamKill.Disconnect< BasicEvent, &BasicEvent::PlayerTeamKill >(this); + break; + case EVT_PLAYERSPECTATE: + _Core->PlayerSpectate.Disconnect< BasicEvent, &BasicEvent::PlayerSpectate >(this); + break; + case EVT_PLAYERCRASHREPORT: + _Core->PlayerCrashreport.Disconnect< BasicEvent, &BasicEvent::PlayerCrashreport >(this); + break; + case EVT_PLAYERBURNING: + _Core->PlayerBurning.Disconnect< BasicEvent, &BasicEvent::PlayerBurning >(this); + break; + case EVT_PLAYERCROUCHING: + _Core->PlayerCrouching.Disconnect< BasicEvent, &BasicEvent::PlayerCrouching >(this); + break; + case EVT_PLAYERSTATE: + _Core->PlayerState.Disconnect< BasicEvent, &BasicEvent::PlayerState >(this); + break; + case EVT_PLAYERACTION: + _Core->PlayerAction.Disconnect< BasicEvent, &BasicEvent::PlayerAction >(this); + break; + case EVT_STATENONE: + _Core->StateNone.Disconnect< BasicEvent, &BasicEvent::StateNone >(this); + break; + case EVT_STATENORMAL: + _Core->StateNormal.Disconnect< BasicEvent, &BasicEvent::StateNormal >(this); + break; + case EVT_STATESHOOTING: + _Core->StateShooting.Disconnect< BasicEvent, &BasicEvent::StateShooting >(this); + break; + case EVT_STATEDRIVER: + _Core->StateDriver.Disconnect< BasicEvent, &BasicEvent::StateDriver >(this); + break; + case EVT_STATEPASSENGER: + _Core->StatePassenger.Disconnect< BasicEvent, &BasicEvent::StatePassenger >(this); + break; + case EVT_STATEENTERDRIVER: + _Core->StateEnterDriver.Disconnect< BasicEvent, &BasicEvent::StateEnterDriver >(this); + break; + case EVT_STATEENTERPASSENGER: + _Core->StateEnterPassenger.Disconnect< BasicEvent, &BasicEvent::StateEnterPassenger >(this); + break; + case EVT_STATEEXITVEHICLE: + _Core->StateExitVehicle.Disconnect< BasicEvent, &BasicEvent::StateExitVehicle >(this); + break; + case EVT_STATEUNSPAWNED: + _Core->StateUnspawned.Disconnect< BasicEvent, &BasicEvent::StateUnspawned >(this); + break; + case EVT_ACTIONNONE: + _Core->ActionNone.Disconnect< BasicEvent, &BasicEvent::ActionNone >(this); + break; + case EVT_ACTIONNORMAL: + _Core->ActionNormal.Disconnect< BasicEvent, &BasicEvent::ActionNormal >(this); + break; + case EVT_ACTIONAIMING: + _Core->ActionAiming.Disconnect< BasicEvent, &BasicEvent::ActionAiming >(this); + break; + case EVT_ACTIONSHOOTING: + _Core->ActionShooting.Disconnect< BasicEvent, &BasicEvent::ActionShooting >(this); + break; + case EVT_ACTIONJUMPING: + _Core->ActionJumping.Disconnect< BasicEvent, &BasicEvent::ActionJumping >(this); + break; + case EVT_ACTIONLIEDOWN: + _Core->ActionLieDown.Disconnect< BasicEvent, &BasicEvent::ActionLieDown >(this); + break; + case EVT_ACTIONGETTINGUP: + _Core->ActionGettingUp.Disconnect< BasicEvent, &BasicEvent::ActionGettingUp >(this); + break; + case EVT_ACTIONJUMPVEHICLE: + _Core->ActionJumpVehicle.Disconnect< BasicEvent, &BasicEvent::ActionJumpVehicle >(this); + break; + case EVT_ACTIONDRIVING: + _Core->ActionDriving.Disconnect< BasicEvent, &BasicEvent::ActionDriving >(this); + break; + case EVT_ACTIONDYING: + _Core->ActionDying.Disconnect< BasicEvent, &BasicEvent::ActionDying >(this); + break; + case EVT_ACTIONWASTED: + _Core->ActionWasted.Disconnect< BasicEvent, &BasicEvent::ActionWasted >(this); + break; + case EVT_ACTIONEMBARKING: + _Core->ActionEmbarking.Disconnect< BasicEvent, &BasicEvent::ActionEmbarking >(this); + break; + case EVT_ACTIONDISEMBARKING: + _Core->ActionDisembarking.Disconnect< BasicEvent, &BasicEvent::ActionDisembarking >(this); + break; + case EVT_VEHICLERESPAWN: + _Core->VehicleRespawn.Disconnect< BasicEvent, &BasicEvent::VehicleRespawn >(this); + break; + case EVT_VEHICLEEXPLODE: + _Core->VehicleExplode.Disconnect< BasicEvent, &BasicEvent::VehicleExplode >(this); + break; + case EVT_VEHICLEHEALTH: + _Core->VehicleHealth.Disconnect< BasicEvent, &BasicEvent::VehicleHealth >(this); + break; + case EVT_VEHICLEMOVE: + _Core->VehicleMove.Disconnect< BasicEvent, &BasicEvent::VehicleMove >(this); + break; + case EVT_PICKUPRESPAWN: + _Core->PickupRespawn.Disconnect< BasicEvent, &BasicEvent::PickupRespawn >(this); + break; + case EVT_KEYBINDKEYPRESS: + _Core->KeybindKeyPress.Disconnect< BasicEvent, &BasicEvent::KeybindKeyPress >(this); + break; + case EVT_KEYBINDKEYRELEASE: + _Core->KeybindKeyRelease.Disconnect< BasicEvent, &BasicEvent::KeybindKeyRelease >(this); + break; + case EVT_VEHICLEEMBARKING: + _Core->VehicleEmbarking.Disconnect< BasicEvent, &BasicEvent::VehicleEmbarking >(this); + break; + case EVT_VEHICLEEMBARKED: + _Core->VehicleEmbarked.Disconnect< BasicEvent, &BasicEvent::VehicleEmbarked >(this); + break; + case EVT_VEHICLEDISEMBARK: + _Core->VehicleDisembark.Disconnect< BasicEvent, &BasicEvent::VehicleDisembark >(this); + break; + case EVT_PICKUPCLAIMED: + _Core->PickupClaimed.Disconnect< BasicEvent, &BasicEvent::PickupClaimed >(this); + break; + case EVT_PICKUPCOLLECTED: + _Core->PickupCollected.Disconnect< BasicEvent, &BasicEvent::PickupCollected >(this); + break; + case EVT_OBJECTSHOT: + _Core->ObjectShot.Disconnect< BasicEvent, &BasicEvent::ObjectShot >(this); + break; + case EVT_OBJECTBUMP: + _Core->ObjectBump.Disconnect< BasicEvent, &BasicEvent::ObjectBump >(this); + break; + case EVT_CHECKPOINTENTERED: + _Core->CheckpointEntered.Disconnect< BasicEvent, &BasicEvent::CheckpointEntered >(this); + break; + case EVT_CHECKPOINTEXITED: + _Core->CheckpointExited.Disconnect< BasicEvent, &BasicEvent::CheckpointExited >(this); + break; + case EVT_SPHEREENTERED: + _Core->SphereEntered.Disconnect< BasicEvent, &BasicEvent::SphereEntered >(this); + break; + case EVT_SPHEREEXITED: + _Core->SphereExited.Disconnect< BasicEvent, &BasicEvent::SphereExited >(this); + break; + case EVT_SERVERFRAME: + _Core->ServerFrame.Disconnect< BasicEvent, &BasicEvent::ServerFrame >(this); + break; + case EVT_SERVERSTARTUP: + _Core->ServerStartup.Disconnect< BasicEvent, &BasicEvent::ServerStartup >(this); + break; + case EVT_SERVERSHUTDOWN: + _Core->ServerShutdown.Disconnect< BasicEvent, &BasicEvent::ServerShutdown >(this); + break; + case EVT_INTERNALCOMMAND: + _Core->InternalCommand.Disconnect< BasicEvent, &BasicEvent::InternalCommand >(this); + break; + case EVT_LOGINATTEMPT: + _Core->LoginAttempt.Disconnect< BasicEvent, &BasicEvent::LoginAttempt >(this); + break; + case EVT_CUSTOMEVENT: + _Core->CustomEvent.Disconnect< BasicEvent, &BasicEvent::CustomEvent >(this); + break; + case EVT_WORLDOPTION: + _Core->WorldOption.Disconnect< BasicEvent, &BasicEvent::WorldOption >(this); + break; + case EVT_WORLDTOGGLE: + _Core->WorldToggle.Disconnect< BasicEvent, &BasicEvent::WorldToggle >(this); + break; + case EVT_SCRIPTRELOAD: + _Core->ScriptReload.Disconnect< BasicEvent, &BasicEvent::ScriptReload >(this); + break; + case EVT_LOGMESSAGE: + _Core->LogMessage.Disconnect< BasicEvent, &BasicEvent::LogMessage >(this); + break; + default: + LogErr("Attempting to to an unknown event type: %d", _SCI32(evt)); + } +} + +// ================================================================================================ +bool Register_BasicEvent(HSQUIRRELVM vm) +{ + // Output debugging information + LogDbg("Beginning registration of type"); + // Attempt to register the specified type + Sqrat::RootTable(vm).Bind(_SC("BasicEvent"), Sqrat::Class< BasicEvent >(vm, _SC("BasicEvent")) + .Ctor() + .Ctor() + .Ctor() + + .Func(_SC("_cmp"), &BasicEvent::Cmp) + .Func(_SC("_tostring"), &BasicEvent::GetName) + + .Prop(_SC("type"), &BasicEvent::GetType) + .Prop(_SC("ltag"), &BasicEvent::GetTag, &BasicEvent::SetTag) + .Prop(_SC("ldata"), &BasicEvent::GetData, &BasicEvent::SetData) + .Prop(_SC("idle"), &BasicEvent::GetIdle, &BasicEvent::SetIdle) + .Prop(_SC("is_idle"), &BasicEvent::IsIdle) + .Prop(_SC("stride"), &BasicEvent::GetStride, &BasicEvent::SetStride) + .Prop(_SC("ignore"), &BasicEvent::GetIgnore, &BasicEvent::SetIgnore) + .Prop(_SC("primary"), &BasicEvent::GetPrimary, &BasicEvent::SetPrimary) + .Prop(_SC("secondary"), &BasicEvent::GetSecondary, &BasicEvent::SetSecondary) + .Prop(_SC("suspended"), &BasicEvent::GetSuspended, &BasicEvent::SetSuspended) + + .Prop(_SC("on_trigger"), &BasicEvent::GetOnTrigger, &BasicEvent::SetOnTrigger) + ); + // Output debugging information + LogDbg("Registration of type was successful"); + // Registration succeeded + return true; +} + +} // Namespace:: SqMod diff --git a/source/Event/Basic.hpp b/source/Event/Basic.hpp new file mode 100644 index 00000000..58ce985c --- /dev/null +++ b/source/Event/Basic.hpp @@ -0,0 +1,788 @@ +#ifndef _SQMOD_EVENT_BASIC_HPP_ +#define _SQMOD_EVENT_BASIC_HPP_ + +// ------------------------------------------------------------------------------------------------ +#include "Common.hpp" +#include "Shared.hpp" + +// ------------------------------------------------------------------------------------------------ +#include + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +/* ------------------------------------------------------------------------------------------------ + * ... +*/ +class BasicEvent +{ +protected: + + // -------------------------------------------------------------------------------------------- + typedef std::chrono::time_point TimePoint; + +public: + + /* -------------------------------------------------------------------------------------------- + * ... + */ + BasicEvent() noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + BasicEvent(SQInt32 type) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + BasicEvent(SQInt32 type, bool suspended) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + BasicEvent(const BasicEvent & o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + BasicEvent(BasicEvent && o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + ~BasicEvent(); + + /* -------------------------------------------------------------------------------------------- + * ... + */ + BasicEvent & operator = (const BasicEvent & o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + BasicEvent & operator = (BasicEvent && o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool operator == (const BasicEvent & o) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool operator != (const BasicEvent & o) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool operator < (const BasicEvent & o) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool operator > (const BasicEvent & o) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool operator <= (const BasicEvent & o) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool operator >= (const BasicEvent & o) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + operator bool () const noexcept + { + return (m_Type == EVT_UNKNOWN || m_Type >= EVT_COUNT); + } + + /* -------------------------------------------------------------------------------------------- + * ... + */ + operator ! () const noexcept + { + return (m_Type == EVT_COUNT || m_Type >= EVT_COUNT); + } + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SQInt32 Cmp(const BasicEvent & o) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + const SQChar * GetName() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SQInt32 GetType() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + const SQChar * GetTag() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetTag(const SQChar * tag) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SqObj & GetData() noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetData(SqObj & data) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SQInteger GetIdle() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetIdle(SQInteger millis) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool IsIdle() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SQInt32 GetStride() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetStride(SQInt32 stride) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SQInt32 GetIgnore() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetIgnore(SQInt32 ignore) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SQInt32 GetPrimary() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetPrimary(SQInt32 subset) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + SQInt32 GetSecondary() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetSecondary(SQInt32 subset) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool GetSuspended() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetSuspended(bool toggle) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + Function GetOnTrigger() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SetOnTrigger(const Function & func) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void BlipCreated(SQInt32 blip, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void CheckpointCreated(SQInt32 checkpoint, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void KeybindCreated(SQInt32 keybind, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ObjectCreated(SQInt32 object, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PickupCreated(SQInt32 pickup, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerCreated(SQInt32 player, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SphereCreated(SQInt32 sphere, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SpriteCreated(SQInt32 sprite, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void TextdrawCreated(SQInt32 textdraw, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleCreated(SQInt32 vehicle, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void BlipDestroyed(SQInt32 blip, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void CheckpointDestroyed(SQInt32 checkpoint, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void KeybindDestroyed(SQInt32 keybind, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ObjectDestroyed(SQInt32 object, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PickupDestroyed(SQInt32 pickup, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerDestroyed(SQInt32 player, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SphereDestroyed(SQInt32 sphere, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SpriteDestroyed(SQInt32 sprite, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void TextdrawDestroyed(SQInt32 textdraw, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleDestroyed(SQInt32 vehicle, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void BlipCustom(SQInt32 blip, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void CheckpointCustom(SQInt32 checkpoint, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void KeybindCustom(SQInt32 keybind, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ObjectCustom(SQInt32 object, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PickupCustom(SQInt32 pickup, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerCustom(SQInt32 player, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SphereCustom(SQInt32 sphere, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SpriteCustom(SQInt32 sprite, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void TextdrawCustom(SQInt32 textdraw, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleCustom(SQInt32 vehicle, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerAway(SQInt32 player, bool status) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerGameKeys(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerRename(SQInt32 player, const SQChar * previous, const SQChar * current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerRequestClass(SQInt32 player, SQInt32 offset) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerRequestSpawn(SQInt32 player) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerSpawn(SQInt32 player) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerStartTyping(SQInt32 player) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerStopTyping(SQInt32 player) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerChat(SQInt32 player, const SQChar * message) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerCommand(SQInt32 player, const SQChar * command) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerMessage(SQInt32 player, SQInt32 receiver, const SQChar * message) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerHealth(SQInt32 player, SQFloat previous, SQFloat current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerArmour(SQInt32 player, SQFloat previous, SQFloat current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerWeapon(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerMove(SQInt32 player, const Vector3 & previous, const Vector3 & current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerWasted(SQInt32 player, SQInt32 reason) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerKilled(SQInt32 player, SQInt32 killer, SQInt32 reason, SQInt32 body_part) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerTeamKill(SQInt32 player, SQInt32 killer, SQInt32 reason, SQInt32 body_part) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerSpectate(SQInt32 player, SQInt32 target) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerCrashreport(SQInt32 player, const SQChar * report) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerBurning(SQInt32 player, bool state) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerCrouching(SQInt32 player, bool state) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerState(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PlayerAction(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateNone(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateNormal(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateShooting(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateDriver(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StatePassenger(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateEnterDriver(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateEnterPassenger(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateExitVehicle(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void StateUnspawned(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionNone(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionNormal(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionAiming(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionShooting(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionJumping(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionLieDown(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionGettingUp(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionJumpVehicle(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionDriving(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionDying(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionWasted(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionEmbarking(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ActionDisembarking(SQInt32 player, SQInt32 previous) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleRespawn(SQInt32 vehicle) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleExplode(SQInt32 vehicle) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleHealth(SQInt32 vehicle, SQFloat previous, SQFloat current) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleMove(SQInt32 vehicle, const Vector3 & previous, const Vector3 ¤t) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PickupRespawn(SQInt32 pickup) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void KeybindKeyPress(SQInt32 player, SQInt32 keybind) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void KeybindKeyRelease(SQInt32 player, SQInt32 keybind) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleEmbarking(SQInt32 player, SQInt32 vehicle, SQInt32 slot) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleEmbarked(SQInt32 player, SQInt32 vehicle, SQInt32 slot) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void VehicleDisembark(SQInt32 player, SQInt32 vehicle) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PickupClaimed(SQInt32 player, SQInt32 pickup) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void PickupCollected(SQInt32 player, SQInt32 pickup) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ObjectShot(SQInt32 player, SQInt32 object, SQInt32 weapon) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ObjectBump(SQInt32 player, SQInt32 object) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void CheckpointEntered(SQInt32 player, SQInt32 checkpoint) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void CheckpointExited(SQInt32 player, SQInt32 checkpoint) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SphereEntered(SQInt32 player, SQInt32 sphere) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void SphereExited(SQInt32 player, SQInt32 sphere) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ServerFrame(SQFloat delta) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ServerStartup() noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ServerShutdown() noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void InternalCommand(SQInt32 type, const SQChar * text) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void LoginAttempt(const SQChar * name, const SQChar * pass, const SQChar * addr) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void CustomEvent(SQInt32 group, SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void WorldOption(SQInt32 option, Object & value) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void WorldToggle(SQInt32 option, bool value) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void ScriptReload(SQInt32 header, Object & payload) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void LogMessage(SQInt32 type, const SQChar * message) noexcept; + +protected: + + /* -------------------------------------------------------------------------------------------- + * ... + */ + bool Trigger() noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void Attach(EventType evt) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + void Detach(EventType evt) noexcept; + +private: + + // -------------------------------------------------------------------------------------------- + EventType m_Type; + + // -------------------------------------------------------------------------------------------- + SQInt32 m_Stride; + SQInt32 m_Ignore; + + // -------------------------------------------------------------------------------------------- + SQInt32 m_Primary; + SQInt32 m_Secondary; + + // -------------------------------------------------------------------------------------------- + TimePoint m_Idle; + + // -------------------------------------------------------------------------------------------- + Function m_OnTrigger; + + // -------------------------------------------------------------------------------------------- + SqTag m_Tag; + SqObj m_Data; + + // -------------------------------------------------------------------------------------------- + bool m_Suspended; +}; + +} // Namespace:: SqMod + +#endif // _SQMOD_EVENT_BASIC_HPP_ diff --git a/source/Event/Global.cpp b/source/Event/Global.cpp new file mode 100644 index 00000000..5b4984a7 --- /dev/null +++ b/source/Event/Global.cpp @@ -0,0 +1,70 @@ +#include "Event/Global.hpp" + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +// ------------------------------------------------------------------------------------------------ +GlobalEvent::GlobalEvent() noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +GlobalEvent::GlobalEvent(SQInt32 type) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +GlobalEvent::GlobalEvent(SQInt32 type, bool suspended) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +GlobalEvent::GlobalEvent(const GlobalEvent & o) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +GlobalEvent::GlobalEvent(GlobalEvent && o) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +GlobalEvent::~GlobalEvent() +{ + +} + +// ------------------------------------------------------------------------------------------------ +GlobalEvent & GlobalEvent::operator = (const GlobalEvent & o) noexcept +{ + return *this; +} + +// ------------------------------------------------------------------------------------------------ +GlobalEvent & GlobalEvent::operator = (GlobalEvent && o) noexcept +{ + return *this; +} + +// ================================================================================================ +bool Register_GlobalEvent(HSQUIRRELVM vm) +{ + // Output debugging information + LogDbg("Beginning registration of type"); + // Attempt to register the specified type + Sqrat::RootTable(vm).Bind(_SC("GlobalEvent"), Sqrat::Class< GlobalEvent >(vm, _SC("GlobalEvent")) + .Ctor() + ); + // Output debugging information + LogDbg("Registration of type was successful"); + // Registration succeeded + return true; +} + + +} // Namespace:: SqMod diff --git a/source/Event/Global.hpp b/source/Event/Global.hpp new file mode 100644 index 00000000..cc6d3c22 --- /dev/null +++ b/source/Event/Global.hpp @@ -0,0 +1,78 @@ +#ifndef _SQMOD_EVENT_GLOBAL_HPP_ +#define _SQMOD_EVENT_GLOBAL_HPP_ + +// ------------------------------------------------------------------------------------------------ +#include "Common.hpp" +#include "Shared.hpp" + +// ------------------------------------------------------------------------------------------------ +#include + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +/* ------------------------------------------------------------------------------------------------ + * ... +*/ +class GlobalEvent +{ +public: + + /* -------------------------------------------------------------------------------------------- + * ... + */ + GlobalEvent() noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + GlobalEvent(SQInt32 type) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + GlobalEvent(SQInt32 type, bool suspended) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + GlobalEvent(const GlobalEvent & o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + GlobalEvent(GlobalEvent && o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + ~GlobalEvent(); + + /* -------------------------------------------------------------------------------------------- + * ... + */ + GlobalEvent & operator = (const GlobalEvent & o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + GlobalEvent & operator = (GlobalEvent && o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + + +protected: + + // -------------------------------------------------------------------------------------------- + +private: + + // -------------------------------------------------------------------------------------------- + +}; + +} // Namespace:: SqMod + +#endif // _SQMOD_EVENT_GLOBAL_HPP_ diff --git a/source/Event/Local.cpp b/source/Event/Local.cpp new file mode 100644 index 00000000..b8c77790 --- /dev/null +++ b/source/Event/Local.cpp @@ -0,0 +1,73 @@ +#include "Event/Local.hpp" + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +// ------------------------------------------------------------------------------------------------ +LocalEvent::LocalEvent() noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +LocalEvent::LocalEvent(SQInt32 type) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +LocalEvent::LocalEvent(SQInt32 type, bool suspended) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +LocalEvent::LocalEvent(const LocalEvent & o) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +LocalEvent::LocalEvent(LocalEvent && o) noexcept +{ + +} + +// ------------------------------------------------------------------------------------------------ +LocalEvent::~LocalEvent() +{ + +} + +// ------------------------------------------------------------------------------------------------ +LocalEvent & LocalEvent::operator = (const LocalEvent & o) noexcept +{ + return *this; +} + +// ------------------------------------------------------------------------------------------------ +LocalEvent & LocalEvent::operator = (LocalEvent && o) noexcept +{ + return *this; +} + +// ------------------------------------------------------------------------------------------------ + + +// ================================================================================================ +bool Register_LocalEvent(HSQUIRRELVM vm) +{ + // Output debugging information + LogDbg("Beginning registration of type"); + // Attempt to register the specified type + Sqrat::RootTable(vm).Bind(_SC("LocalEvent"), Sqrat::Class< LocalEvent >(vm, _SC("LocalEvent")) + .Ctor() + ); + // Output debugging information + LogDbg("Registration of type was successful"); + // Registration succeeded + return true; +} + + +} // Namespace:: SqMod diff --git a/source/Event/Local.hpp b/source/Event/Local.hpp new file mode 100644 index 00000000..9e13def1 --- /dev/null +++ b/source/Event/Local.hpp @@ -0,0 +1,78 @@ +#ifndef _SQMOD_EVENT_LOCAL_HPP_ +#define _SQMOD_EVENT_LOCAL_HPP_ + +// ------------------------------------------------------------------------------------------------ +#include "Common.hpp" +#include "Shared.hpp" + +// ------------------------------------------------------------------------------------------------ +#include + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +/* ------------------------------------------------------------------------------------------------ + * ... +*/ +class LocalEvent +{ +public: + + /* -------------------------------------------------------------------------------------------- + * ... + */ + LocalEvent() noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + LocalEvent(SQInt32 type) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + LocalEvent(SQInt32 type, bool suspended) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + LocalEvent(const LocalEvent & o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + LocalEvent(LocalEvent && o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + ~LocalEvent(); + + /* -------------------------------------------------------------------------------------------- + * ... + */ + LocalEvent & operator = (const LocalEvent & o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + LocalEvent & operator = (LocalEvent && o) noexcept; + + /* -------------------------------------------------------------------------------------------- + * ... + */ + + +protected: + + // -------------------------------------------------------------------------------------------- + +private: + + // -------------------------------------------------------------------------------------------- + +}; + +} // Namespace:: SqMod + +#endif // _SQMOD_EVENT_LOCAL_HPP_ diff --git a/source/Event/Routine.cpp b/source/Event/Routine.cpp new file mode 100644 index 00000000..e69de29b diff --git a/source/Event/Routine.hpp b/source/Event/Routine.hpp new file mode 100644 index 00000000..e69de29b diff --git a/source/Event/Shared.cpp b/source/Event/Shared.cpp new file mode 100644 index 00000000..dfc1120d --- /dev/null +++ b/source/Event/Shared.cpp @@ -0,0 +1,128 @@ +// ------------------------------------------------------------------------------------------------ +#include "Event/Shared.hpp" +#include "Register.hpp" + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +// ------------------------------------------------------------------------------------------------ +const SQChar * GetEventName(EventType evt) +{ + switch (evt) + { + case EVT_BLIPCREATED: return _SC("Blip Created"); + case EVT_CHECKPOINTCREATED: return _SC("Checkpoint Created"); + case EVT_KEYBINDCREATED: return _SC("Keybind Created"); + case EVT_OBJECTCREATED: return _SC("Object Created"); + case EVT_PICKUPCREATED: return _SC("Pickup Created"); + case EVT_PLAYERCREATED: return _SC("Player Created"); + case EVT_SPHERECREATED: return _SC("Sphere Created"); + case EVT_SPRITECREATED: return _SC("Sprite Created"); + case EVT_TEXTDRAWCREATED: return _SC("Textdraw Created"); + case EVT_VEHICLECREATED: return _SC("Vehicle Created"); + case EVT_BLIPDESTROYED: return _SC("Blip Destroyed"); + case EVT_CHECKPOINTDESTROYED: return _SC("Checkpoint Destroyed"); + case EVT_KEYBINDDESTROYED: return _SC("Keybind Destroyed"); + case EVT_OBJECTDESTROYED: return _SC("Object Destroyed"); + case EVT_PICKUPDESTROYED: return _SC("Pickup Destroyed"); + case EVT_PLAYERDESTROYED: return _SC("Player Destroyed"); + case EVT_SPHEREDESTROYED: return _SC("Sphere Destroyed"); + case EVT_SPRITEDESTROYED: return _SC("Sprite Destroyed"); + case EVT_TEXTDRAWDESTROYED: return _SC("Textdraw Destroyed"); + case EVT_VEHICLEDESTROYED: return _SC("Vehicle Destroyed"); + case EVT_BLIPCUSTOM: return _SC("Blip Custom"); + case EVT_CHECKPOINTCUSTOM: return _SC("Checkpoint Custom"); + case EVT_KEYBINDCUSTOM: return _SC("Keybind Custom"); + case EVT_OBJECTCUSTOM: return _SC("Object Custom"); + case EVT_PICKUPCUSTOM: return _SC("Pickup Custom"); + case EVT_PLAYERCUSTOM: return _SC("Player Custom"); + case EVT_SPHERECUSTOM: return _SC("Sphere Custom"); + case EVT_SPRITECUSTOM: return _SC("Sprite Custom"); + case EVT_TEXTDRAWCUSTOM: return _SC("Textdraw Custom"); + case EVT_VEHICLECUSTOM: return _SC("Vehicle Custom"); + case EVT_PLAYERAWAY: return _SC("Player Away"); + case EVT_PLAYERGAMEKEYS: return _SC("Player Game Keys"); + case EVT_PLAYERRENAME: return _SC("Player Rename"); + case EVT_PLAYERREQUESTCLASS: return _SC("Player Request Class"); + case EVT_PLAYERREQUESTSPAWN: return _SC("Player Request Spawn"); + case EVT_PLAYERSPAWN: return _SC("Player Spawn"); + case EVT_PLAYERSTARTTYPING: return _SC("Player Start Typing"); + case EVT_PLAYERSTOPTYPING: return _SC("Player Stop Typing"); + case EVT_PLAYERCHAT: return _SC("Player Chat"); + case EVT_PLAYERCOMMAND: return _SC("Player Command"); + case EVT_PLAYERMESSAGE: return _SC("Player Message"); + case EVT_PLAYERHEALTH: return _SC("Player Health"); + case EVT_PLAYERARMOUR: return _SC("Player Armour"); + case EVT_PLAYERWEAPON: return _SC("Player Weapon"); + case EVT_PLAYERMOVE: return _SC("Player Move"); + case EVT_PLAYERWASTED: return _SC("Player Wasted"); + case EVT_PLAYERKILLED: return _SC("Player Killed"); + case EVT_PLAYERTEAMKILL: return _SC("Player Team Kill"); + case EVT_PLAYERSPECTATE: return _SC("Player Spectate"); + case EVT_PLAYERCRASHREPORT: return _SC("Player Crash Report"); + case EVT_PLAYERBURNING: return _SC("Player Burning"); + case EVT_PLAYERCROUCHING: return _SC("Player Crouching"); + case EVT_PLAYERSTATE: return _SC("Player State"); + case EVT_PLAYERACTION: return _SC("Player Action"); + case EVT_STATENONE: return _SC("State None"); + case EVT_STATENORMAL: return _SC("State Normal"); + case EVT_STATESHOOTING: return _SC("State Shooting"); + case EVT_STATEDRIVER: return _SC("State Driver"); + case EVT_STATEPASSENGER: return _SC("State Passenger"); + case EVT_STATEENTERDRIVER: return _SC("State Enter Driver"); + case EVT_STATEENTERPASSENGER: return _SC("State Enter Passenger"); + case EVT_STATEEXITVEHICLE: return _SC("State Exit Vehicle"); + case EVT_STATEUNSPAWNED: return _SC("State Unspawned"); + case EVT_ACTIONNONE: return _SC("Action None"); + case EVT_ACTIONNORMAL: return _SC("Action Normal"); + case EVT_ACTIONAIMING: return _SC("Action Aiming"); + case EVT_ACTIONSHOOTING: return _SC("Action Shooting"); + case EVT_ACTIONJUMPING: return _SC("Action Jumping"); + case EVT_ACTIONLIEDOWN: return _SC("Action Lie Down"); + case EVT_ACTIONGETTINGUP: return _SC("Action Getting Up"); + case EVT_ACTIONJUMPVEHICLE: return _SC("Action Jump Vehicle"); + case EVT_ACTIONDRIVING: return _SC("Action Driving"); + case EVT_ACTIONDYING: return _SC("Action Dying"); + case EVT_ACTIONWASTED: return _SC("Action Wasted"); + case EVT_ACTIONEMBARKING: return _SC("Action Embarking"); + case EVT_ACTIONDISEMBARKING: return _SC("Action Disembarking"); + case EVT_VEHICLERESPAWN: return _SC("Vehicle Respawn"); + case EVT_VEHICLEEXPLODE: return _SC("Vehicle Explode"); + case EVT_VEHICLEHEALTH: return _SC("Vehicle Health"); + case EVT_VEHICLEMOVE: return _SC("Vehicle Move"); + case EVT_PICKUPRESPAWN: return _SC("Pickup Respawn"); + case EVT_KEYBINDKEYPRESS: return _SC("Keybind Key Press"); + case EVT_KEYBINDKEYRELEASE: return _SC("Keybind Key Release"); + case EVT_VEHICLEEMBARKING: return _SC("Vehicle Embarking"); + case EVT_VEHICLEEMBARKED: return _SC("Vehicle Embarked"); + case EVT_VEHICLEDISEMBARK: return _SC("Vehicle Disembark"); + case EVT_PICKUPCLAIMED: return _SC("Pickup Claimed"); + case EVT_PICKUPCOLLECTED: return _SC("Pickup Collected"); + case EVT_OBJECTSHOT: return _SC("Object Shot"); + case EVT_OBJECTBUMP: return _SC("Object Bump"); + case EVT_CHECKPOINTENTERED: return _SC("Checkpoint Entered"); + case EVT_CHECKPOINTEXITED: return _SC("Checkpoint Exited"); + case EVT_SPHEREENTERED: return _SC("Sphere Entered"); + case EVT_SPHEREEXITED: return _SC("Sphere Exited"); + case EVT_SERVERFRAME: return _SC("Server Frame"); + case EVT_SERVERSTARTUP: return _SC("Server Startup"); + case EVT_SERVERSHUTDOWN: return _SC("Server Shutdown"); + case EVT_INTERNALCOMMAND: return _SC("Internal Command"); + case EVT_LOGINATTEMPT: return _SC("Login Attempt"); + case EVT_CUSTOMEVENT: return _SC("Custom Event"); + case EVT_WORLDOPTION: return _SC("World Option"); + case EVT_WORLDTOGGLE: return _SC("World Toggle"); + case EVT_SCRIPTRELOAD: return _SC("Script Reload"); + case EVT_LOGMESSAGE: return _SC("Log Message"); + default: return _SC("Unknown"); + } + +} + +// ================================================================================================ +bool Register_Event(HSQUIRRELVM vm) +{ + return true; +} + +} // Namespace:: SqMod diff --git a/source/Event/Shared.hpp b/source/Event/Shared.hpp new file mode 100644 index 00000000..e4116123 --- /dev/null +++ b/source/Event/Shared.hpp @@ -0,0 +1,15 @@ +#ifndef _SQMOD_EVENT_SHARED_HPP_ +#define _SQMOD_EVENT_SHARED_HPP_ + +// ------------------------------------------------------------------------------------------------ +#include "Signal.hpp" + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +// ------------------------------------------------------------------------------------------------ +const SQChar * GetEventName(EventType evt); + +} // Namespace:: SqMod + +#endif // _SQMOD_EVENT_SHARED_HPP_ \ No newline at end of file diff --git a/source/Register.cpp b/source/Register.cpp index 1e0ae0b5..b5436fa6 100644 --- a/source/Register.cpp +++ b/source/Register.cpp @@ -69,7 +69,12 @@ bool RegisterAPI(HSQUIRRELVM vm) noexcept _Log->cFtl(!Register_CWastedSettings(vm), "Unable to register: CWastedSettings") || \ _Log->cFtl(!Register_CWeapon(vm), "Unable to register: CWeapon") || \ _Log->cFtl(!Register_CWorldBounds(vm), "Unable to register: CWorldBounds") || \ - _Log->cFtl(!Register_Misc(vm), "Unable to register: Misc") + _Log->cFtl(!Register_Misc(vm), "Unable to register: Misc") || \ + + _Log->cFtl(!Register_BasicEvent(vm), "Unable to register: BasicEvent") || \ + _Log->cFtl(!Register_GlobalEvent(vm), "Unable to register: GlobalEvent") || \ + _Log->cFtl(!Register_LocalEvent(vm), "Unable to register: LocalEvent") || \ + _Log->cFtl(!Register_Event(vm), "Unable to register: Event") ) return false; return true; diff --git a/source/Register.hpp b/source/Register.hpp index 10d68455..f3fbf1b7 100644 --- a/source/Register.hpp +++ b/source/Register.hpp @@ -98,6 +98,12 @@ bool Register_SSprite(HSQUIRRELVM vm); bool Register_STextdraw(HSQUIRRELVM vm); bool Register_Selector(HSQUIRRELVM vm); +// ------------------------------------------------------------------------------------------------ +bool Register_BasicEvent(HSQUIRRELVM vm); +bool Register_GlobalEvent(HSQUIRRELVM vm); +bool Register_LocalEvent(HSQUIRRELVM vm); +bool Register_Event(HSQUIRRELVM vm); + // ------------------------------------------------------------------------------------------------ bool Register_Utility(HSQUIRRELVM vm); diff --git a/source/Signal.hpp b/source/Signal.hpp index ecc4ca8a..890eb462 100644 --- a/source/Signal.hpp +++ b/source/Signal.hpp @@ -92,9 +92,12 @@ protected: { if (node->m_This == t && node->m_Exec == e) { - if (prev) { + if (prev) + { prev->m_Next = node->m_Next; - } else { + } + else + { m_Head = m_Head->m_Next; } delete node; @@ -108,7 +111,7 @@ protected: { for (Node * node = m_Head, * next = 0; node; node = next) { - next = node->m_Next ? node->m_Next : 0; + next = node->m_Next; delete node; } m_Head = 0; @@ -461,8 +464,8 @@ using EPlayerSpectate = Signal< void (SQInt32 /* player */, SQInt32 /* tar using EPlayerCrashreport = Signal< void (SQInt32 /* player */, const SQChar * /* report */), EVT_PLAYERCRASHREPORT >; // ------------------------------------------------------------------------------------------------ -using EPlayerBurning = Signal< void (SQInt32 /* player */, bool /* state */ ), EVT_PLAYERBURNING >; -using EPlayerCrouching = Signal< void (SQInt32 /* player */, bool /* state */ ), EVT_PLAYERCROUCHING >; +using EPlayerBurning = Signal< void (SQInt32 /* player */, bool /* state */), EVT_PLAYERBURNING >; +using EPlayerCrouching = Signal< void (SQInt32 /* player */, bool /* state */), EVT_PLAYERCROUCHING >; // ------------------------------------------------------------------------------------------------ using EPlayerState = Signal< void (SQInt32 /* player */, SQInt32 /* previous */, SQInt32 /* current */), EVT_PLAYERSTATE >; @@ -480,27 +483,27 @@ using EStateExitVehicle = Signal< void (SQInt32 /* player */, SQInt32 /* pre using EStateUnspawned = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_STATEUNSPAWNED >; // ------------------------------------------------------------------------------------------------ -using EActionNone = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONNONE >; -using EActionNormal = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONNORMAL >; -using EActionAiming = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONAIMING >; -using EActionShooting = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONSHOOTING >; -using EActionJumping = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONJUMPING >; -using EActionLieDown = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONLIEDOWN >; -using EActionGettingUp = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONGETTINGUP >; -using EActionJumpVehicle = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONJUMPVEHICLE >; -using EActionDriving = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONDRIVING >; -using EActionDying = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONDYING >; -using EActionWasted = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONWASTED >; -using EActionEmbarking = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONEMBARKING >; -using EActionDisembarking = Signal< void (SQInt32 /* player */, SQInt32 /* previous */ ), EVT_ACTIONDISEMBARKING >; +using EActionNone = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONNONE >; +using EActionNormal = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONNORMAL >; +using EActionAiming = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONAIMING >; +using EActionShooting = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONSHOOTING >; +using EActionJumping = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONJUMPING >; +using EActionLieDown = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONLIEDOWN >; +using EActionGettingUp = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONGETTINGUP >; +using EActionJumpVehicle = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONJUMPVEHICLE >; +using EActionDriving = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONDRIVING >; +using EActionDying = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONDYING >; +using EActionWasted = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONWASTED >; +using EActionEmbarking = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONEMBARKING >; +using EActionDisembarking = Signal< void (SQInt32 /* player */, SQInt32 /* previous */), EVT_ACTIONDISEMBARKING >; // ------------------------------------------------------------------------------------------------ -using EVehicleRespawn = Signal< void (SQInt32 /* vehcle */), EVT_VEHICLERESPAWN >; -using EVehicleExplode = Signal< void (SQInt32 /* vehcle */), EVT_VEHICLEEXPLODE >; +using EVehicleRespawn = Signal< void (SQInt32 /* vehicle */), EVT_VEHICLERESPAWN >; +using EVehicleExplode = Signal< void (SQInt32 /* vehicle */), EVT_VEHICLEEXPLODE >; // ------------------------------------------------------------------------------------------------ -using EVehicleHealth = Signal< void (SQInt32 /* vehcle */, SQFloat, SQFloat), EVT_VEHICLEHEALTH >; -using EVehicleMove = Signal< void (SQInt32 /* vehcle */, const Vector3 &, const Vector3 &), EVT_VEHICLEMOVE >; +using EVehicleHealth = Signal< void (SQInt32 /* vehicle */, SQFloat /* previous */, SQFloat /* current */), EVT_VEHICLEHEALTH >; +using EVehicleMove = Signal< void (SQInt32 /* vehicle */, const Vector3 & /* previous */, const Vector3 &/* current */), EVT_VEHICLEMOVE >; // ------------------------------------------------------------------------------------------------ using EPickupRespawn = Signal< void (SQInt32 /* pickup */), EVT_PICKUPRESPAWN >; @@ -510,9 +513,9 @@ using EKeybindKeyPress = Signal< void (SQInt32 /* player */, SQInt32 /* key using EKeybindKeyRelease = Signal< void (SQInt32 /* player */, SQInt32 /* keybind */), EVT_KEYBINDKEYRELEASE >; // ------------------------------------------------------------------------------------------------ -using EVehicleEmbarking = Signal< void (SQInt32 /* player */, SQInt32 /* vehcle */, SQInt32 /* slot */), EVT_VEHICLEEMBARKING >; -using EVehicleEmbarked = Signal< void (SQInt32 /* player */, SQInt32 /* vehcle */, SQInt32 /* slot */), EVT_VEHICLEEMBARKED >; -using EVehicleDisembark = Signal< void (SQInt32 /* player */, SQInt32 /* vehcle */), EVT_VEHICLEDISEMBARK >; +using EVehicleEmbarking = Signal< void (SQInt32 /* player */, SQInt32 /* vehicle */, SQInt32 /* slot */), EVT_VEHICLEEMBARKING >; +using EVehicleEmbarked = Signal< void (SQInt32 /* player */, SQInt32 /* vehicle */, SQInt32 /* slot */), EVT_VEHICLEEMBARKED >; +using EVehicleDisembark = Signal< void (SQInt32 /* player */, SQInt32 /* vehicle */), EVT_VEHICLEDISEMBARK >; // ------------------------------------------------------------------------------------------------ using EPickupClaimed = Signal< void (SQInt32 /* player */, SQInt32 /* pickup */), EVT_PICKUPCLAIMED >; @@ -548,6 +551,9 @@ using ECustomEvent = Signal< void (SQInt32 /* group */, SQInt32 /* head using EWorldOption = Signal< void (SQInt32 /* option */, Object & /* value */), EVT_WORLDOPTION >; using EWorldToggle = Signal< void (SQInt32 /* option */, bool /* value */), EVT_WORLDTOGGLE >; +// ------------------------------------------------------------------------------------------------ +using EScriptReload = Signal< void (SQInt32 /* header */, Object & /* payload */), EVT_SCRIPTRELOAD >; + // ------------------------------------------------------------------------------------------------ using ELogMessage = Signal< void (SQInt32 /* type */, const SQChar * /* message */), EVT_LOGMESSAGE >;