added affinity implementation
This commit is contained in:
parent
9bbb0df492
commit
f9c9088303
|
@ -1,6 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "sh_list.h"
|
#include "sh_list.h"
|
||||||
#include "mysql2_header.h"
|
#include "mysql2_header.h"
|
||||||
|
#include "sqlheaders.h"
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
|
@ -314,7 +315,6 @@ static cell AMX_NATIVE_CALL SQL_NumResults(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (!rs)
|
if (!rs)
|
||||||
{
|
{
|
||||||
MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,6 +398,34 @@ static cell AMX_NATIVE_CALL SQL_FieldNameToNum(AMX *amx, cell *params)
|
||||||
return columnId;
|
return columnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL SQL_GetAffinity(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return MF_SetAmxString(amx, params[1], g_Mysql.NameString(), params[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL SQL_SetAffinity(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *str = MF_GetAmxString(amx, params[1], 0, &len);
|
||||||
|
|
||||||
|
if (stricmp(str, g_Mysql.NameString()) == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SqlFunctions *pFuncs = (SqlFunctions *)MF_RequestFunction(SQL_DRIVER_FUNC);
|
||||||
|
while (pFuncs)
|
||||||
|
{
|
||||||
|
if (pFuncs->driver->IsCompatDriver(str))
|
||||||
|
{
|
||||||
|
return pFuncs->set_affinity(amx);
|
||||||
|
}
|
||||||
|
pFuncs = pFuncs->prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
extern AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
||||||
{
|
{
|
||||||
{"SQL_MakeDbTuple", SQL_MakeDbTuple},
|
{"SQL_MakeDbTuple", SQL_MakeDbTuple},
|
||||||
|
@ -415,6 +443,8 @@ extern AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
||||||
{"SQL_NumColumns", SQL_NumColumns},
|
{"SQL_NumColumns", SQL_NumColumns},
|
||||||
{"SQL_FieldNumToName", SQL_FieldNumToName},
|
{"SQL_FieldNumToName", SQL_FieldNumToName},
|
||||||
{"SQL_FieldNameToNum", SQL_FieldNameToNum},
|
{"SQL_FieldNameToNum", SQL_FieldNameToNum},
|
||||||
|
{"SQL_GetAffinity", SQL_GetAffinity},
|
||||||
|
{"SQL_SetAffinity", SQL_SetAffinity},
|
||||||
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,13 +1,29 @@
|
||||||
#include "amxxmodule.h"
|
#include "amxxmodule.h"
|
||||||
#include "mysql2_header.h"
|
#include "mysql2_header.h"
|
||||||
|
#include "sqlheaders.h"
|
||||||
|
|
||||||
static g_ident = 0;
|
static g_ident = 0;
|
||||||
|
|
||||||
|
SqlFunctions g_MysqlFuncs =
|
||||||
|
{
|
||||||
|
&g_Mysql,
|
||||||
|
SetMysqlAffinity,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
int SetMysqlAffinity(AMX *amx)
|
||||||
|
{
|
||||||
|
MF_AmxReRegister(amx, g_BaseSqlNatives, -1);
|
||||||
|
MF_AmxReRegister(amx, g_ThreadSqlNatives, -1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void OnAmxxAttach()
|
void OnAmxxAttach()
|
||||||
{
|
{
|
||||||
MF_AddNatives(g_BaseSqlNatives);
|
MF_AddNatives(g_BaseSqlNatives);
|
||||||
MF_AddNatives(g_ThreadSqlNatives);
|
MF_AddNatives(g_ThreadSqlNatives);
|
||||||
MF_RegisterFunction(&g_Mysql, "GetSqlDriver");
|
g_MysqlFuncs.prev = (SqlFunctions *)MF_RegisterFunctionEx(&g_MysqlFuncs, SQL_DRIVER_FUNC);
|
||||||
if (!MF_RequestFunction("GetDbDriver") && !MF_FindLibrary("SQLITE", LibType_Library))
|
if (!MF_RequestFunction("GetDbDriver") && !MF_FindLibrary("SQLITE", LibType_Library))
|
||||||
{
|
{
|
||||||
MF_AddNatives(g_OldCompatNatives);
|
MF_AddNatives(g_OldCompatNatives);
|
||||||
|
|
|
@ -251,6 +251,9 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\sdk\sh_stack.h">
|
RelativePath=".\sdk\sh_stack.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\sqlheaders.h">
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
|
|
|
@ -42,6 +42,7 @@ bool FreeHandle(unsigned int num);
|
||||||
void FreeAllHandles(HandleType type);
|
void FreeAllHandles(HandleType type);
|
||||||
void FreeHandleTable();
|
void FreeHandleTable();
|
||||||
void ShutdownThreading();
|
void ShutdownThreading();
|
||||||
|
int SetMysqlAffinity(AMX *amx);
|
||||||
|
|
||||||
extern AMX_NATIVE_INFO g_BaseSqlNatives[];
|
extern AMX_NATIVE_INFO g_BaseSqlNatives[];
|
||||||
extern AMX_NATIVE_INFO g_ThreadSqlNatives[];
|
extern AMX_NATIVE_INFO g_ThreadSqlNatives[];
|
||||||
|
|
|
@ -2513,6 +2513,8 @@ PFN_ADDLIBRARIES g_fn_AddLibraries;
|
||||||
PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
|
PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
|
||||||
PFN_OVERRIDENATIVES g_fn_OverrideNatives;
|
PFN_OVERRIDENATIVES g_fn_OverrideNatives;
|
||||||
PFN_GETLOCALINFO g_fn_GetLocalInfo;
|
PFN_GETLOCALINFO g_fn_GetLocalInfo;
|
||||||
|
PFN_AMX_REREGISTER g_fn_AmxReRegister;
|
||||||
|
PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
|
||||||
|
|
||||||
// *** Exports ***
|
// *** Exports ***
|
||||||
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
||||||
|
@ -2563,6 +2565,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
||||||
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
|
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
|
||||||
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
|
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
|
||||||
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
|
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
|
||||||
|
REQFUNC("RegisterFunctionEx", g_fn_RegisterFunctionEx, PFN_REGISTERFUNCTIONEX);
|
||||||
|
|
||||||
// Amx scripts
|
// Amx scripts
|
||||||
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
|
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
|
||||||
|
@ -2627,11 +2630,13 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
||||||
REQFUNC("RegAuthFunc", g_fn_RegAuthFunc, PFN_REG_AUTH_FUNC);
|
REQFUNC("RegAuthFunc", g_fn_RegAuthFunc, PFN_REG_AUTH_FUNC);
|
||||||
REQFUNC("UnregAuthFunc", g_fn_UnregAuthFunc, PFN_UNREG_AUTH_FUNC);
|
REQFUNC("UnregAuthFunc", g_fn_UnregAuthFunc, PFN_UNREG_AUTH_FUNC);
|
||||||
|
|
||||||
|
//Added in 1.75
|
||||||
REQFUNC("FindLibrary", g_fn_FindLibrary, PFN_FINDLIBRARY);
|
REQFUNC("FindLibrary", g_fn_FindLibrary, PFN_FINDLIBRARY);
|
||||||
REQFUNC("AddLibraries", g_fn_AddLibraries, PFN_ADDLIBRARIES);
|
REQFUNC("AddLibraries", g_fn_AddLibraries, PFN_ADDLIBRARIES);
|
||||||
REQFUNC("RemoveLibraries", g_fn_RemoveLibraries, PFN_REMOVELIBRARIES);
|
REQFUNC("RemoveLibraries", g_fn_RemoveLibraries, PFN_REMOVELIBRARIES);
|
||||||
REQFUNC("OverrideNatives", g_fn_OverrideNatives, PFN_OVERRIDENATIVES);
|
REQFUNC("OverrideNatives", g_fn_OverrideNatives, PFN_OVERRIDENATIVES);
|
||||||
REQFUNC("GetLocalInfo", g_fn_GetLocalInfo, PFN_GETLOCALINFO);
|
REQFUNC("GetLocalInfo", g_fn_GetLocalInfo, PFN_GETLOCALINFO);
|
||||||
|
REQFUNC("AmxReregister", g_fn_AmxReRegister, PFN_AMX_REREGISTER);
|
||||||
|
|
||||||
#ifdef MEMORY_TEST
|
#ifdef MEMORY_TEST
|
||||||
// Memory
|
// Memory
|
||||||
|
@ -2766,6 +2771,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
||||||
MF_GetPlayerEdict(0);
|
MF_GetPlayerEdict(0);
|
||||||
MF_Format("", 4, "str");
|
MF_Format("", 4, "str");
|
||||||
MF_RegisterFunction(NULL, "");
|
MF_RegisterFunction(NULL, "");
|
||||||
|
MF_RegisterFunctionEx(NULL, "");
|
||||||
MF_SetPlayerTeamInfo(0, 0, "");
|
MF_SetPlayerTeamInfo(0, 0, "");
|
||||||
MF_PlayerPropAddr(0, 0);
|
MF_PlayerPropAddr(0, 0);
|
||||||
MF_RegAuthFunc(NULL);
|
MF_RegAuthFunc(NULL);
|
||||||
|
|
|
@ -2181,6 +2181,8 @@ typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/
|
||||||
typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/);
|
typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/);
|
||||||
typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/);
|
typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/);
|
||||||
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
|
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
|
||||||
|
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
|
||||||
|
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
|
||||||
|
|
||||||
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
||||||
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||||
|
@ -2253,6 +2255,8 @@ extern PFN_ADDLIBRARIES g_fn_AddLibraries;
|
||||||
extern PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
|
extern PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
|
||||||
extern PFN_OVERRIDENATIVES g_fn_OverrideNatives;
|
extern PFN_OVERRIDENATIVES g_fn_OverrideNatives;
|
||||||
extern PFN_GETLOCALINFO g_fn_GetLocalInfo;
|
extern PFN_GETLOCALINFO g_fn_GetLocalInfo;
|
||||||
|
extern PFN_AMX_REREGISTER g_fn_AmxReRegister;
|
||||||
|
extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
|
||||||
|
|
||||||
#ifdef MAY_NEVER_BE_DEFINED
|
#ifdef MAY_NEVER_BE_DEFINED
|
||||||
// Function prototypes for intellisense and similar systems
|
// Function prototypes for intellisense and similar systems
|
||||||
|
@ -2322,6 +2326,8 @@ size_t MF_AddLibraries (const char *name, LibType type, void *parent) { }
|
||||||
size_t MF_RemoveLibraries (void *parent) { }
|
size_t MF_RemoveLibraries (void *parent) { }
|
||||||
void MF_OverrideNatives (AMX_NATIVE_INFO *natives) { }
|
void MF_OverrideNatives (AMX_NATIVE_INFO *natives) { }
|
||||||
const char * MF_GetLocalInfo (const char *name, const char *def) { }
|
const char * MF_GetLocalInfo (const char *name, const char *def) { }
|
||||||
|
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
|
||||||
|
void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
|
||||||
#endif // MAY_NEVER_BE_DEFINED
|
#endif // MAY_NEVER_BE_DEFINED
|
||||||
|
|
||||||
#define MF_AddNatives g_fn_AddNatives
|
#define MF_AddNatives g_fn_AddNatives
|
||||||
|
@ -2396,6 +2402,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
|
||||||
#define MF_RemoveLibraries g_fn_RemoveLibraries
|
#define MF_RemoveLibraries g_fn_RemoveLibraries
|
||||||
#define MF_OverrideNatives g_fn_OverrideNatives
|
#define MF_OverrideNatives g_fn_OverrideNatives
|
||||||
#define MF_GetLocalInfo g_fn_GetLocalInfo
|
#define MF_GetLocalInfo g_fn_GetLocalInfo
|
||||||
|
#define MF_AmxReRegister g_fn_AmxReRegister
|
||||||
|
#define MF_RegisterFunctionEx g_fn_RegisterFunctionEx
|
||||||
|
|
||||||
#ifdef MEMORY_TEST
|
#ifdef MEMORY_TEST
|
||||||
/*** Memory ***/
|
/*** Memory ***/
|
||||||
|
|
17
dlls/mysqlx/sqlheaders.h
Normal file
17
dlls/mysqlx/sqlheaders.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef _INCLUDE_SQLHEADERS_H
|
||||||
|
#define _INCLUDE_SQLHEADERS_H
|
||||||
|
|
||||||
|
#include "ISQLDriver.h"
|
||||||
|
|
||||||
|
#define SQL_DRIVER_FUNC "GetSqlFuncs"
|
||||||
|
|
||||||
|
typedef int (*SQLAFFINITY)(AMX *amx);
|
||||||
|
|
||||||
|
struct SqlFunctions
|
||||||
|
{
|
||||||
|
SourceMod::ISQLDriver *driver;
|
||||||
|
SQLAFFINITY set_affinity;
|
||||||
|
SqlFunctions *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_INCLUDE_SQLHEADERS_H
|
|
@ -284,7 +284,7 @@ void OnPluginsLoaded()
|
||||||
|
|
||||||
void StartFrame()
|
void StartFrame()
|
||||||
{
|
{
|
||||||
if (g_lasttime < gpGlobals->time)
|
if (g_pWorker && (g_lasttime < gpGlobals->time))
|
||||||
{
|
{
|
||||||
g_lasttime = gpGlobals->time + 0.3f;
|
g_lasttime = gpGlobals->time + 0.3f;
|
||||||
g_QueueLock->Lock();
|
g_QueueLock->Lock();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user