LogError() now can log native function names.

This commit is contained in:
David Anderson 2004-10-29 00:21:44 +00:00
parent c9c26b869c
commit 3587483fa6
2 changed files with 5 additions and 0 deletions

View File

@ -428,6 +428,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
AMX_HEADER *hdr;
AMX_FUNCSTUB *func;
AMX_NATIVE f;
int i =0;
assert(amx!=NULL);
hdr=(AMX_HEADER *)amx->base;
@ -437,6 +438,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
assert(index>=0 && index<(cell)NUMENTRIES(hdr,natives,libraries));
func=GETENTRY(hdr,natives,index);
f=(AMX_NATIVE)func->address;
amx->userdata[2] = (char *)GETENTRYNAME(hdr, func);
assert(f!=NULL);
/* now that we have found the function, patch the program so that any
@ -606,6 +608,7 @@ static int amx_BrowseRelocate(AMX *amx)
} else {
amx->userdata[0] = 0;
amx->userdata[1] = 0;
amx->userdata[2] = 0;
}
#if defined __GNUC__ || defined ASM32 || defined JIT && !defined __64BIT__

View File

@ -1166,6 +1166,8 @@ void GenericError(AMX *amx, int err, int line, char buf[], const char *file)
{
sprintf(buf, "Run time error %d on line %d (%s \"%s\").", err, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
} else {
if (err == AMX_ERR_NATIVE && amx->userdata[2])
geterr = (char *)(amx->userdata[2]);
sprintf(buf, "Run time error %d (%s) on line %d (%s \"%s\").", err, geterr, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
}
}