From 35121544b4eb5d8dbdad1aedd9889b12db539cc7 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Mar 2016 22:33:10 -0500 Subject: [PATCH] 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. --- src/p_acs.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index fe10921d0..42048c159 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -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; }