From 49ec7364c2a58f7fb0dccd0970a9ef1a4345ee50 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 12 Oct 2023 11:54:02 -0400 Subject: [PATCH] MxDSAction::MergeFrom: match to 100% (#200) * Minor accuracy improvement * Workaround for 100% match * Update mxdsaction.cpp --- LEGO1/mxdsaction.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/LEGO1/mxdsaction.cpp b/LEGO1/mxdsaction.cpp index 153a6498..771f64b0 100644 --- a/LEGO1/mxdsaction.cpp +++ b/LEGO1/mxdsaction.cpp @@ -15,7 +15,7 @@ MxU16 g_unkSep = TWOCC(',', ' '); // OFFSET: LEGO1 0x100ad810 MxDSAction::MxDSAction() { - this->m_flags = 32; + this->m_flags = MxDSAction::Flag_Enabled; this->m_startTime = INT_MIN; this->m_extraData = NULL; this->m_extraLength = 0; @@ -153,7 +153,7 @@ void MxDSAction::MergeFrom(MxDSAction &p_dsAction) if (p_dsAction.m_direction[1] != FLT_MAX) this->m_direction[1] = p_dsAction.m_direction[1]; if (p_dsAction.m_direction[2] != FLT_MAX) - this->m_direction[2] = p_dsAction.m_direction[2]; + this->m_direction[2] = p_dsAction.m_up[2]; // This is correct if (p_dsAction.m_up[0] != FLT_MAX) this->m_up[0] = p_dsAction.m_up[0]; @@ -162,9 +162,13 @@ void MxDSAction::MergeFrom(MxDSAction &p_dsAction) if (p_dsAction.m_up[2] != FLT_MAX) this->m_up[2] = p_dsAction.m_up[2]; - // TODO MxU16 extraLength = p_dsAction.m_extraLength; char *extraData = p_dsAction.m_extraData; + + // Taking those references forces the compiler to move the values onto the stack. + // The original code most likely looked different, but this yields a 100% match. + MxU16 &_extraLength = extraLength; + char *&_extraData = extraData; if (extraLength && extraData) { if (!this->m_extraData || !strncmp("XXX", this->m_extraData, 3)) { delete[] this->m_extraData;