- removed all uses of single precision floats from FraggleScript code.

This commit is contained in:
Christoph Oelckers 2013-09-02 09:08:47 +02:00
parent 267030c759
commit ba2a07fb26
3 changed files with 9 additions and 9 deletions

View file

@ -73,7 +73,6 @@ static FRandom pr_script("FScript");
#define AngleToFixed(x) ((((double) x) / ((double) ANG45/45)) * FRACUNIT) #define AngleToFixed(x) ((((double) x) / ((double) ANG45/45)) * FRACUNIT)
#define FixedToAngle(x) ((((double) x) / FRACUNIT) * ANG45/45) #define FixedToAngle(x) ((((double) x) / FRACUNIT) * ANG45/45)
#define FIXED_TO_FLOAT(f) ((f)/(float)FRACUNIT)
// functions. FParser::SF_ means Script Function not, well.. heh, me // functions. FParser::SF_ means Script Function not, well.. heh, me
@ -1417,11 +1416,11 @@ void FParser::SF_PointToDist(void)
if (CheckArgs(4)) if (CheckArgs(4))
{ {
// Doing this in floating point is actually faster with modern computers! // Doing this in floating point is actually faster with modern computers!
float x = floatvalue(t_argv[2]) - floatvalue(t_argv[0]); double x = floatvalue(t_argv[2]) - floatvalue(t_argv[0]);
float y = floatvalue(t_argv[3]) - floatvalue(t_argv[1]); double y = floatvalue(t_argv[3]) - floatvalue(t_argv[1]);
t_return.type = svt_fixed; t_return.type = svt_fixed;
t_return.value.f = (fixed_t)(sqrtf(x*x+y*y)*65536.f); t_return.value.f = FLOAT2FIXED(sqrt(x*x+y*y)*65536.f);
} }
} }

View file

@ -110,7 +110,7 @@ struct svalue_t
int intvalue(const svalue_t & v); int intvalue(const svalue_t & v);
fixed_t fixedvalue(const svalue_t & v); fixed_t fixedvalue(const svalue_t & v);
float floatvalue(const svalue_t & v); double floatvalue(const svalue_t & v);
const char *stringvalue(const svalue_t & v); const char *stringvalue(const svalue_t & v);
AActor *actorvalue(const svalue_t &svalue); AActor *actorvalue(const svalue_t &svalue);

View file

@ -89,11 +89,12 @@ fixed_t fixedvalue(const svalue_t &v)
// //
//========================================================================== //==========================================================================
float floatvalue(const svalue_t &v) double floatvalue(const svalue_t &v)
{ {
return (float)( (v.type == svt_string ? atof(v.string) : return
v.type == svt_fixed ? (float)(v.value.f / (float)FRACUNIT) : v.type == svt_string ? atof(v.string) :
v.type == svt_mobj ? -1.f : (float)v.value.i )); v.type == svt_fixed ? FIXED2DBL(v.value.f) :
v.type == svt_mobj ? -1. : (double)v.value.i;
} }
//========================================================================== //==========================================================================