1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-19 16:47:14 +02:00

Untested update to the new plugin API.

Various other changes to the plugin as well.
This commit is contained in:
Sandu Liviu Catalin
2016-05-22 06:20:38 +03:00
parent ddb52677bd
commit f2361a27c3
167 changed files with 15520 additions and 60635 deletions

View File

@ -123,12 +123,12 @@ bool CheckAPIVer(CCStr ver)
/* --------------------------------------------------------------------------------------------
* React to command sent by other plugins.
*/
static int OnInternalCommand(unsigned int type, const char * text)
static uint8_t OnPluginCommand(uint32_t command_identifier, CCStr message)
{
switch(type)
switch(command_identifier)
{
case SQMOD_INITIALIZE_CMD:
if (CheckAPIVer(text))
if (CheckAPIVer(message))
{
OnSquirrelInitialize();
}
@ -147,12 +147,12 @@ static int OnInternalCommand(unsigned int type, const char * text)
/* --------------------------------------------------------------------------------------------
* The server was initialized and this plugin was loaded successfully.
*/
static int OnInitServer()
static uint8_t OnServerInitialise()
{
return 1;
}
static void OnShutdownServer(void)
static void OnServerShutdown(void)
{
// The server may still send callbacks
UnbindCallbacks();
@ -161,17 +161,17 @@ static void OnShutdownServer(void)
// ------------------------------------------------------------------------------------------------
void BindCallbacks()
{
_Clbk->OnInitServer = OnInitServer;
_Clbk->OnInternalCommand = OnInternalCommand;
_Clbk->OnShutdownServer = OnShutdownServer;
_Clbk->OnServerInitialise = OnServerInitialise;
_Clbk->OnServerShutdown = OnServerShutdown;
_Clbk->OnPluginCommand = OnPluginCommand;
}
// ------------------------------------------------------------------------------------------------
void UnbindCallbacks()
{
_Clbk->OnInitServer = nullptr;
_Clbk->OnInternalCommand = nullptr;
_Clbk->OnShutdownServer = nullptr;
_Clbk->OnServerInitialise = nullptr;
_Clbk->OnServerShutdown = nullptr;
_Clbk->OnPluginCommand = nullptr;
}
// --------------------------------------------------------------------------------------------
@ -712,17 +712,17 @@ void OutputMessageImpl(const char * msg, va_list args)
CONSOLE_SCREEN_BUFFER_INFO csb_before;
GetConsoleScreenBufferInfo( hstdout, &csb_before);
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
printf("[SQMOD] ");
std::printf("[SQMOD] ");
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
vprintf(msg, args);
puts("");
std::vprintf(msg, args);
std::puts("");
SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
#else
printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27);
vprintf(msg, args);
puts("");
std::printf("%c[0;32m[SQMOD]%c[0m", 27, 27);
std::vprintf(msg, args);
std::puts("");
#endif
}
@ -735,17 +735,17 @@ void OutputErrorImpl(const char * msg, va_list args)
CONSOLE_SCREEN_BUFFER_INFO csb_before;
GetConsoleScreenBufferInfo( hstdout, &csb_before);
SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
printf("[SQMOD] ");
std::printf("[SQMOD] ");
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
vprintf(msg, args);
puts("");
std::vprintf(msg, args);
std::puts("");
SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
#else
printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27);
vprintf(msg, args);
puts("");
std::printf("%c[0;91m[SQMOD]%c[0m", 27, 27);
std::vprintf(msg, args);
std::puts("");
#endif
}
@ -813,7 +813,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallb
return SQMOD_FAILURE;
}
// Should never reach this point but just in case
else if (host_plugin_id > (info->nPluginId))
else if (static_cast< Uint32 >(host_plugin_id) > info->pluginId)
{
OutputError("%s loaded after the host plugin", SQSQLITE_NAME);
// Don't load!
@ -823,9 +823,12 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallb
_Func = functions;
_Clbk = callbacks;
_Info = info;
// Assign plugin information
_Info->uPluginVer = SQSQLITE_VERSION;
std::strcpy(_Info->szName, SQSQLITE_HOST_NAME);
// Assign plugin version
_Info->pluginVersion = SQSQLITE_VERSION;
_Info->apiMajorVersion = PLUGIN_API_MAJOR;
_Info->apiMinorVersion = PLUGIN_API_MINOR;
// Assign the plugin name
std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQSQLITE_HOST_NAME);
// Bind callbacks
BindCallbacks();
// Notify that the plugin was successfully loaded