Add float support to ACS's Get/SetUserVariable functions

- "Support" means that setting one will convert from fixed point to
  floating point, and reading one will do the reverse.
This commit is contained in:
Randy Heit 2016-03-29 22:33:10 -05:00
parent b6e3358b1c
commit 35121544b4

View file

@ -4567,7 +4567,14 @@ static void SetUserVariable(AActor *self, FName varname, int index, int value)
if (GetVarAddrType(self, varname, index, addr, type))
{
type->SetValue(addr, value);
if (!type->IsKindOf(RUNTIME_CLASS(PFloat)))
{
type->SetValue(addr, value);
}
else
{
type->SetValue(addr, FIXED2DBL(value));
}
}
}
@ -4578,7 +4585,14 @@ static int GetUserVariable(AActor *self, FName varname, int index)
if (GetVarAddrType(self, varname, index, addr, type))
{
return type->GetValueInt(addr);
if (!type->IsKindOf(RUNTIME_CLASS(PFloat)))
{
return type->GetValueInt(addr);
}
else
{
return FLOAT2FIXED(type->GetValueFloat(addr));
}
}
return 0;
}