use union hack

This commit is contained in:
Christian Semmler 2023-06-19 23:40:07 +02:00
parent f7cbc4ba02
commit cc49881c36
No known key found for this signature in database
GPG Key ID: 086DAA1360BEEE5C
2 changed files with 9 additions and 11 deletions

View File

@ -8,20 +8,12 @@ MxDSObject::MxDSObject()
{
// The following code yields 100% matching assembly if m_unk24 is declared as (signed) short.
// However, in other areas m_unk24 (notably, ISLE.EXE) is treated as unsigned short.
// this->m_unk0c = 0;
// this->m_unk10 = 0;
// this->m_unk14 = 0;
// this->m_name = NULL;
// this->m_unk24 = -1;
// this->m_unk1c = -1;
// this->m_unk28 = 0;
// Assembly not matching but m_unk24 is unsigned short (probably correct)
// Since we don't have a proper solution yet, we are using a union to work around this discrepancy.
this->m_unk0c = 0;
this->m_unk10 = 0;
this->m_unk14 = 0;
this->m_name = NULL;
this->m_unk24 = 0xFFFF;
this->m_unk24signed = -1;
this->m_unk1c = -1;
this->m_unk28 = 0;
}

View File

@ -27,7 +27,13 @@ class MxDSObject : public MxCore
char *m_name;
int m_unk1c;
MxAtomId m_atomId;
unsigned short m_unk24;
// So far, implementing MxDSObject::MxDSObject correctly required that m_unk24 is declared a (signed) short.
// Most of the other game's code appears to treat it as unsigned short, however.
// This union is a workaround until we have figured this out.
union {
unsigned short m_unk24;
short m_unk24signed;
};
unsigned short m_unk26;
int m_unk28;
};