- store floating point parameters for DECORATE properties as doubles.

This commit is contained in:
Christoph Oelckers 2016-02-12 01:21:29 +01:00
parent 73cbc59dd9
commit d25455736a
3 changed files with 12 additions and 9 deletions

View file

@ -258,7 +258,7 @@ enum EDefinitionType
union FPropParam union FPropParam
{ {
int i; int i;
float f; double d;
const char *s; const char *s;
FxExpression *exp; FxExpression *exp;
}; };
@ -317,10 +317,13 @@ int MatchString (const char *in, const char **strings);
int var = params[(no)+1].i; int var = params[(no)+1].i;
#define PROP_FLOAT_PARM(var, no) \ #define PROP_FLOAT_PARM(var, no) \
float var = params[(no)+1].f; float var = float(params[(no)+1].d);
#define PROP_DOUBLE_PARM(var, no) \
double var = params[(no)+1].d;
#define PROP_FIXED_PARM(var, no) \ #define PROP_FIXED_PARM(var, no) \
fixed_t var = fixed_t(params[(no)+1].f * FRACUNIT); fixed_t var = FLOAT2FIXED(params[(no)+1].d);
#define PROP_COLOR_PARM(var, no) \ #define PROP_COLOR_PARM(var, no) \
int var = params[(no)+1].i== 0? params[(no)+2].i : V_GetColor(NULL, params[(no)+2].s); int var = params[(no)+1].i== 0? params[(no)+2].i : V_GetColor(NULL, params[(no)+2].s);

View file

@ -825,7 +825,7 @@ static bool ParsePropertyParams(FScanner &sc, FPropertyInfo *prop, AActor *defau
case 'F': case 'F':
sc.MustGetFloat(); sc.MustGetFloat();
conv.f = float(sc.Float); conv.d = sc.Float;
break; break;
case 'Z': // an optional string. Does not allow any numerical value. case 'Z': // an optional string. Does not allow any numerical value.

View file

@ -2174,7 +2174,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory)
} }
if (PROP_PARM_COUNT > 2) if (PROP_PARM_COUNT > 2)
{ {
PROP_FLOAT_PARM(falpha, 2); PROP_DOUBLE_PARM(falpha, 2);
alpha=int(falpha*255); alpha=int(falpha*255);
} }
else alpha = 255/3; else alpha = 255/3;
@ -2718,17 +2718,17 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn)
} }
else if (PROP_PARM_COUNT < 4) else if (PROP_PARM_COUNT < 4)
{ {
PROP_FLOAT_PARM(a, 2); PROP_DOUBLE_PARM(a, 2);
color.a = BYTE(255 * clamp(a, 0.f, 1.f)); color.a = BYTE(255 * clamp<double>(a, 0.f, 1.f));
defaults->DamageFade = color; defaults->DamageFade = color;
} }
else else
{ {
PROP_FLOAT_PARM(a, 2); PROP_DOUBLE_PARM(a, 2);
PROP_STRING_PARM(type, 3); PROP_STRING_PARM(type, 3);
color.a = BYTE(255 * clamp(a, 0.f, 1.f)); color.a = BYTE(255 * clamp<double>(a, 0.f, 1.f));
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn))); assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
static_cast<PClassPlayerPawn *>(info)->PainFlashes.Insert(type, color); static_cast<PClassPlayerPawn *>(info)->PainFlashes.Insert(type, color);
} }