mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Fixed module correction output
This commit is contained in:
parent
59880371e1
commit
b8721e0123
@ -1576,6 +1576,7 @@ static AMX_NATIVE findfunction(const char *name, AMX_NATIVE_INFO *list, int numb
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *no_function; // PM: Nice hack ;)
|
const char *no_function; // PM: Nice hack ;)
|
||||||
|
int no_module_test;
|
||||||
int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
||||||
{
|
{
|
||||||
AMX_FUNCSTUB *func;
|
AMX_FUNCSTUB *func;
|
||||||
@ -1607,6 +1608,38 @@ int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
|||||||
} /* for */
|
} /* for */
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL null_native(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void amx_NullNativeTable(AMX *amx)
|
||||||
|
{
|
||||||
|
AMX_FUNCSTUB *func;
|
||||||
|
AMX_HEADER *hdr;
|
||||||
|
int i, numnatives;
|
||||||
|
|
||||||
|
hdr=(AMX_HEADER *)amx->base;
|
||||||
|
if (hdr == NULL)
|
||||||
|
return;
|
||||||
|
if (hdr->magic!=AMX_MAGIC)
|
||||||
|
return;
|
||||||
|
|
||||||
|
numnatives = NUMENTRIES(hdr, natives, libraries);
|
||||||
|
|
||||||
|
func=GETENTRY(hdr, natives, 0);
|
||||||
|
|
||||||
|
for (i=0; i<numnatives; i++)
|
||||||
|
{
|
||||||
|
if (func->address == 0)
|
||||||
|
{
|
||||||
|
func->address = (ucell)null_native;
|
||||||
|
}
|
||||||
|
func=(AMX_FUNCSTUB*)((unsigned char*)func+hdr->defsize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* AMX_REGISTER || AMX_EXEC || AMX_INIT */
|
#endif /* AMX_REGISTER || AMX_EXEC || AMX_INIT */
|
||||||
|
|
||||||
#if defined AMX_NATIVEINFO
|
#if defined AMX_NATIVEINFO
|
||||||
@ -2800,7 +2833,9 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index, int numparams, ...)
|
|||||||
if (amx->callback==NULL)
|
if (amx->callback==NULL)
|
||||||
return AMX_ERR_CALLBACK;
|
return AMX_ERR_CALLBACK;
|
||||||
i=amx_Register(amx,NULL,0); /* verify that all natives are registered */
|
i=amx_Register(amx,NULL,0); /* verify that all natives are registered */
|
||||||
if (i!=AMX_ERR_NONE)
|
//HACKHACK - still execute if doing a module test!
|
||||||
|
// this WILL cause a crash if bad natives are used....
|
||||||
|
if (i!=AMX_ERR_NONE && !no_module_test)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
if ((amx->flags & AMX_FLAG_RELOC)==0)
|
if ((amx->flags & AMX_FLAG_RELOC)==0)
|
||||||
|
@ -382,7 +382,7 @@ int AMXAPI amx_StrLen(cell *cstring, int *length);
|
|||||||
int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value);
|
int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value);
|
||||||
int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value);
|
int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value);
|
||||||
int AMXAPI amx_UTF8Check(const char *string);
|
int AMXAPI amx_UTF8Check(const char *string);
|
||||||
|
void amx_NullNativeTable(AMX *amx);
|
||||||
|
|
||||||
#if !defined AMX_NO_ALIGN
|
#if !defined AMX_NO_ALIGN
|
||||||
#if defined __linux__
|
#if defined __linux__
|
||||||
|
@ -2473,7 +2473,7 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
|
|||||||
|
|
||||||
// native callfunc_push_int(value);
|
// native callfunc_push_int(value);
|
||||||
// native callfunc_push_float(Float: value);
|
// native callfunc_push_float(Float: value);
|
||||||
static cell callfunc_push_byval(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL callfunc_push_byval(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
|
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
|
||||||
if (!g_CallFunc_Plugin)
|
if (!g_CallFunc_Plugin)
|
||||||
@ -2499,7 +2499,7 @@ static cell callfunc_push_byval(AMX *amx, cell *params)
|
|||||||
|
|
||||||
// native callfunc_push_intref(&value);
|
// native callfunc_push_intref(&value);
|
||||||
// native callfunc_push_floatref(Float: &value);
|
// native callfunc_push_floatref(Float: &value);
|
||||||
static cell callfunc_push_byref(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL callfunc_push_byref(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
|
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
|
||||||
if (!g_CallFunc_Plugin)
|
if (!g_CallFunc_Plugin)
|
||||||
@ -2557,7 +2557,7 @@ static cell callfunc_push_byref(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// native callfunc_push_str(value[]);
|
// native callfunc_push_str(value[]);
|
||||||
static cell callfunc_push_str(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
|
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
|
||||||
if (!g_CallFunc_Plugin)
|
if (!g_CallFunc_Plugin)
|
||||||
@ -2618,20 +2618,20 @@ static cell callfunc_push_str(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get_langsnum();
|
// get_langsnum();
|
||||||
static cell get_langsnum(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL get_langsnum(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
return g_langMngr.GetLangsNum();
|
return g_langMngr.GetLangsNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_lang(id, name[(at least 3)]);
|
// get_lang(id, name[(at least 3)]);
|
||||||
static cell get_lang(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL get_lang(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
set_amxstring(amx, params[2], g_langMngr.GetLangName(params[1]), 2);
|
set_amxstring(amx, params[2], g_langMngr.GetLangName(params[1]), 2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// register_dictionary(const filename[]);
|
// register_dictionary(const filename[]);
|
||||||
static cell register_dictionary(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL register_dictionary(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int result = g_langMngr.MergeDefinitionFile(build_pathname("%s/lang/%s",
|
int result = g_langMngr.MergeDefinitionFile(build_pathname("%s/lang/%s",
|
||||||
@ -2639,7 +2639,7 @@ static cell register_dictionary(AMX *amx, cell *params)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell plugin_flags(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL plugin_flags(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
AMX_HEADER *hdr;
|
AMX_HEADER *hdr;
|
||||||
hdr = (AMX_HEADER *)amx->base;
|
hdr = (AMX_HEADER *)amx->base;
|
||||||
@ -2647,13 +2647,13 @@ static cell plugin_flags(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lang_exists(const name[]);
|
// lang_exists(const name[]);
|
||||||
static cell lang_exists(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL lang_exists(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
return g_langMngr.LangExists(get_amxstring(amx, params[1], 1, len)) ? 1 : 0;
|
return g_langMngr.LangExists(get_amxstring(amx, params[1], 1, len)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell register_module(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL register_module(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
|
@ -254,6 +254,7 @@ void* alloc_amxmemory(void**, int size);
|
|||||||
void free_amxmemory(void **ptr);
|
void free_amxmemory(void **ptr);
|
||||||
// get_localinfo
|
// get_localinfo
|
||||||
const char* get_localinfo( const char* name , const char* def );
|
const char* get_localinfo( const char* name , const char* def );
|
||||||
|
static cell AMX_NATIVE_CALL null_native(AMX *amx, cell *params);
|
||||||
|
|
||||||
enum ModuleCallReason
|
enum ModuleCallReason
|
||||||
{
|
{
|
||||||
@ -267,6 +268,7 @@ extern ModuleCallReason g_ModuleCallReason; // modules.cpp
|
|||||||
extern CModule *g_CurrentlyCalledModule; // modules.cpp
|
extern CModule *g_CurrentlyCalledModule; // modules.cpp
|
||||||
extern const char *g_LastRequestedFunc; // modules.cpp
|
extern const char *g_LastRequestedFunc; // modules.cpp
|
||||||
extern CQueue<String> CurModuleList;
|
extern CQueue<String> CurModuleList;
|
||||||
|
extern int no_module_test;
|
||||||
|
|
||||||
void *Module_ReqFnptr(const char *funcName); // modules.cpp
|
void *Module_ReqFnptr(const char *funcName); // modules.cpp
|
||||||
|
|
||||||
|
@ -266,7 +266,9 @@ int C_Spawn( edict_t *pent ) {
|
|||||||
memset(g_players[0].flags,-1,sizeof(g_players[0].flags));
|
memset(g_players[0].flags,-1,sizeof(g_players[0].flags));
|
||||||
|
|
||||||
// ###### Load AMX scripts
|
// ###### Load AMX scripts
|
||||||
|
no_module_test = 0;
|
||||||
g_plugins.loadPluginsFromFile( get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini") );
|
g_plugins.loadPluginsFromFile( get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini") );
|
||||||
|
no_module_test = 0;
|
||||||
|
|
||||||
// Register forwards
|
// Register forwards
|
||||||
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
|
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
|
||||||
@ -446,6 +448,7 @@ void C_ServerDeactivate_Post() {
|
|||||||
// pft that's not really a hack
|
// pft that's not really a hack
|
||||||
g_FakeMeta.m_Plugins.begin()->GetDllFuncTable().pfnSpawn = C_Spawn;
|
g_FakeMeta.m_Plugins.begin()->GetDllFuncTable().pfnSpawn = C_Spawn;
|
||||||
|
|
||||||
|
no_module_test = 0;
|
||||||
detachReloadModules();
|
detachReloadModules();
|
||||||
g_auth.clear();
|
g_auth.clear();
|
||||||
g_forwards.clear();
|
g_forwards.clear();
|
||||||
|
@ -222,6 +222,7 @@ int CheckModules(AMX *amx, char error[64])
|
|||||||
{
|
{
|
||||||
cell retVal = 0;
|
cell retVal = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
no_module_test = 1;
|
||||||
if ( (err = amx_Exec(amx, &retVal, idx, 0)) == AMX_ERR_NONE )
|
if ( (err = amx_Exec(amx, &retVal, idx, 0)) == AMX_ERR_NONE )
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
@ -261,9 +262,11 @@ int CheckModules(AMX *amx, char error[64])
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AMXXLOG_Log("[AMXX] Run time error %d on line %ld during module check.", err, amx->curline);
|
AMXXLOG_Log("[AMXX] Run time error %d on line %ld during module check.", err, amx->curline);
|
||||||
|
no_module_test = 0;
|
||||||
//could not execute
|
//could not execute
|
||||||
return -1; //bad! very bad!
|
return -1; //bad! very bad!
|
||||||
}
|
}
|
||||||
|
no_module_test = 0;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -292,7 +295,9 @@ int set_amxnatives(AMX* amx,char error[64])
|
|||||||
{
|
{
|
||||||
if (CheckModules(amx, error) == -1)
|
if (CheckModules(amx, error) == -1)
|
||||||
{
|
{
|
||||||
//HACKHACK
|
//HACKHACK - if we get here, nullify the plugin's native table
|
||||||
|
// - BAILOPAN
|
||||||
|
amx_NullNativeTable(amx);
|
||||||
sprintf(error,"Plugin uses an unknown function (name \"%s\") - check your modules.ini.",no_function);
|
sprintf(error,"Plugin uses an unknown function (name \"%s\") - check your modules.ini.",no_function);
|
||||||
}
|
}
|
||||||
return (amx->error = AMX_ERR_NATIVE);
|
return (amx->error = AMX_ERR_NATIVE);
|
||||||
|
Loading…
Reference in New Issue
Block a user