Fixed FormatAmxString bugs

This commit is contained in:
David Anderson 2004-08-13 09:39:59 +00:00
parent eadd0a8317
commit 5469f70dba
2 changed files with 39 additions and 5 deletions

View File

@ -317,11 +317,16 @@ void CLangMngr::CLang::Dump()
const char * CLangMngr::CLang::GetDef(const char *key)
{
static char nfind[1024];
uint32_t hash = MakeHash(key, true);
for (LookUpVecIter iter = m_LookUpTable.begin(); iter != m_LookUpTable.end(); ++iter)
{
AMXXLOG_Log( "Lookup: %s", (*iter).GetKey() );
if (*iter == hash)
return iter->GetDef();
return "(not found)";
}
sprintf(nfind, "ML Lookup Failure: %s", key);
return nfind;
}
@ -687,6 +692,9 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
}
default:
{
char tmpString[256];
char *tmpPtr = tmpString;
int tmpLen =0;
char format[16];
format[0] = '%';
char *ptr = format+1;
@ -694,7 +702,33 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
/*nothing*/;
--src;
*ptr = 0;
sprintf(outptr, format, *get_amxaddr(amx, params[parm++]));
switch ( *(ptr-1) )
{
case 's':
{
cell *tmpCell = get_amxaddr(amx, params[parm++]);
while (*tmpCell)
*tmpPtr++ = *tmpCell++;
*tmpPtr = 0;
sprintf(outptr, format, tmpString);
break;
}
case 'f':
{
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
break;
}
case 'd':
{
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
break;
}
case 'i':
{
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
break;
}
}
outptr += strlen(outptr);
break;
}

View File

@ -236,7 +236,7 @@ int C_Spawn( edict_t *pent ) {
get_localinfo("amxx_customdir", "addons/amxx/custom");
// ###### Load modules
loadModules(get_localinfo("amxx_modules", "addons/amxx/modules.ini"));
loadModules(get_localinfo("amxx_modules", "addons/amxx/configs/modules.ini"));
attachModules();
int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat
// Set some info about amx version and modules
@ -268,7 +268,7 @@ int C_Spawn( edict_t *pent ) {
memset(g_players[0].flags,-1,sizeof(g_players[0].flags));
// ###### Load AMX scripts
g_plugins.loadPluginsFromFile( get_localinfo("amxx_plugins", "addons/amxx/plugins.ini") );
g_plugins.loadPluginsFromFile( get_localinfo("amxx_plugins", "addons/amxx/configs/plugins.ini") );
// Register forwards
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
@ -1064,7 +1064,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
// ###### Now attach metamod modules
// This will also call modules Meta_Query and Meta_Attach functions
attachMetaModModules(now, get_localinfo("amxx_modules", "addons/amxx/modules.ini") );
attachMetaModModules(now, get_localinfo("amxx_modules", "addons/amxx/configs/modules.ini") );
return(TRUE);
}