mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-21 19:32:30 +00:00
FTOS fix: no leading spaces and keeping maximum precision for float values
This commit is contained in:
parent
5765a6c08f
commit
64462f814d
1 changed files with 11 additions and 1 deletions
|
@ -1038,12 +1038,22 @@ char pr_string_temp[128];
|
||||||
void PF_ftos (void)
|
void PF_ftos (void)
|
||||||
{
|
{
|
||||||
float v;
|
float v;
|
||||||
|
int i; // 1999-07-25 FTOS fix by Maddes
|
||||||
|
|
||||||
v = G_FLOAT(OFS_PARM0);
|
v = G_FLOAT(OFS_PARM0);
|
||||||
|
|
||||||
if (v == (int)v)
|
if (v == (int)v)
|
||||||
snprintf(pr_string_temp, sizeof(pr_string_temp), "%d",(int)v);
|
snprintf(pr_string_temp, sizeof(pr_string_temp), "%d",(int)v);
|
||||||
else
|
else
|
||||||
snprintf(pr_string_temp, sizeof(pr_string_temp), "%5.1f",v);
|
// 1999-07-25 FTOS fix by Maddes start
|
||||||
|
{
|
||||||
|
snprintf(pr_string_temp, sizeof(pr_string_temp), "%1f",v);
|
||||||
|
for (i=Q_strlen(pr_string_temp)-1 ; i>0 && pr_string_temp[i]=='0' && pr_string_temp[i-1]!='.' ; i--)
|
||||||
|
{
|
||||||
|
pr_string_temp[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 1999-07-25 FTOS fix by Maddes end
|
||||||
G_INT(OFS_RETURN) = PR_SetString(pr_string_temp);
|
G_INT(OFS_RETURN) = PR_SetString(pr_string_temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue