From aacabd2e13e1e498000c9e446081a31dbee31f56 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sat, 12 Feb 2022 10:13:25 -0500 Subject: [PATCH] Fixed const float encoding in reflection --- IDEHelper/Compiler/BfModule.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index dbd40db0..9207ac2c 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -5416,9 +5416,17 @@ BfIRValue BfModule::CreateFieldData(BfFieldInstance* fieldInstance, int customAt if (fieldInstance->mConstIdx != -1) { auto constant = typeInstance->mConstHolder->GetConstantById(fieldInstance->mConstIdx); - constValue = mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, constant->mUInt64); + uint64 val = constant->mUInt64; + + if (constant->mTypeCode == BfTypeCode_Float) + { + float f = (float)*(double*)&val; + val = *(uint32*)&f; + } + + constValue = mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, val); if (is32Bit) - constValue2 = mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, constant->mUInt64 >> 32); + constValue2 = mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, val >> 32); } } else if (fieldInstance->GetFieldDef()->mIsStatic)