From 5ddb222903f28fbb43393d654ffd41b3dca53223 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 16 Jul 2016 21:51:01 +0300 Subject: [PATCH] Prevent server callbacks not being bound when compiling on linux. --- modules/irc/Module.cpp | 40 ++------- modules/json/Module.cpp | 30 +------ modules/mg/Module.cpp | 30 +------ modules/mmdb/Module.cpp | 30 +------ modules/mysql/Module.cpp | 30 +------ modules/sample/Module.cpp | 30 +------ modules/sqlite/Module.cpp | 30 +------ modules/xml/Module.cpp | 30 +------ source/Main.cpp | 184 +++++++++++++++++--------------------- 9 files changed, 118 insertions(+), 316 deletions(-) diff --git a/modules/irc/Module.cpp b/modules/irc/Module.cpp index 60903904..48cd0420 100644 --- a/modules/irc/Module.cpp +++ b/modules/irc/Module.cpp @@ -14,16 +14,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -163,7 +153,10 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); + _Clbk->OnServerInitialise = nullptr; + _Clbk->OnServerShutdown = nullptr; + _Clbk->OnServerFrame = nullptr; + _Clbk->OnPluginCommand = nullptr; } /* ------------------------------------------------------------------------------------------------ @@ -175,24 +168,6 @@ static void OnServerFrame(float /*delta*/) Session::Process(); } -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnServerFrame = OnServerFrame; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ - _Clbk->OnServerInitialise = nullptr; - _Clbk->OnServerShutdown = nullptr; - _Clbk->OnServerFrame = nullptr; - _Clbk->OnPluginCommand = nullptr; -} - // ------------------------------------------------------------------------------------------------ void RegisterAPI(HSQUIRRELVM vm) { @@ -532,8 +507,11 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQIRC_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnServerFrame = OnServerFrame; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQIRC_NAME); // Dummy spacing diff --git a/modules/json/Module.cpp b/modules/json/Module.cpp index 6d686acc..909c1019 100644 --- a/modules/json/Module.cpp +++ b/modules/json/Module.cpp @@ -8,16 +8,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -155,20 +145,6 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); -} - -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnPluginCommand = nullptr; @@ -243,8 +219,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQJSON_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQJSON_NAME); // Dummy spacing diff --git a/modules/mg/Module.cpp b/modules/mg/Module.cpp index 007b1718..9a8aaaf7 100644 --- a/modules/mg/Module.cpp +++ b/modules/mg/Module.cpp @@ -10,16 +10,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -157,20 +147,6 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); -} - -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnPluginCommand = nullptr; @@ -326,8 +302,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMG_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQMG_NAME); // Dummy spacing diff --git a/modules/mmdb/Module.cpp b/modules/mmdb/Module.cpp index c6b6eb15..577a8b86 100644 --- a/modules/mmdb/Module.cpp +++ b/modules/mmdb/Module.cpp @@ -8,16 +8,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -155,20 +145,6 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); -} - -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnPluginCommand = nullptr; @@ -220,8 +196,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMMDB_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQMMDB_NAME); // Dummy spacing diff --git a/modules/mysql/Module.cpp b/modules/mysql/Module.cpp index 3b432ebf..ad41de74 100644 --- a/modules/mysql/Module.cpp +++ b/modules/mysql/Module.cpp @@ -8,16 +8,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -155,20 +145,6 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); -} - -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnPluginCommand = nullptr; @@ -233,8 +209,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMYSQL_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQMYSQL_NAME); // Dummy spacing diff --git a/modules/sample/Module.cpp b/modules/sample/Module.cpp index 02d69831..4e0cdf5e 100644 --- a/modules/sample/Module.cpp +++ b/modules/sample/Module.cpp @@ -8,16 +8,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -156,20 +146,6 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); -} - -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnPluginCommand = nullptr; @@ -229,8 +205,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQSAMPLE_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQSAMPLE_NAME); // Dummy spacing diff --git a/modules/sqlite/Module.cpp b/modules/sqlite/Module.cpp index 7075616b..b774b3c9 100644 --- a/modules/sqlite/Module.cpp +++ b/modules/sqlite/Module.cpp @@ -8,16 +8,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -155,20 +145,6 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); -} - -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnPluginCommand = nullptr; @@ -239,8 +215,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQSQLITE_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQSQLITE_NAME); // Dummy spacing diff --git a/modules/xml/Module.cpp b/modules/xml/Module.cpp index b23de8bf..204461e1 100644 --- a/modules/xml/Module.cpp +++ b/modules/xml/Module.cpp @@ -13,16 +13,6 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { -/* ------------------------------------------------------------------------------------------------ - * Bind specific functions to certain server events. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Undo changes made with BindCallbacks(). -*/ -void UnbindCallbacks(); - /* ------------------------------------------------------------------------------------------------ * Register the module API under the specified virtual machine. */ @@ -160,20 +150,6 @@ static uint8_t OnServerInitialise() static void OnServerShutdown(void) { // The server may still send callbacks - UnbindCallbacks(); -} - -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() -{ - _Clbk->OnServerInitialise = OnServerInitialise; - _Clbk->OnServerShutdown = OnServerShutdown; - _Clbk->OnPluginCommand = OnPluginCommand; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnPluginCommand = nullptr; @@ -517,8 +493,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * functions, PluginCall _Info->apiMinorVersion = PLUGIN_API_MINOR; // Assign the plug-in name std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQXML_HOST_NAME); - // Bind callbacks - BindCallbacks(); + // Bind to the server callbacks + _Clbk->OnServerInitialise = OnServerInitialise; + _Clbk->OnServerShutdown = OnServerShutdown; + _Clbk->OnPluginCommand = OnPluginCommand; // Notify that the plug-in was successfully loaded OutputMessage("Successfully loaded %s", SQXML_NAME); // Dummy spacing diff --git a/source/Main.cpp b/source/Main.cpp index 64b4be0d..ec416cb9 100644 --- a/source/Main.cpp +++ b/source/Main.cpp @@ -61,16 +61,6 @@ void DoReload() } } -/* ------------------------------------------------------------------------------------------------ - * Bind all server callbacks. -*/ -void BindCallbacks(); - -/* ------------------------------------------------------------------------------------------------ - * Unbind all server callbacks. -*/ -void UnbindCallbacks(); - // -------------------------------------------------------------------------------------------- #define SQMOD_CATCH_EVENT_EXCEPTION(ev) /* */ catch (const Sqrat::Exception & e) /* @@ -138,7 +128,50 @@ static void OnServerShutdown(void) // See if a reload was requested (quite useless here but why not) SQMOD_RELOAD_CHECK(g_Reload) // The server still triggers callbacks and we deallocated everything! - UnbindCallbacks(); + _Clbk->OnServerInitialise = nullptr; + _Clbk->OnServerShutdown = nullptr; + _Clbk->OnServerFrame = nullptr; + _Clbk->OnPluginCommand = nullptr; + _Clbk->OnIncomingConnection = nullptr; + _Clbk->OnClientScriptData = nullptr; + _Clbk->OnPlayerConnect = nullptr; + _Clbk->OnPlayerDisconnect = nullptr; + _Clbk->OnPlayerRequestClass = nullptr; + _Clbk->OnPlayerRequestSpawn = nullptr; + _Clbk->OnPlayerSpawn = nullptr; + _Clbk->OnPlayerDeath = nullptr; + _Clbk->OnPlayerUpdate = nullptr; + _Clbk->OnPlayerRequestEnterVehicle = nullptr; + _Clbk->OnPlayerEnterVehicle = nullptr; + _Clbk->OnPlayerExitVehicle = nullptr; + _Clbk->OnPlayerNameChange = nullptr; + _Clbk->OnPlayerStateChange = nullptr; + _Clbk->OnPlayerActionChange = nullptr; + _Clbk->OnPlayerOnFireChange = nullptr; + _Clbk->OnPlayerCrouchChange = nullptr; + _Clbk->OnPlayerGameKeysChange = nullptr; + _Clbk->OnPlayerBeginTyping = nullptr; + _Clbk->OnPlayerEndTyping = nullptr; + _Clbk->OnPlayerAwayChange = nullptr; + _Clbk->OnPlayerMessage = nullptr; + _Clbk->OnPlayerCommand = nullptr; + _Clbk->OnPlayerPrivateMessage = nullptr; + _Clbk->OnPlayerKeyBindDown = nullptr; + _Clbk->OnPlayerKeyBindUp = nullptr; + _Clbk->OnPlayerSpectate = nullptr; + _Clbk->OnPlayerCrashReport = nullptr; + _Clbk->OnVehicleUpdate = nullptr; + _Clbk->OnVehicleExplode = nullptr; + _Clbk->OnVehicleRespawn = nullptr; + _Clbk->OnObjectShot = nullptr; + _Clbk->OnObjectTouched = nullptr; + _Clbk->OnPickupPickAttempt = nullptr; + _Clbk->OnPickupPicked = nullptr; + _Clbk->OnPickupRespawn = nullptr; + _Clbk->OnCheckpointEntered = nullptr; + _Clbk->OnCheckpointExited = nullptr; + _Clbk->OnEntityPoolChange = nullptr; + _Clbk->OnServerPerformanceReport = nullptr; } // ------------------------------------------------------------------------------------------------ @@ -805,9 +838,44 @@ static void OnServerPerformanceReport(size_t /*entry_count*/, CCStr * /*descript // Ignored for now... } -// ------------------------------------------------------------------------------------------------ -void BindCallbacks() +} // Namespace:: SqMod + +/* ------------------------------------------------------------------------------------------------ + * Plugiun initialization procedure. +*/ +SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallbacks * calls, PluginInfo * info) { + using namespace SqMod; + // Output plug-in header + puts(""); + OutputMessage("--------------------------------------------------------------------"); + OutputMessage("Plug-in: %s", SQMOD_NAME); + OutputMessage("Author: %s", SQMOD_AUTHOR); + OutputMessage("Legal: %s", SQMOD_COPYRIGHT); + OutputMessage("--------------------------------------------------------------------"); + puts(""); + // Store server proxies + _Func = funcs; + _Clbk = calls; + _Info = info; + // Assign plug-in version + _Info->pluginVersion = SQMOD_VERSION; + _Info->apiMajorVersion = PLUGIN_API_MAJOR; + _Info->apiMinorVersion = PLUGIN_API_MINOR; + // Assign the plug-in name + std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMOD_HOST_NAME); + // Attempt to initialize the logger before anything else + Logger::Get().Initialize(nullptr); + // Attempt to initialize the plug-in core + if (!Core::Get().Initialize()) + { + LogFtl("Unable to initialize the plug-in central core"); + // Attempt to terminate + Core::Get().Terminate(false); + // Stop here! + return SQMOD_FAILURE; + } + // Bind to the server callbacks _Clbk->OnServerInitialise = OnServerInitialise; _Clbk->OnServerShutdown = OnServerShutdown; _Clbk->OnServerFrame = OnServerFrame; @@ -852,96 +920,6 @@ void BindCallbacks() _Clbk->OnCheckpointExited = OnCheckpointExited; _Clbk->OnEntityPoolChange = OnEntityPoolChange; _Clbk->OnServerPerformanceReport = OnServerPerformanceReport; -} - -// ------------------------------------------------------------------------------------------------ -void UnbindCallbacks() -{ - _Clbk->OnServerInitialise = nullptr; - _Clbk->OnServerShutdown = nullptr; - _Clbk->OnServerFrame = nullptr; - _Clbk->OnPluginCommand = nullptr; - _Clbk->OnIncomingConnection = nullptr; - _Clbk->OnClientScriptData = nullptr; - _Clbk->OnPlayerConnect = nullptr; - _Clbk->OnPlayerDisconnect = nullptr; - _Clbk->OnPlayerRequestClass = nullptr; - _Clbk->OnPlayerRequestSpawn = nullptr; - _Clbk->OnPlayerSpawn = nullptr; - _Clbk->OnPlayerDeath = nullptr; - _Clbk->OnPlayerUpdate = nullptr; - _Clbk->OnPlayerRequestEnterVehicle = nullptr; - _Clbk->OnPlayerEnterVehicle = nullptr; - _Clbk->OnPlayerExitVehicle = nullptr; - _Clbk->OnPlayerNameChange = nullptr; - _Clbk->OnPlayerStateChange = nullptr; - _Clbk->OnPlayerActionChange = nullptr; - _Clbk->OnPlayerOnFireChange = nullptr; - _Clbk->OnPlayerCrouchChange = nullptr; - _Clbk->OnPlayerGameKeysChange = nullptr; - _Clbk->OnPlayerBeginTyping = nullptr; - _Clbk->OnPlayerEndTyping = nullptr; - _Clbk->OnPlayerAwayChange = nullptr; - _Clbk->OnPlayerMessage = nullptr; - _Clbk->OnPlayerCommand = nullptr; - _Clbk->OnPlayerPrivateMessage = nullptr; - _Clbk->OnPlayerKeyBindDown = nullptr; - _Clbk->OnPlayerKeyBindUp = nullptr; - _Clbk->OnPlayerSpectate = nullptr; - _Clbk->OnPlayerCrashReport = nullptr; - _Clbk->OnVehicleUpdate = nullptr; - _Clbk->OnVehicleExplode = nullptr; - _Clbk->OnVehicleRespawn = nullptr; - _Clbk->OnObjectShot = nullptr; - _Clbk->OnObjectTouched = nullptr; - _Clbk->OnPickupPickAttempt = nullptr; - _Clbk->OnPickupPicked = nullptr; - _Clbk->OnPickupRespawn = nullptr; - _Clbk->OnCheckpointEntered = nullptr; - _Clbk->OnCheckpointExited = nullptr; - _Clbk->OnEntityPoolChange = nullptr; - _Clbk->OnServerPerformanceReport = nullptr; -} - -} // Namespace:: SqMod - -/* ------------------------------------------------------------------------------------------------ - * Plugiun initialization procedure. -*/ -SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallbacks * calls, PluginInfo * info) -{ - using namespace SqMod; - // Output plug-in header - puts(""); - OutputMessage("--------------------------------------------------------------------"); - OutputMessage("Plug-in: %s", SQMOD_NAME); - OutputMessage("Author: %s", SQMOD_AUTHOR); - OutputMessage("Legal: %s", SQMOD_COPYRIGHT); - OutputMessage("--------------------------------------------------------------------"); - puts(""); - // Store server proxies - _Func = funcs; - _Clbk = calls; - _Info = info; - // Assign plug-in version - _Info->pluginVersion = SQMOD_VERSION; - _Info->apiMajorVersion = PLUGIN_API_MAJOR; - _Info->apiMinorVersion = PLUGIN_API_MINOR; - // Assign the plug-in name - std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMOD_HOST_NAME); - // Attempt to initialize the logger before anything else - Logger::Get().Initialize(nullptr); - // Attempt to initialize the plug-in core - if (!Core::Get().Initialize()) - { - LogFtl("Unable to initialize the plug-in central core"); - // Attempt to terminate - Core::Get().Terminate(false); - // Stop here! - return SQMOD_FAILURE; - } - // Bind to server callbacks - BindCallbacks(); // Attempt to initialize the plug-in exports InitExports(); // Dummy spacing