FTOS fix: no leading spaces and keeping maximum precision for float values

This commit is contained in:
Maddes Buecher 2000-08-16 21:43:46 +00:00
parent 5765a6c08f
commit 64462f814d

View file

@ -1038,12 +1038,22 @@ char pr_string_temp[128];
void PF_ftos (void)
{
float v;
int i; // 1999-07-25 FTOS fix by Maddes
v = G_FLOAT(OFS_PARM0);
if (v == (int)v)
snprintf(pr_string_temp, sizeof(pr_string_temp), "%d",(int)v);
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);
}