More fixes for negative numbers in ui scripts.

This commit is contained in:
Andrei Drexler 2009-06-25 20:31:08 +00:00
parent aceb1a7761
commit d35f226f34

View file

@ -485,10 +485,23 @@ Float_Parse
qboolean Float_Parse(char **p, float *f) qboolean Float_Parse(char **p, float *f)
{ {
char *token; char *token;
qboolean negative = qfalse;
token = COM_ParseExt(p, qfalse); for ( token = COM_ParseExt(p, qfalse);
if (token && token[0] != 0) { token && *token;
token = COM_ParseExt(p, qfalse) )
{
if (*token != '-')
break;
negative ^= qtrue;
}
if (token && token[0] != 0)
{
*f = atof(token); *f = atof(token);
if (negative)
*f = -*f;
return qtrue; return qtrue;
} else { } else {
return qfalse; return qfalse;
@ -582,11 +595,23 @@ Int_Parse
qboolean Int_Parse(char **p, int *i) qboolean Int_Parse(char **p, int *i)
{ {
char *token; char *token;
qboolean negative = qfalse;
token = COM_ParseExt(p, qfalse); for ( token = COM_ParseExt(p, qfalse);
token && *token;
token = COM_ParseExt(p, qfalse) )
{
if (*token != '-')
break;
if (token && token[0] != 0) { negative ^= qtrue;
}
if (token && token[0] != 0)
{
*i = atoi(token); *i = atoi(token);
if (negative)
*i = -*i;
return qtrue; return qtrue;
} else { } else {
return qfalse; return qfalse;