From a4932b9e7f189557e15c9bbb38719b1fae77cf27 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 3 Mar 2024 14:01:53 -0500 Subject: [PATCH] WIP --- .../lego/legoomni/include/legopartpresenter.h | 2 + .../legoomni/include/legoworldpresenter.h | 6 ++ .../src/entity/legoworldpresenter.cpp | 75 ++++++++++++++++++- LEGO1/library_msvc.h | 3 + LEGO1/modeldb/modeldb.cpp | 2 + LEGO1/modeldb/modeldb.h | 22 +++++- 6 files changed, 108 insertions(+), 2 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopartpresenter.h b/LEGO1/lego/legoomni/include/legopartpresenter.h index af4ea706..90cc2ddc 100644 --- a/LEGO1/lego/legoomni/include/legopartpresenter.h +++ b/LEGO1/lego/legoomni/include/legopartpresenter.h @@ -8,6 +8,8 @@ class LegoPartPresenter : public MxMediaPresenter { public: LegoPartPresenter() { Reset(); } + + // FUNCTION: LEGO1 0x10067300 ~LegoPartPresenter() override { Destroy(TRUE); } // FUNCTION: LEGO1 0x1000cf70 diff --git a/LEGO1/lego/legoomni/include/legoworldpresenter.h b/LEGO1/lego/legoomni/include/legoworldpresenter.h index 45961a3e..e101acfb 100644 --- a/LEGO1/lego/legoomni/include/legoworldpresenter.h +++ b/LEGO1/lego/legoomni/include/legoworldpresenter.h @@ -3,7 +3,11 @@ #include "legoentitypresenter.h" +#include + class LegoWorld; +struct ModelDbPart; +struct ModelDbModel; // VTABLE: LEGO1 0x100d8ee0 // SIZE 0x54 @@ -33,6 +37,8 @@ class LegoWorldPresenter : public LegoEntityPresenter { MxResult StartAction(MxStreamController* p_controller, MxDSAction* p_action) override; // vtable+0x3c void VTable0x60(MxPresenter* p_presenter) override; // vtable+0x60 + MxResult FUN_10067360(ModelDbPart& p_part, FILE* p_wdbFile); + MxResult FUN_100674b0(ModelDbModel& p_model, FILE* p_wdbFile, LegoWorld* p_world); MxResult LoadWorld(char* p_worldName, LegoWorld* p_world); // SYNTHETIC: LEGO1 0x10066750 diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 62bc2574..c73006e8 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -187,7 +187,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) } } - ModelDbWorld* worlds; + ModelDbWorld* worlds = NULL; MxS32 numWorlds; FILE* wdbFile = fopen(wdbPath, "rb"); @@ -235,6 +235,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) return FAILURE; } + buff = new MxU8[size]; if (fread(&buff, size, 1, wdbFile) != 1) { return FAILURE; } @@ -257,6 +258,78 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) } } + ModelDbPartListCursor cursor(worlds[i].m_partList); + ModelDbPart* part; + + while (cursor.Next(part)) { + if (GetViewLODListManager()->Lookup(part->m_name.GetData()) == NULL && + FUN_10067360(*part, wdbFile) != SUCCESS) { + return FAILURE; + } + } + + for (MxS32 j = 0; j < worlds[i].m_numModels; j++) { + if (!strnicmp(worlds[i].m_models[j].m_modelName, "isle", 4)) { + switch (g_legoWorldPresenterQuality) { + case 0: + if (strcmpi(worlds[i].m_models[j].m_modelName, "isle_lo")) { + continue; + } + break; + case 1: + if (strcmpi(worlds[i].m_models[j].m_modelName, "isle")) { + continue; + } + break; + case 2: + if (strcmpi(worlds[i].m_models[j].m_modelName, "isle_hi")) { + continue; + } + break; + } + + if (FUN_100674b0(worlds[i].m_models[j], wdbFile, p_world) != SUCCESS) { + return FAILURE; + } + } + else { + if (g_legoWorldPresenterQuality < 1 && !strcmpi(worlds[i].m_models[j].m_modelName, "haus")) { + if (FUN_100674b0(worlds[i].m_models[j], wdbFile, p_world) != SUCCESS) { + return FAILURE; + } + } + else { + if (worlds[i].m_models[j].m_modelName[4] == '3') { + if (FUN_100674b0(worlds[i].m_models[j], wdbFile, p_world) != SUCCESS) { + return FAILURE; + } + + if (FUN_100674b0(worlds[i].m_models[j - 2], wdbFile, p_world) != SUCCESS) { + return FAILURE; + } + + if (FUN_100674b0(worlds[i].m_models[j - 1], wdbFile, p_world) != SUCCESS) { + return FAILURE; + } + } + } + } + } + + return SUCCESS; +} + +// STUB: LEGO1 0x10067360 +MxResult LegoWorldPresenter::FUN_10067360(ModelDbPart& p_part, FILE* p_wdbFile) +{ + // TODO + return SUCCESS; +} + +// STUB: LEGO1 0x100674b0 +MxResult LegoWorldPresenter::FUN_100674b0(ModelDbModel& p_model, FILE* p_wdbFile, LegoWorld* p_world) +{ + // TODO return SUCCESS; } diff --git a/LEGO1/library_msvc.h b/LEGO1/library_msvc.h index f08a4876..e819f995 100644 --- a/LEGO1/library_msvc.h +++ b/LEGO1/library_msvc.h @@ -78,6 +78,9 @@ // LIBRARY: LEGO1 0x1008c410 // _strlwr +// LIBRARY: LEGO1 0x1008c570 +// _access + // LIBRARY: LEGO1 0x1008c5c0 // _fseek diff --git a/LEGO1/modeldb/modeldb.cpp b/LEGO1/modeldb/modeldb.cpp index 2c83c588..78c4c629 100644 --- a/LEGO1/modeldb/modeldb.cpp +++ b/LEGO1/modeldb/modeldb.cpp @@ -3,6 +3,8 @@ DECOMP_SIZE_ASSERT(ModelDbWorld, 0x18) DECOMP_SIZE_ASSERT(ModelDbPart, 0x18) DECOMP_SIZE_ASSERT(ModelDbModel, 0x38) +DECOMP_SIZE_ASSERT(ModelDbPartList, 0x1c) +DECOMP_SIZE_ASSERT(ModelDbPartListCursor, 0x10) // STUB: LEGO1 0x100276b0 MxResult ModelDbModel::Read(FILE* p_file) diff --git a/LEGO1/modeldb/modeldb.h b/LEGO1/modeldb/modeldb.h index 40f6ecda..0bf6e7a2 100644 --- a/LEGO1/modeldb/modeldb.h +++ b/LEGO1/modeldb/modeldb.h @@ -49,6 +49,16 @@ class ModelDbPartList : public MxList { undefined m_unk0x18; }; +// VTABLE: LEGO1 0x100d68d0 +// class MxListCursor + +// VTABLE: LEGO1 0x100d68e8 +// SIZE 0x10 +class ModelDbPartListCursor : public MxListCursor { +public: + ModelDbPartListCursor(ModelDbPartList* p_list) : MxListCursor(p_list) {} +}; + // TEMPLATE: LEGO1 0x10027c70 // MxCollection::Compare @@ -67,11 +77,21 @@ class ModelDbPartList : public MxList { // SYNTHETIC: LEGO1 0x10027e50 // MxList::`scalar deleting destructor' +// SYNTHETIC: LEGO1 0x10027f00 +// ModelDbPartListCursor::`scalar deleting destructor' + +// TEMPLATE: LEGO1 0x10027f70 +// MxListCursor::~MxListCursor + +// SYNTHETIC: LEGO1 0x10027fc0 +// MxListCursor::`scalar deleting destructor' + // SIZE 0x38 struct ModelDbModel { MxResult Read(FILE* p_file); - undefined m_unk0x00[0x38]; // 0x00 + char* m_modelName; // 0x00 + undefined m_unk0x04[0x34]; // 0x04 }; // SIZE 0x18