updated to new module API
This commit is contained in:
parent
37151d361f
commit
f2c5a2b85b
|
@ -1,6 +1,8 @@
|
|||
#include "amxxmodule.h"
|
||||
#include "mysql2_header.h"
|
||||
|
||||
static g_ident = 0;
|
||||
|
||||
void OnAmxxAttach()
|
||||
{
|
||||
MF_AddNatives(g_BaseSqlNatives);
|
||||
|
@ -9,15 +11,20 @@ void OnAmxxAttach()
|
|||
if (!MF_RequestFunction("GetDbDriver"))
|
||||
{
|
||||
MF_AddNatives(g_OldCompatNatives);
|
||||
MF_AddLibraries("dbi", LibType_Class, &g_ident);
|
||||
}
|
||||
}
|
||||
|
||||
void ServerDeactivate_Post()
|
||||
void OnAmxxDetach()
|
||||
{
|
||||
ShutdownThreading();
|
||||
MF_RemoveLibraries(&g_ident);
|
||||
}
|
||||
|
||||
void OnPluginsUnloaded()
|
||||
{
|
||||
FreeAllHandles(Handle_OldResult);
|
||||
FreeAllHandles(Handle_OldDb);
|
||||
FreeAllHandles(Handle_Connection);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ void *GetHandle(unsigned int num, HandleType type);
|
|||
bool FreeHandle(unsigned int num);
|
||||
void FreeAllHandles(HandleType type);
|
||||
void FreeHandleTable();
|
||||
void ShutdownThreading();
|
||||
|
||||
extern AMX_NATIVE_INFO g_BaseSqlNatives[];
|
||||
extern AMX_NATIVE_INFO g_ThreadSqlNatives[];
|
||||
|
|
|
@ -2430,7 +2430,9 @@ static amxx_module_info_s g_ModuleInfo =
|
|||
#else // MODULE_RELOAD_ON_MAPCHANGE
|
||||
0,
|
||||
#endif // MODULE_RELOAD_ON_MAPCHANGE
|
||||
MODULE_LOGTAG
|
||||
MODULE_LOGTAG,
|
||||
MODULE_LIBRARY,
|
||||
MODULE_LIBCLASS
|
||||
};
|
||||
|
||||
// Storage for the requested functions
|
||||
|
@ -2506,6 +2508,9 @@ PFN_SET_TEAM_INFO g_fn_SetTeamInfo;
|
|||
PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr;
|
||||
PFN_REG_AUTH_FUNC g_fn_RegAuthFunc;
|
||||
PFN_UNREG_AUTH_FUNC g_fn_UnregAuthFunc;
|
||||
PFN_FINDLIBRARY g_fn_FindLibrary;
|
||||
PFN_ADDLIBRARIES g_fn_AddLibraries;
|
||||
PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
|
||||
|
||||
// *** Exports ***
|
||||
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
||||
|
@ -2620,6 +2625,10 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||
REQFUNC("RegAuthFunc", g_fn_RegAuthFunc, PFN_REG_AUTH_FUNC);
|
||||
REQFUNC("UnregAuthFunc", g_fn_UnregAuthFunc, PFN_UNREG_AUTH_FUNC);
|
||||
|
||||
REQFUNC("FindLibrary", g_fn_FindLibrary, PFN_FINDLIBRARY);
|
||||
REQFUNC("AddLibraries", g_fn_AddLibraries, PFN_ADDLIBRARIES);
|
||||
REQFUNC("RemoveLibraries", g_fn_RemoveLibraries, PFN_REMOVELIBRARIES);
|
||||
|
||||
#ifdef MEMORY_TEST
|
||||
// Memory
|
||||
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
||||
|
@ -2654,6 +2663,20 @@ C_DLLEXPORT int AMXX_PluginsLoaded()
|
|||
return AMXX_OK;
|
||||
}
|
||||
|
||||
C_DLLEXPORT void AMXX_PluginsUnloaded()
|
||||
{
|
||||
#ifdef FN_AMXX_PLUGINSUNLOADED
|
||||
FN_AMXX_PLUGINSUNLOADED();
|
||||
#endif // FN_AMXX_PLUGINSUNLOADED
|
||||
}
|
||||
|
||||
C_DLLEXPORT void AMXX_PluginsUnloading()
|
||||
{
|
||||
#ifdef FN_AMXX_PLUGINSUNLOADING
|
||||
FN_AMXX_PLUGINSUNLOADING();
|
||||
#endif // FN_AMXX_PLUGINSUNLOADING
|
||||
}
|
||||
|
||||
// Advanced MF functions
|
||||
void MF_Log(const char *fmt, ...)
|
||||
{
|
||||
|
@ -2743,6 +2766,9 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||
MF_PlayerPropAddr(0, 0);
|
||||
MF_RegAuthFunc(NULL);
|
||||
MF_UnregAuthFunc(NULL);
|
||||
MF_FindLibrary(NULL, LibType_Class);
|
||||
MF_AddLibraries(NULL, LibType_Class, NULL);
|
||||
MF_RemoveLibraries(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
// module interface version was 1
|
||||
// 2 - added logtag to struct (amxx1.1-rc1)
|
||||
// 3 - added new tagAMX structure (amxx1.5)
|
||||
#define AMXX_INTERFACE_VERSION 3
|
||||
// 4 - added new 'library' setting for direct loading
|
||||
#define AMXX_INTERFACE_VERSION 4
|
||||
|
||||
// amxx module info
|
||||
struct amxx_module_info_s
|
||||
|
@ -44,6 +45,8 @@ struct amxx_module_info_s
|
|||
const char *version;
|
||||
int reload; // reload on mapchange when nonzero
|
||||
const char *logtag; // added in version 2
|
||||
const char *library; // added in version 4
|
||||
const char *libclass; // added in version 4
|
||||
};
|
||||
|
||||
// return values from functions called by amxx
|
||||
|
@ -2032,6 +2035,14 @@ void FN_AMXX_DETACH(void);
|
|||
void FN_AMXX_PLUGINSLOADED(void);
|
||||
#endif // FN_AMXX_PLUGINSLOADED
|
||||
|
||||
#ifdef FN_AMXX_PLUGINSUNLOADING
|
||||
void FN_AMXX_PLUGINSUNLOADING(void);
|
||||
#endif // FN_AMXX_PLUGINSUNLOADING
|
||||
|
||||
#ifdef FN_AMXX_PLUGINSUNLOADED
|
||||
void FN_AMXX_PLUGINSUNLOADED(void);
|
||||
#endif // FN_AMXX_PLUGINSUNLOADED
|
||||
|
||||
// *** Types ***
|
||||
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
|
||||
|
||||
|
@ -2078,6 +2089,12 @@ enum PlayerProp
|
|||
Player_NewmenuPage, //int
|
||||
};
|
||||
|
||||
enum LibType
|
||||
{
|
||||
LibType_Library,
|
||||
LibType_Class
|
||||
};
|
||||
|
||||
typedef void (*AUTHORIZEFUNC)(int player, const char *authstring);
|
||||
|
||||
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
|
||||
|
@ -2159,6 +2176,9 @@ typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/);
|
|||
typedef int (*PFN_SET_TEAM_INFO) (int /*player */, int /*teamid */, const char * /*name */);
|
||||
typedef void (*PFN_REG_AUTH_FUNC) (AUTHORIZEFUNC);
|
||||
typedef void (*PFN_UNREG_AUTH_FUNC) (AUTHORIZEFUNC);
|
||||
typedef int (*PFN_FINDLIBRARY) (const char * /*name*/, LibType /*type*/);
|
||||
typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/, void * /*parent*/);
|
||||
typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/);
|
||||
|
||||
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
||||
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||
|
@ -2226,6 +2246,9 @@ extern PFN_SET_TEAM_INFO g_fn_SetTeamInfo;
|
|||
extern PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr;
|
||||
extern PFN_REG_AUTH_FUNC g_fn_RegAuthFunc;
|
||||
extern PFN_UNREG_AUTH_FUNC g_fn_UnregAuthFunc;
|
||||
extern PFN_FINDLIBRARY g_fn_FindLibrary;
|
||||
extern PFN_ADDLIBRARIES g_fn_AddLibraries;
|
||||
extern PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
|
||||
|
||||
#ifdef MAY_NEVER_BE_DEFINED
|
||||
// Function prototypes for intellisense and similar systems
|
||||
|
@ -2290,6 +2313,9 @@ int MF_SetPlayerTeamInfo (int id, int teamid, const char *teamname) { }
|
|||
void * MF_PlayerPropAddr (int id, int prop) { }
|
||||
void MF_RegAuthFunc (AUTHORIZEFUNC fn) { }
|
||||
void MF_UnregAuthFunc (AUTHORIZEFUNC fn) { }
|
||||
int MF_FindLibrary (const char *name, LibType type) { }
|
||||
size_t MF_AddLibraries (const char *name, LibType type, void *parent) { }
|
||||
size_t MF_RemoveLibraries (void *parent) { }
|
||||
#endif // MAY_NEVER_BE_DEFINED
|
||||
|
||||
#define MF_AddNatives g_fn_AddNatives
|
||||
|
@ -2359,6 +2385,9 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
|
|||
#define MF_PlayerPropAddr g_fn_PlayerPropAddr
|
||||
#define MF_RegAuthFunc g_fn_RegAuthFunc
|
||||
#define MF_UnregAuthFunc g_fn_UnregAuthFunc
|
||||
#define MF_FindLibrary g_fn_FindLibrary;
|
||||
#define MF_AddLibraries g_fn_AddLibraries;
|
||||
#define MF_RemoveLibraries g_fn_RemoveLibraries;
|
||||
|
||||
#ifdef MEMORY_TEST
|
||||
/*** Memory ***/
|
||||
|
|
|
@ -3,14 +3,26 @@
|
|||
#ifndef __MODULECONFIG_H__
|
||||
#define __MODULECONFIG_H__
|
||||
|
||||
// Module info
|
||||
#define MODULE_NAME "MySQL X"
|
||||
#define MODULE_VERSION "1.01"
|
||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org/"
|
||||
#define MODULE_LOGTAG "SQLX"
|
||||
/** Module info
|
||||
* -The logtag is the tag that the module's log messages will be
|
||||
* prepended with.
|
||||
* -The library is the name that the #pragma library
|
||||
* message will have prepended.
|
||||
* -The library class is the class of libraries that
|
||||
* a module belongs to (like DBI). Keep it "" to
|
||||
* ignore.
|
||||
* -For both library and library class, you can use a comma
|
||||
* to add multiple entries.
|
||||
*/
|
||||
#define MODULE_NAME "MySQLX"
|
||||
#define MODULE_VERSION "1.75"
|
||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org/"
|
||||
#define MODULE_LOGTAG "MySQLX"
|
||||
#define MODULE_LIBRARY "mysqlx"
|
||||
#define MODULE_LIBCLASS "sqlx"
|
||||
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
|
||||
//#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
|
||||
#ifdef __DATE__
|
||||
#define MODULE_DATE __DATE__
|
||||
|
@ -34,18 +46,32 @@
|
|||
// Uncomment this if you are using MSVC8 or greater and want to fix some of the compatibility issues yourself
|
||||
// #define NO_MSVC8_AUTO_COMPAT
|
||||
|
||||
// - AMXX Init functions
|
||||
// Also consider using FN_META_*
|
||||
// AMXX query
|
||||
/**
|
||||
* AMXX Init functions
|
||||
* Also consider using FN_META_*
|
||||
*/
|
||||
|
||||
/** AMXX query */
|
||||
//#define FN_AMXX_QUERY OnAmxxQuery
|
||||
// AMXX attach
|
||||
// Do native functions init here (MF_AddNatives)
|
||||
|
||||
/** AMXX attach
|
||||
* Do native functions init here (MF_AddNatives)
|
||||
*/
|
||||
#define FN_AMXX_ATTACH OnAmxxAttach
|
||||
// AMXX detach
|
||||
|
||||
/** AMXX Detach (unload) */
|
||||
#define FN_AMXX_DETACH OnAmxxDetach
|
||||
// All plugins loaded
|
||||
// Do forward functions init here (MF_RegisterForward)
|
||||
// #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
|
||||
/** All plugins loaded
|
||||
* Do forward functions init here (MF_RegisterForward)
|
||||
*/
|
||||
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
|
||||
/** All plugins are about to be unloaded */
|
||||
#define FN_AMXX_PLUGINSUNLOADING OnPluginsUnloading
|
||||
|
||||
/** All plguins are now unloaded */
|
||||
#define FN_AMXX_PLUGINSUNLOADED OnPluginsUnloaded
|
||||
|
||||
/**** METAMOD ****/
|
||||
// If your module doesn't use metamod, you may close the file now :)
|
||||
|
@ -67,7 +93,7 @@
|
|||
// (wd) are Will Day's notes
|
||||
// - GetEntityAPI2 functions
|
||||
// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */
|
||||
#define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
|
||||
// #define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
|
||||
// #define FN_DispatchThink DispatchThink /* pfnThink() */
|
||||
// #define FN_DispatchUse DispatchUse /* pfnUse() */
|
||||
// #define FN_DispatchTouch DispatchTouch /* pfnTouch() */
|
||||
|
@ -88,10 +114,10 @@
|
|||
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
|
||||
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
|
||||
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
|
||||
#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
||||
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
||||
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
||||
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
||||
#define FN_StartFrame StartFrame /* pfnStartFrame() */
|
||||
#define FN_StartFrame StartFrame /* pfnStartFrame() */
|
||||
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
|
||||
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
|
||||
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
|
||||
|
@ -140,7 +166,7 @@
|
|||
// #define FN_ClientCommand_Post ClientCommand_Post
|
||||
// #define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post
|
||||
// #define FN_ServerActivate_Post ServerActivate_Post
|
||||
#define FN_ServerDeactivate_Post ServerDeactivate_Post
|
||||
// #define FN_ServerDeactivate_Post ServerDeactivate_Post
|
||||
// #define FN_PlayerPreThink_Post PlayerPreThink_Post
|
||||
// #define FN_PlayerPostThink_Post PlayerPostThink_Post
|
||||
// #define FN_StartFrame_Post StartFrame_Post
|
||||
|
|
|
@ -14,7 +14,7 @@ CStack<MysqlThread *> g_ThreadQueue;
|
|||
CStack<MysqlThread *> g_FreeThreads;
|
||||
float g_lasttime = 0.0f;
|
||||
|
||||
void OnAmxxDetach()
|
||||
void ShutdownThreading()
|
||||
{
|
||||
if (g_pWorker)
|
||||
{
|
||||
|
@ -257,11 +257,11 @@ void MysqlThread::Execute()
|
|||
* METAMOD STUFF *
|
||||
*****************/
|
||||
|
||||
int DispatchSpawn(edict_t *pEnt)
|
||||
void OnPluginsLoaded()
|
||||
{
|
||||
if (g_pWorker)
|
||||
{
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_StringPool.IsThreadable())
|
||||
|
@ -279,7 +279,7 @@ int DispatchSpawn(edict_t *pEnt)
|
|||
|
||||
g_lasttime = 0.0f;
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
void StartFrame()
|
||||
|
@ -310,18 +310,14 @@ void StartFrame()
|
|||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ServerDeactivate()
|
||||
void OnPluginsUnloading()
|
||||
{
|
||||
g_pFunctionTable->pfnSpawn = DispatchSpawn;
|
||||
|
||||
if (!g_pWorker)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
return;
|
||||
|
||||
g_pWorker->Stop(false);
|
||||
delete g_pWorker;
|
||||
g_pWorker = NULL;
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
/***********************
|
||||
|
|
Loading…
Reference in New Issue
Block a user