diff --git a/LEGO1/lego/legoomni/include/legounksavedatawriter.h b/LEGO1/lego/legoomni/include/legounksavedatawriter.h index ffc3b661..e0aa8cea 100644 --- a/LEGO1/lego/legoomni/include/legounksavedatawriter.h +++ b/LEGO1/lego/legoomni/include/legounksavedatawriter.h @@ -3,18 +3,21 @@ #include "decomp.h" #include "lego/sources/misc/legostorage.h" +#include "legovariables.h" #include "mxstl/stlcompat.h" #include "mxtypes.h" class LegoROI; +#pragma warning(disable : 4237) + // TODO: generic string comparator? struct LegoUnkSaveDataMapComparator { bool operator()(const char* const& p_a, const char* const& p_b) const { return strcmpi(p_a, p_b) > 0; } }; // TODO: pair instead? -// SIZE 0x8 +// SIZE 0x08 struct LegoUnkSaveDataMapValue { LegoROI* m_roi; // 0x00 MxU32 m_counter; // 0x04 @@ -54,18 +57,19 @@ class LegoUnkSaveDataWriter { MxResult WriteSaveData3(LegoStorage* p_stream); LegoROI* FUN_10083500(char*, MxBool); - void InitSaveData(); + + static void InitSaveData(); + static void SetCustomizeAnimFile(const char* p_value); + void FUN_100832a0(); void FUN_10083db0(LegoROI* p_roi); void FUN_10083f10(LegoROI* p_roi); - static void SetCustomizeAnimFile(const char* p_value); - private: static char* g_customizeAnimFile; - LegoUnkSaveDataMap* m_map; // 0x00 - undefined m_unk0x04[0x04]; // 0x04 + LegoUnkSaveDataMap* m_map; // 0x00 + CustomizeAnimFileVariable* m_customizeAnimFile; // 0x04 }; // clang-format off diff --git a/LEGO1/lego/legoomni/include/legovariables.h b/LEGO1/lego/legoomni/include/legovariables.h index bf03bf24..8528d44d 100644 --- a/LEGO1/lego/legoomni/include/legovariables.h +++ b/LEGO1/lego/legoomni/include/legovariables.h @@ -48,8 +48,7 @@ class WhoAmIVariable : public MxVariable { // SIZE 0x24 class CustomizeAnimFileVariable : public MxVariable { public: - // FUNCTION: LEGO1 0x10085aa0 - CustomizeAnimFileVariable() : MxVariable("CUSTOMIZE_ANIM_FILE") {} + CustomizeAnimFileVariable(const char* p_key); void SetValue(const char* p_value) override; // vtable+0x04 }; diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index b88e7b6f..e4ca4762 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -58,10 +58,10 @@ void LegoBuildingManager::SetCustomizeAnimFile(const char* p_value) } strcpy(g_customizeAnimFile, p_value); - return; } - - g_customizeAnimFile = NULL; + else { + g_customizeAnimFile = NULL; + } } // STUB: LEGO1 0x10030220 diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index 91a59a12..d678e9ab 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -49,10 +49,10 @@ void LegoPlantManager::SetCustomizeAnimFile(const char* p_value) } strcpy(g_customizeAnimFile, p_value); - return; } - - g_customizeAnimFile = NULL; + else { + g_customizeAnimFile = NULL; + } } // STUB: LEGO1 0x10026e00 diff --git a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp index 04d3aea2..ae3ff926 100644 --- a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp +++ b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp @@ -2,7 +2,6 @@ #include "legogamestate.h" #include "legoomni.h" -#include "legovariables.h" #include "roi/legoroi.h" DECOMP_SIZE_ASSERT(LegoUnkSaveDataWriter, 0x08) @@ -23,9 +22,8 @@ LegoUnkSaveDataWriter::LegoUnkSaveDataWriter() m_map = new LegoUnkSaveDataMap(); InitSaveData(); - // DECOMP: this constructor is partially inlined - CustomizeAnimFileVariable* v = new CustomizeAnimFileVariable(); - VariableTable()->SetVariable(v); + m_customizeAnimFile = new CustomizeAnimFileVariable("CUSTOMIZE_ANIM_FILE"); + VariableTable()->SetVariable(m_customizeAnimFile); } // FUNCTION: LEGO1 0x10083270 @@ -125,8 +123,8 @@ void LegoUnkSaveDataWriter::SetCustomizeAnimFile(const char* p_value) } strcpy(g_customizeAnimFile, p_value); - return; } - - g_customizeAnimFile = NULL; + else { + g_customizeAnimFile = NULL; + } } diff --git a/LEGO1/lego/legoomni/src/common/legovariables.cpp b/LEGO1/lego/legoomni/src/common/legovariables.cpp index b7e59272..d19dc009 100644 --- a/LEGO1/lego/legoomni/src/common/legovariables.cpp +++ b/LEGO1/lego/legoomni/src/common/legovariables.cpp @@ -44,15 +44,20 @@ void WhoAmIVariable::SetValue(const char* p_value) // TODO } +// FUNCTION: LEGO1 0x10085aa0 +CustomizeAnimFileVariable::CustomizeAnimFileVariable(const char* p_key) +{ + m_key = p_key; + m_key.ToUpperCase(); +} + // FUNCTION: LEGO1 0x10085b50 void CustomizeAnimFileVariable::SetValue(const char* p_value) { // STRING: LEGO1 0x100fc4f4 - if (strcmp(m_key.GetData(), "CUSTOMIZE_ANIM_FILE") != 0) { - return; + if (strcmp(m_key.GetData(), "CUSTOMIZE_ANIM_FILE") == 0) { + UnkSaveDataWriter()->SetCustomizeAnimFile(p_value); + PlantManager()->SetCustomizeAnimFile(p_value); + BuildingManager()->SetCustomizeAnimFile(p_value); } - - UnkSaveDataWriter()->SetCustomizeAnimFile(p_value); - PlantManager()->SetCustomizeAnimFile(p_value); - BuildingManager()->SetCustomizeAnimFile(p_value); }