added requests amb565 and amb445

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401078
This commit is contained in:
David Anderson
2007-07-08 18:00:35 +00:00
parent 6dd0ff6b07
commit 9a2fbe5f9f
2 changed files with 47 additions and 0 deletions
+28
View File
@@ -108,6 +108,18 @@ static cell_t sm_strconvint(IPluginContext *pCtx, const cell_t *params)
return static_cast<cell_t>(strtol(str, &dummy, params[2]));
}
static cell_t StringToIntEx(IPluginContext *pCtx, const cell_t *params)
{
char *str, *dummy = NULL;
cell_t *addr;
pCtx->LocalToString(params[1], &str);
pCtx->LocalToPhysAddr(params[2], &addr);
*addr = static_cast<cell_t>(strtol(str, &dummy, params[3]));
return dummy - str;
}
static cell_t sm_numtostr(IPluginContext *pCtx, const cell_t *params)
{
char *str;
@@ -127,6 +139,20 @@ static cell_t sm_strtofloat(IPluginContext *pCtx, const cell_t *params)
return sp_ftoc(val);
}
static cell_t StringToFloatEx(IPluginContext *pCtx, const cell_t *params)
{
char *str, *dummy = NULL;
cell_t *addr;
pCtx->LocalToString(params[1], &str);
pCtx->LocalToPhysAddr(params[2], &addr);
float val = (float)strtod(str, &dummy);
*addr = sp_ftoc(val);
return dummy - str;
}
static cell_t sm_floattostr(IPluginContext *pCtx, const cell_t *params)
{
char *str;
@@ -539,7 +565,9 @@ REGISTER_NATIVES(basicStrings)
{"strcopy", sm_strcopy},
{"StrCopy", sm_strcopy}, /* Backwards compat shim */
{"StringToInt", sm_strconvint},
{"StringToIntEx", StringToIntEx},
{"StringToFloat", sm_strtofloat},
{"StringToFloatEx", StringToFloatEx},
{"TrimString", TrimString},
{"VFormat", sm_vformat},
{NULL, NULL},