PF_vlen: add casts to double to force 64-bit precision

Fixes https://sourceforge.net/p/quakespasm/bugs/26/
(travail qte1m2.bsp button near 2772 767 -584 hurting the player
sm179_otp.bsp: left button causing the player to get stuck)

This change should probably be applied to more places in pr_cmds.c
and elsewhere, but this specific change is enough to fix these corner
cases

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1554 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Eric Wasylishen 2018-01-17 07:44:26 +00:00
parent 77a45cbbbe
commit a89063a5ff

View file

@ -427,11 +427,11 @@ scalar vlen(vector)
static void PF_vlen (void)
{
float *value1;
float new_temp;
double new_temp;
value1 = G_VECTOR(OFS_PARM0);
new_temp = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
new_temp = (double)value1[0] * value1[0] + (double)value1[1] * value1[1] + (double)value1[2]*value1[2];
new_temp = sqrt(new_temp);
G_FLOAT(OFS_RETURN) = new_temp;