Added amx_ReRegister() and MNF_RegisterFunctionEx()
This commit is contained in:
parent
f9c9088303
commit
bce3bce586
|
@ -1481,6 +1481,36 @@ int AMXAPI amx_RegisterToAny(AMX *amx, AMX_NATIVE f)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AMXAPI amx_Reregister(AMX *amx, const AMX_NATIVE_INFO *list, int number)
|
||||||
|
{
|
||||||
|
AMX_FUNCSTUB *func;
|
||||||
|
AMX_HEADER *hdr;
|
||||||
|
int i,numnatives,count=0;
|
||||||
|
AMX_NATIVE funcptr;
|
||||||
|
|
||||||
|
hdr=(AMX_HEADER *)amx->base;
|
||||||
|
assert(hdr!=NULL);
|
||||||
|
assert(hdr->magic==AMX_MAGIC);
|
||||||
|
assert(hdr->natives<=hdr->libraries);
|
||||||
|
numnatives=NUMENTRIES(hdr,natives,libraries);
|
||||||
|
|
||||||
|
count=0;
|
||||||
|
func=GETENTRY(hdr,natives,0);
|
||||||
|
for (i=0; i<numnatives; i++) {
|
||||||
|
if (func->address!=0) {
|
||||||
|
/* this function is located */
|
||||||
|
funcptr=(list!=NULL) ? findfunction(GETENTRYNAME(hdr,func),list,number) : NULL;
|
||||||
|
if (funcptr!=NULL)
|
||||||
|
{
|
||||||
|
func->address=(ucell)funcptr;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} /* if */
|
||||||
|
func=(AMX_FUNCSTUB*)((unsigned char*)func+hdr->defsize);
|
||||||
|
} /* for */
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *list, int number)
|
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *list, int number)
|
||||||
{
|
{
|
||||||
AMX_FUNCSTUB *func;
|
AMX_FUNCSTUB *func;
|
||||||
|
|
|
@ -410,6 +410,7 @@ int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell
|
||||||
int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
|
int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
|
||||||
int AMXAPI amx_RaiseError(AMX *amx, int error);
|
int AMXAPI amx_RaiseError(AMX *amx, int error);
|
||||||
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
|
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
|
||||||
|
int AMXAPI amx_Reregister(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
|
||||||
int AMXAPI amx_RegisterToAny(AMX *amx, AMX_NATIVE f);
|
int AMXAPI amx_RegisterToAny(AMX *amx, AMX_NATIVE f);
|
||||||
int AMXAPI amx_Release(AMX *amx, cell amx_addr);
|
int AMXAPI amx_Release(AMX *amx, cell amx_addr);
|
||||||
int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
|
int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
|
||||||
|
|
|
@ -1647,6 +1647,25 @@ void MNF_RegisterFunction(void *pfn, const char *description)
|
||||||
REGISTER_FUNC(description, pfn);
|
REGISTER_FUNC(description, pfn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *MNF_RegisterFunctionEx(void *pfn, const char *description)
|
||||||
|
{
|
||||||
|
func_s *pFunc;
|
||||||
|
CList<func_s, const char *>::iterator iter;
|
||||||
|
|
||||||
|
for (iter = g_functions.begin(); iter; ++iter)
|
||||||
|
{
|
||||||
|
pFunc = &(*iter);
|
||||||
|
if (strcmp(description, pFunc->desc) == 0)
|
||||||
|
{
|
||||||
|
void *pOld = pFunc->pfn;
|
||||||
|
pFunc->pfn = pfn;
|
||||||
|
return pOld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void Module_UncacheFunctions()
|
void Module_UncacheFunctions()
|
||||||
{
|
{
|
||||||
g_functions.clear();
|
g_functions.clear();
|
||||||
|
@ -1746,6 +1765,7 @@ void Module_CacheFunctions()
|
||||||
REGISTER_FUNC("MergeDefinitionFile", MNF_MergeDefinitionFile)
|
REGISTER_FUNC("MergeDefinitionFile", MNF_MergeDefinitionFile)
|
||||||
REGISTER_FUNC("Format", MNF_Format)
|
REGISTER_FUNC("Format", MNF_Format)
|
||||||
REGISTER_FUNC("RegisterFunction", MNF_RegisterFunction);
|
REGISTER_FUNC("RegisterFunction", MNF_RegisterFunction);
|
||||||
|
REGISTER_FUNC("RegisterFunctionEx", MNF_RegisterFunctionEx);
|
||||||
|
|
||||||
// Amx scripts loading / unloading / managing
|
// Amx scripts loading / unloading / managing
|
||||||
REGISTER_FUNC("GetAmxScript", MNF_GetAmxScript)
|
REGISTER_FUNC("GetAmxScript", MNF_GetAmxScript)
|
||||||
|
@ -1762,6 +1782,7 @@ void Module_CacheFunctions()
|
||||||
REGISTER_FUNC("FormatAmxString", MNF_FormatAmxString)
|
REGISTER_FUNC("FormatAmxString", MNF_FormatAmxString)
|
||||||
REGISTER_FUNC("CopyAmxMemory", MNF_CopyAmxMemory)
|
REGISTER_FUNC("CopyAmxMemory", MNF_CopyAmxMemory)
|
||||||
REGISTER_FUNC("GetAmxAddr", get_amxaddr)
|
REGISTER_FUNC("GetAmxAddr", get_amxaddr)
|
||||||
|
REGISTER_FUNC("AmxReregister", amx_Reregister);
|
||||||
|
|
||||||
// other amx stuff
|
// other amx stuff
|
||||||
REGISTER_FUNC("amx_Exec", amx_Exec)
|
REGISTER_FUNC("amx_Exec", amx_Exec)
|
||||||
|
|
|
@ -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_AMXREREGISTER 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 ***/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user