From 09394c3512f3d2272a5901cd575adcd3159d3188 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 11 May 2024 12:57:07 -0400 Subject: [PATCH] Implement/match LegoPathController::FUN_10047b30 (#906) * Implement/match LegoPathController::FUN_10047b30 * Fix delete --- LEGO1/lego/legoomni/include/legopathstruct.h | 12 ++++++--- .../legoomni/src/paths/legopathcontroller.cpp | 27 ++++++++++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopathstruct.h b/LEGO1/lego/legoomni/include/legopathstruct.h index b85d7d52..6ffdb20f 100644 --- a/LEGO1/lego/legoomni/include/legopathstruct.h +++ b/LEGO1/lego/legoomni/include/legopathstruct.h @@ -5,22 +5,26 @@ #include "mxatom.h" #include "mxtypes.h" +class LegoPathController; + // VTABLE: LEGO1 0x100d7d9c // SIZE 0x0c class LegoPathStructBase { public: - LegoPathStructBase() : m_unk0x04(NULL), m_unk0x08(0) {} + LegoPathStructBase() : m_name(NULL), m_unk0x08(0) {} // FUNCTION: LEGO1 0x10047420 virtual ~LegoPathStructBase() { - if (m_unk0x04 != NULL) { - delete m_unk0x04; + if (m_name != NULL) { + delete[] m_name; } } + friend class LegoPathController; + private: - undefined* m_unk0x04; // 0x04 + char* m_name; // 0x04 undefined4 m_unk0x08; // 0x08 }; diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 3a2cf6ae..c6c70780 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -181,16 +181,37 @@ MxResult LegoPathController::Read(LegoStorage* p_storage) return SUCCESS; } -// STUB: LEGO1 0x10047b30 +// FUNCTION: LEGO1 0x10047b30 // FUNCTION: BETA10 0x100b7cd6 MxResult LegoPathController::FUN_10047b30(LegoStorage* p_storage) { - // TODO + for (MxS32 i = 0; i < m_numT; i++) { + MxU8 length = 0; + + if (p_storage->Read(&length, sizeof(length)) != SUCCESS) { + return FAILURE; + } + + if (length > 0) { + m_unk0x14[i].m_name = new char[length + 1]; + + if (p_storage->Read(m_unk0x14[i].m_name, length) != SUCCESS) { + return FAILURE; + } + + m_unk0x14[i].m_name[length] = '\0'; + } + + if (p_storage->Read(&m_unk0x14[i].m_unk0x08, sizeof(m_unk0x14[i].m_unk0x08)) != SUCCESS) { + return FAILURE; + } + } + return SUCCESS; } // STUB: LEGO1 0x10047c10 -// FUNCTION: BETA10 0x1100b7df3 +// FUNCTION: BETA10 0x100b7df3 MxResult LegoPathController::FUN_10047c10(LegoStorage* p_storage) { // TODO