mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-18 23:52:02 +00:00
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:
parent
b6e3358b1c
commit
35121544b4
1 changed files with 16 additions and 2 deletions
|
@ -4567,7 +4567,14 @@ static void SetUserVariable(AActor *self, FName varname, int index, int value)
|
||||||
|
|
||||||
if (GetVarAddrType(self, varname, index, addr, type))
|
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))
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue