mirror of
https://github.com/ioquake/ioq3.git
synced 2025-06-02 01:42:12 +00:00
Fix botlib parser for negative int/float values, thanks to Makro for reporting (#4227).
This commit is contained in:
parent
5663ff1362
commit
ba31be1736
3 changed files with 48 additions and 17 deletions
|
@ -1156,13 +1156,21 @@ float ReadSignedFloat(script_t *script)
|
|||
PS_ExpectAnyToken(script, &token);
|
||||
if (!strcmp(token.string, "-"))
|
||||
{
|
||||
if(!PS_ExpectAnyToken(script, &token))
|
||||
{
|
||||
ScriptError(script, "Missing float value\n", token.string);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sign = -1.0;
|
||||
PS_ExpectTokenType(script, TT_NUMBER, 0, &token);
|
||||
} //end if
|
||||
else if (token.type != TT_NUMBER)
|
||||
}
|
||||
|
||||
if (token.type != TT_NUMBER)
|
||||
{
|
||||
ScriptError(script, "expected float value, found %s\n", token.string);
|
||||
} //end else if
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sign * token.floatvalue;
|
||||
} //end of the function ReadSignedFloat
|
||||
//============================================================================
|
||||
|
@ -1179,13 +1187,21 @@ signed long int ReadSignedInt(script_t *script)
|
|||
PS_ExpectAnyToken(script, &token);
|
||||
if (!strcmp(token.string, "-"))
|
||||
{
|
||||
if(!PS_ExpectAnyToken(script, &token))
|
||||
{
|
||||
ScriptError(script, "Missing integer value\n", token.string);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sign = -1;
|
||||
PS_ExpectTokenType(script, TT_NUMBER, TT_INTEGER, &token);
|
||||
} //end if
|
||||
else if (token.type != TT_NUMBER || token.subtype == TT_FLOAT)
|
||||
}
|
||||
|
||||
if (token.type != TT_NUMBER || token.subtype == TT_FLOAT)
|
||||
{
|
||||
ScriptError(script, "expected integer value, found %s\n", token.string);
|
||||
} //end else if
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sign * token.intvalue;
|
||||
} //end of the function ReadSignedInt
|
||||
//============================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue