Fixed module correction output

This commit is contained in:
David Anderson 2004-09-09 06:04:50 +00:00
parent 59880371e1
commit b8721e0123
6 changed files with 57 additions and 12 deletions

View File

@ -1576,6 +1576,7 @@ static AMX_NATIVE findfunction(const char *name, AMX_NATIVE_INFO *list, int numb
}
const char *no_function; // PM: Nice hack ;)
int no_module_test;
int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
{
AMX_FUNCSTUB *func;
@ -1607,6 +1608,38 @@ int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
} /* for */
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 */
#if defined AMX_NATIVEINFO
@ -2800,7 +2833,9 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index, int numparams, ...)
if (amx->callback==NULL)
return AMX_ERR_CALLBACK;
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;
if ((amx->flags & AMX_FLAG_RELOC)==0)

View File

@ -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_UTF8Put(char *string, char **endptr, int maxchars, cell value);
int AMXAPI amx_UTF8Check(const char *string);
void amx_NullNativeTable(AMX *amx);
#if !defined AMX_NO_ALIGN
#if defined __linux__

View File

@ -2473,7 +2473,7 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
// native callfunc_push_int(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);
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_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);
if (!g_CallFunc_Plugin)
@ -2557,7 +2557,7 @@ static cell callfunc_push_byref(AMX *amx, cell *params)
}
// 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);
if (!g_CallFunc_Plugin)
@ -2618,20 +2618,20 @@ static cell callfunc_push_str(AMX *amx, cell *params)
}
// 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();
}
// 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);
return 0;
}
// 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 result = g_langMngr.MergeDefinitionFile(build_pathname("%s/lang/%s",
@ -2639,7 +2639,7 @@ static cell register_dictionary(AMX *amx, cell *params)
return result;
}
static cell plugin_flags(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL plugin_flags(AMX *amx, cell *params)
{
AMX_HEADER *hdr;
hdr = (AMX_HEADER *)amx->base;
@ -2647,13 +2647,13 @@ static cell plugin_flags(AMX *amx, cell *params)
}
// 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;
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;

View File

@ -254,6 +254,7 @@ void* alloc_amxmemory(void**, int size);
void free_amxmemory(void **ptr);
// get_localinfo
const char* get_localinfo( const char* name , const char* def );
static cell AMX_NATIVE_CALL null_native(AMX *amx, cell *params);
enum ModuleCallReason
{
@ -267,6 +268,7 @@ extern ModuleCallReason g_ModuleCallReason; // modules.cpp
extern CModule *g_CurrentlyCalledModule; // modules.cpp
extern const char *g_LastRequestedFunc; // modules.cpp
extern CQueue<String> CurModuleList;
extern int no_module_test;
void *Module_ReqFnptr(const char *funcName); // modules.cpp

View File

@ -266,7 +266,9 @@ int C_Spawn( edict_t *pent ) {
memset(g_players[0].flags,-1,sizeof(g_players[0].flags));
// ###### Load AMX scripts
no_module_test = 0;
g_plugins.loadPluginsFromFile( get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini") );
no_module_test = 0;
// Register forwards
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
@ -446,6 +448,7 @@ void C_ServerDeactivate_Post() {
// pft that's not really a hack
g_FakeMeta.m_Plugins.begin()->GetDllFuncTable().pfnSpawn = C_Spawn;
no_module_test = 0;
detachReloadModules();
g_auth.clear();
g_forwards.clear();

View File

@ -222,6 +222,7 @@ int CheckModules(AMX *amx, char error[64])
{
cell retVal = 0;
int err = 0;
no_module_test = 1;
if ( (err = amx_Exec(amx, &retVal, idx, 0)) == AMX_ERR_NONE )
{
unsigned int i = 0;
@ -261,9 +262,11 @@ int CheckModules(AMX *amx, char error[64])
}
} else {
AMXXLOG_Log("[AMXX] Run time error %d on line %ld during module check.", err, amx->curline);
no_module_test = 0;
//could not execute
return -1; //bad! very bad!
}
no_module_test = 0;
} else {
return -1;
}
@ -292,7 +295,9 @@ int set_amxnatives(AMX* amx,char error[64])
{
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);
}
return (amx->error = AMX_ERR_NATIVE);