From 4691b0253cac09c19fad7b902353e46a9f790b68 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Fri, 20 Jun 2025 06:53:42 +0200 Subject: [PATCH 01/16] Fix BETA10 linker settings (#1572) Co-authored-by: jonschz --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37aa52ce..064a207e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,7 +483,12 @@ if(ISLE_BUILD_BETA10) OUT_TARGETS beta10_targets ) reccmp_add_target(beta10 ID BETA10) + + # Enable `#ifdef BETA10` conditions target_compile_definitions(beta10 PRIVATE BETA10) + foreach(tgt IN LISTS beta10_targets) + target_compile_definitions(${tgt} PRIVATE BETA10) + endforeach() endif() if (ISLE_BUILD_APP) @@ -600,10 +605,13 @@ if (MSVC_FOR_DECOMP) endif() endif() + # Setting the MSVC_RUNTIME_LIBRARY for all libraries as well as `lego1` produces the results + # that are most consistent with the LEGO1.DLL and BETA10.DLL originals we have. + # Equivalent to target_compile_options(... PRIVATE "/MT$<$:d>") + set_property(TARGET ${lego1_targets} ${beta10_targets} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") if(TARGET lego1) target_link_options(lego1 PRIVATE "/OPT:REF") - # Equivalent to target_compile_options(... PRIVATE "/MT$<$:d>") - set_property(TARGET lego1 ${lego1_targets} ${beta10_targets} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET lego1 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() set(CMAKE_CXX_FLAGS "/W3 /GX /D \"WIN32\" /D \"_WINDOWS\"") From 72eb19442443624642ebaca746a3ade7859783a3 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Sat, 21 Jun 2025 01:24:32 +0200 Subject: [PATCH 02/16] Clear unknowns in `LegoAnimPresenter` and related classes (#1565) * Clear unknowns in `LegoAnimPresenter` and related classes * Update LEGO1/lego/legoomni/include/legoanimpresenter.h --------- Co-authored-by: Christian Semmler --- .../lego/legoomni/include/legoanimpresenter.h | 17 +-- .../src/build/legocarbuildpresenter.cpp | 8 +- .../legoomni/src/video/legoanimpresenter.cpp | 100 +++++++++--------- .../src/video/legohideanimpresenter.cpp | 6 +- .../src/video/legolocomotionanimpresenter.cpp | 6 +- LEGO1/lego/sources/anim/legoanim.cpp | 30 +++--- LEGO1/lego/sources/anim/legoanim.h | 32 +++--- LEGO1/lego/sources/roi/legoroi.cpp | 31 +++--- LEGO1/lego/sources/roi/legoroi.h | 9 +- 9 files changed, 127 insertions(+), 112 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index fce22592..85917cbc 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -103,12 +103,17 @@ class LegoAnimPresenter : public MxVideoPresenter { LegoChar* FUN_10069150(const LegoChar* p_und1); void FUN_100692b0(); void FUN_100695c0(); - LegoChar* FUN_100697c0(const LegoChar* p_und1, const LegoChar* p_und2); + LegoChar* GetVariableOrIdentity(const LegoChar* p_varName, const LegoChar* p_prefix); LegoBool FUN_100698b0(const CompoundObject& p_rois, const LegoChar* p_und2); - LegoROI* FUN_100699e0(const LegoChar* p_und); + LegoROI* FindROI(const LegoChar* p_name); void FUN_10069b10(); - void FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi); - void FUN_1006a4f0(LegoAnimStructMap& p_map, LegoAnimNodeData* p_data, const LegoChar* p_und, LegoROI* p_roi); + void UpdateStructMapAndROIIndex(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi); + void UpdateStructMapAndROIIndexForNode( + LegoAnimStructMap& p_map, + LegoAnimNodeData* p_data, + const LegoChar* p_und, + LegoROI* p_roi + ); void FUN_1006aa60(); void FUN_1006ab70(); LegoBool FUN_1006aba0(); @@ -121,8 +126,8 @@ class LegoAnimPresenter : public MxVideoPresenter { LegoAnim* m_anim; // 0x64 LegoROI** m_roiMap; // 0x68 MxU32 m_roiMapSize; // 0x6c - LegoROIList* m_unk0x70; // 0x70 - LegoROIList* m_unk0x74; // 0x74 + LegoROIList* m_sceneROIs; // 0x70 + LegoROIList* m_managedActors; // 0x74 Matrix4* m_unk0x78; // 0x78 MxU32 m_flags; // 0x7c LegoWorld* m_currentWorld; // 0x80 diff --git a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp index 2dd76641..87c896dc 100644 --- a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp +++ b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp @@ -336,9 +336,9 @@ void LegoCarBuildAnimPresenter::SwapNodesByName(LegoChar* p_name1, LegoChar* p_n strcpy(node1->GetName(), node2->GetName()); strcpy(node2->GetName(), buffer); - LegoU16 val1 = node1->GetUnknown0x20(); - node1->SetUnknown0x20(node2->GetUnknown0x20()); - node2->SetUnknown0x20(val1); + LegoU16 val1 = node1->GetROIIndex(); + node1->SetROIIndex(node2->GetROIIndex()); + node2->SetROIIndex(val1); } } @@ -456,7 +456,7 @@ void LegoCarBuildAnimPresenter::FUN_100795d0(LegoChar* p_param) assert(newHideKey); newHideKey->SetTime(0); - newHideKey->SetUnknown0x08(FALSE); + newHideKey->SetVisible(FALSE); data->SetNumMorphKeys(1); data->SetMorphKeys(newHideKey); diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 51835a42..54b1da70 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -47,8 +47,8 @@ void LegoAnimPresenter::Init() m_anim = NULL; m_roiMap = NULL; m_roiMapSize = 0; - m_unk0x74 = NULL; - m_unk0x70 = NULL; + m_managedActors = NULL; + m_sceneROIs = NULL; m_unk0x78 = NULL; m_flags = 0; m_unk0xa8.Clear(); @@ -81,13 +81,13 @@ void LegoAnimPresenter::Destroy(MxBool p_fromDestructor) delete[] m_roiMap; } - if (m_unk0x70 != NULL) { - delete m_unk0x70; + if (m_sceneROIs != NULL) { + delete m_sceneROIs; } - if (m_unk0x74 != NULL) { + if (m_managedActors != NULL) { FUN_1006aa60(); - delete m_unk0x74; + delete m_managedActors; } if (m_unk0x78 != NULL) { @@ -214,13 +214,13 @@ LegoChar* LegoAnimPresenter::FUN_10069150(const LegoChar* p_und1) // FUNCTION: LEGO1 0x100692b0 void LegoAnimPresenter::FUN_100692b0() { - m_unk0x74 = new LegoROIList(); + m_managedActors = new LegoROIList(); - if (m_unk0x74) { + if (m_managedActors) { LegoU32 numActors = m_anim->GetNumActors(); for (LegoU32 i = 0; i < numActors; i++) { - LegoChar* str = FUN_100697c0(m_anim->GetActorName(i), NULL); + LegoChar* str = GetVariableOrIdentity(m_anim->GetActorName(i), NULL); undefined4 unk0x04 = m_anim->GetActorUnknown0x04(i); LegoROI* roi = NULL; @@ -280,7 +280,7 @@ void LegoAnimPresenter::FUN_100692b0() } if (roi != NULL) { - m_unk0x74->Append(roi); + m_managedActors->Append(roi); } delete[] str; @@ -292,9 +292,9 @@ void LegoAnimPresenter::FUN_100692b0() // FUNCTION: BETA10 0x1004f359 void LegoAnimPresenter::FUN_100695c0() { - m_unk0x70 = new LegoROIList(); + m_sceneROIs = new LegoROIList(); - if (m_unk0x70) { + if (m_sceneROIs) { const CompoundObject& rois = VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->GetROIs(); LegoU32 numActors = m_anim->GetNumActors(); @@ -324,23 +324,23 @@ void LegoAnimPresenter::FUN_100695c0() } // FUNCTION: LEGO1 0x100697c0 -LegoChar* LegoAnimPresenter::FUN_100697c0(const LegoChar* p_und1, const LegoChar* p_und2) +LegoChar* LegoAnimPresenter::GetVariableOrIdentity(const LegoChar* p_varName, const LegoChar* p_prefix) { - const LegoChar* str = p_und1; - const char* var = VariableTable()->GetVariable(p_und1); + const LegoChar* str = p_varName; + const char* var = VariableTable()->GetVariable(p_varName); if (*var) { str = var; } - LegoU32 len = strlen(str) + (p_und2 ? strlen(p_und2) : 0) + 2; + LegoU32 len = strlen(str) + (p_prefix ? strlen(p_prefix) : 0) + 2; LegoChar* result = new LegoChar[len]; if (result != NULL) { *result = '\0'; - if (p_und2) { - strcpy(result, p_und2); + if (p_prefix) { + strcpy(result, p_prefix); strcat(result, ":"); } @@ -356,7 +356,7 @@ LegoBool LegoAnimPresenter::FUN_100698b0(const CompoundObject& p_rois, const Leg LegoBool result = FALSE; LegoChar* str; - if (*(str = FUN_100697c0(p_und2, NULL)) == '*') { + if (*(str = GetVariableOrIdentity(p_und2, NULL)) == '*') { LegoChar* tmp = FUN_10069150(str); delete[] str; str = tmp; @@ -369,7 +369,7 @@ LegoBool LegoAnimPresenter::FUN_100698b0(const CompoundObject& p_rois, const Leg if (name != NULL) { if (!strcmpi(name, str)) { - m_unk0x70->Append(roi); + m_sceneROIs->Append(roi); result = TRUE; break; } @@ -382,20 +382,20 @@ LegoBool LegoAnimPresenter::FUN_100698b0(const CompoundObject& p_rois, const Leg } // FUNCTION: LEGO1 0x100699e0 -LegoROI* LegoAnimPresenter::FUN_100699e0(const LegoChar* p_und) +LegoROI* LegoAnimPresenter::FindROI(const LegoChar* p_name) { - LegoROIListCursor cursor(m_unk0x70); + LegoROIListCursor cursor(m_sceneROIs); LegoROI* roi; while (cursor.Next(roi)) { - LegoChar* und = FUN_100697c0(roi->GetName(), NULL); + LegoChar* nameOrVar = GetVariableOrIdentity(roi->GetName(), NULL); - if (und != NULL && !strcmpi(und, p_und)) { - delete[] und; + if (nameOrVar != NULL && !strcmpi(nameOrVar, p_name)) { + delete[] nameOrVar; return roi; } - delete[] und; + delete[] nameOrVar; } return NULL; @@ -410,7 +410,7 @@ void LegoAnimPresenter::FUN_10069b10() memset(m_unk0x8c, 0, m_unk0x94 * sizeof(*m_unk0x8c)); } - FUN_1006a3c0(anims, m_anim->GetRoot(), NULL); + UpdateStructMapAndROIIndex(anims, m_anim->GetRoot(), NULL); if (m_roiMap != NULL) { delete[] m_roiMap; @@ -443,7 +443,7 @@ void LegoAnimPresenter::FUN_10069b10() } // FUNCTION: LEGO1 0x1006a3c0 -void LegoAnimPresenter::FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi) +void LegoAnimPresenter::UpdateStructMapAndROIIndex(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi) { LegoROI* roi = p_roi; LegoChar* und = NULL; @@ -456,27 +456,27 @@ void LegoAnimPresenter::FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_n name = und2 = FUN_10069150(name); } - und = FUN_100697c0(name, p_roi != NULL ? p_roi->GetName() : NULL); + und = GetVariableOrIdentity(name, p_roi != NULL ? p_roi->GetName() : NULL); if (p_roi == NULL) { - roi = FUN_100699e0(und); + roi = FindROI(und); if (roi != NULL) { - FUN_1006a4f0(p_map, data, und, roi); + UpdateStructMapAndROIIndexForNode(p_map, data, und, roi); } else { - data->SetUnknown0x20(0); + data->SetROIIndex(0); } } else { LegoROI* child = p_roi->FindChildROI(name, p_roi); if (child != NULL) { - FUN_1006a4f0(p_map, data, und, child); + UpdateStructMapAndROIIndexForNode(p_map, data, und, child); } else { - if (FUN_100699e0(name) != NULL) { - FUN_1006a3c0(p_map, p_node, NULL); + if (FindROI(name) != NULL) { + UpdateStructMapAndROIIndex(p_map, p_node, NULL); delete[] und; delete[] und2; return; @@ -490,12 +490,12 @@ void LegoAnimPresenter::FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_n MxS32 count = p_node->GetNumChildren(); for (MxS32 i = 0; i < count; i++) { - FUN_1006a3c0(p_map, p_node->GetChild(i), roi); + UpdateStructMapAndROIIndex(p_map, p_node->GetChild(i), roi); } } // FUNCTION: LEGO1 0x1006a4f0 -void LegoAnimPresenter::FUN_1006a4f0( +void LegoAnimPresenter::UpdateStructMapAndROIIndexForNode( LegoAnimStructMap& p_map, LegoAnimNodeData* p_data, const LegoChar* p_und, @@ -510,7 +510,7 @@ void LegoAnimPresenter::FUN_1006a4f0( animStruct.m_index = p_map.size() + 1; animStruct.m_roi = p_roi; - p_data->SetUnknown0x20(animStruct.m_index); + p_data->SetROIIndex(animStruct.m_index); LegoChar* und = new LegoChar[strlen(p_und) + 1]; strcpy(und, p_und); @@ -518,7 +518,7 @@ void LegoAnimPresenter::FUN_1006a4f0( p_map[und] = animStruct; } else { - p_data->SetUnknown0x20((*it).second.m_index); + p_data->SetROIIndex((*it).second.m_index); } } @@ -526,7 +526,7 @@ void LegoAnimPresenter::FUN_1006a4f0( // FUNCTION: BETA10 0x1004feee void LegoAnimPresenter::FUN_1006aa60() { - LegoROIListCursor cursor(m_unk0x74); + LegoROIListCursor cursor(m_managedActors); LegoROI* roi; while (cursor.Next(roi)) { @@ -542,10 +542,10 @@ void LegoAnimPresenter::FUN_1006aa60() void LegoAnimPresenter::FUN_1006ab70() { if (m_unk0x96) { - AnimationManager()->FUN_10063270(m_unk0x74, this); + AnimationManager()->FUN_10063270(m_managedActors, this); } else { - AnimationManager()->FUN_10063780(m_unk0x74); + AnimationManager()->FUN_10063780(m_managedActors); } } @@ -565,10 +565,10 @@ MxBool LegoAnimPresenter::FUN_1006abb0(LegoTreeNode* p_node, LegoROI* p_roi) MxS32 i, count; if (name != NULL && *name != '-') { - und = FUN_100697c0(name, p_roi != NULL ? p_roi->GetName() : NULL); + und = GetVariableOrIdentity(name, p_roi != NULL ? p_roi->GetName() : NULL); if (p_roi == NULL) { - roi = FUN_100699e0(und); + roi = FindROI(und); if (roi == NULL) { goto done; @@ -578,7 +578,7 @@ MxBool LegoAnimPresenter::FUN_1006abb0(LegoTreeNode* p_node, LegoROI* p_roi) LegoROI* child = p_roi->FindChildROI(name, p_roi); if (child == NULL) { - if (FUN_100699e0(name) != NULL) { + if (FindROI(name) != NULL) { if (FUN_1006abb0(p_node, NULL)) { result = TRUE; } @@ -828,9 +828,9 @@ void LegoAnimPresenter::StartingTickle() VTable0x8c(); done: - if (m_unk0x70 != NULL) { - delete m_unk0x70; - m_unk0x70 = NULL; + if (m_sceneROIs != NULL) { + delete m_sceneROIs; + m_sceneROIs = NULL; } } @@ -893,7 +893,7 @@ void LegoAnimPresenter::FUN_1006b900(LegoAnim* p_anim, MxLong p_time, Matrix4* p mat = *p_matrix; } else { - LegoROI* roi = m_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = m_roiMap[data->GetROIIndex()]; if (roi != NULL) { mat = roi->GetLocal2World(); @@ -918,7 +918,7 @@ void LegoAnimPresenter::FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, Matrix4* p mat = *p_matrix; } else { - LegoROI* roi = m_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = m_roiMap[data->GetROIIndex()]; if (roi != NULL) { mat = roi->GetLocal2World(); diff --git a/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp index 64a06a08..89768b3e 100644 --- a/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp @@ -104,10 +104,10 @@ void LegoHideAnimPresenter::FUN_1006db60(LegoTreeNode* p_node, LegoTime p_time) MxBool previousB = FALSE; if (m_roiMap != NULL) { - LegoROI* roi = m_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = m_roiMap[data->GetROIIndex()]; if (roi != NULL) { - newB = data->FUN_100a0990(p_time); + newB = data->GetVisibility(p_time); previousB = roi->GetVisibility(); roi->SetVisibility(newB); } @@ -117,7 +117,7 @@ void LegoHideAnimPresenter::FUN_1006db60(LegoTreeNode* p_node, LegoTime p_time) LegoPathBoundary* boundary = m_boundaryMap[data->GetUnknown0x22()]; if (boundary != NULL) { - newB = data->FUN_100a0990(p_time); + newB = data->GetVisibility(p_time); previousB = boundary->GetFlag0x10(); boundary->SetFlag0x10(newB); } diff --git a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp index 0272e50d..90b98e91 100644 --- a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp @@ -157,8 +157,8 @@ void LegoLocomotionAnimPresenter::FUN_1006d680(LegoAnimActor* p_actor, MxFloat p variableTable->SetVariable(key, ""); - if (m_unk0x70 != NULL) { - delete m_unk0x70; - m_unk0x70 = NULL; + if (m_sceneROIs != NULL) { + delete m_sceneROIs; + m_sceneROIs = NULL; } } diff --git a/LEGO1/lego/sources/anim/legoanim.cpp b/LEGO1/lego/sources/anim/legoanim.cpp index 152bce19..3b8caafc 100644 --- a/LEGO1/lego/sources/anim/legoanim.cpp +++ b/LEGO1/lego/sources/anim/legoanim.cpp @@ -348,7 +348,7 @@ LegoResult LegoTranslationKey::Read(LegoStorage* p_storage) } if (m_x > 1e-05F || m_x < -1e-05F || m_y > 1e-05F || m_y < -1e-05F || m_z > 1e-05F || m_z < -1e-05F) { - m_flags |= c_bit1; + m_flags |= c_active; } return SUCCESS; @@ -415,7 +415,7 @@ LegoResult LegoRotationKey::Read(LegoStorage* p_storage) } if (m_angle != 1.0F) { - m_flags |= c_bit1; + m_flags |= c_active; } return SUCCESS; @@ -480,7 +480,7 @@ LegoResult LegoScaleKey::Read(LegoStorage* p_storage) } if (m_x > 1.00001 || m_x < 0.99999 || m_y > 1.00001 || m_y < 0.99999 || m_z > 1.00001 || m_z < 0.99999) { - m_flags |= c_bit1; + m_flags |= c_active; } return SUCCESS; @@ -522,7 +522,7 @@ LegoAnimNodeData::LegoAnimNodeData() m_name = NULL; m_translationKeys = NULL; - m_unk0x20 = 0; + m_roiIndex = 0; m_rotationKeys = NULL; m_unk0x22 = 0; m_scaleKeys = NULL; @@ -785,7 +785,7 @@ inline void LegoAnimNodeData::GetTranslation( case 0: return; case 1: - if (!p_translationKeys[i].TestBit1()) { + if (!p_translationKeys[i].IsActive()) { return; } @@ -794,7 +794,7 @@ inline void LegoAnimNodeData::GetTranslation( z = p_translationKeys[i].GetZ(); break; case 2: - if (!p_translationKeys[i].TestBit1() && !p_translationKeys[i + 1].TestBit1()) { + if (!p_translationKeys[i].IsActive() && !p_translationKeys[i + 1].IsActive()) { return; } @@ -841,7 +841,7 @@ inline void LegoAnimNodeData::GetTranslation( case 0: return; case 1: - if (p_rotationKeys[i].TestBit1()) { + if (p_rotationKeys[i].IsActive()) { p_matrix.FromQuaternion(Mx4DPointFloat( p_rotationKeys[i].GetX(), p_rotationKeys[i].GetY(), @@ -854,19 +854,19 @@ inline void LegoAnimNodeData::GetTranslation( Mx4DPointFloat a; MxQuaternionTransformer b; - if (p_rotationKeys[i].TestBit1() || p_rotationKeys[i + 1].TestBit1()) { + if (p_rotationKeys[i].IsActive() || p_rotationKeys[i + 1].IsActive()) { a[0] = p_rotationKeys[i].GetX(); a[1] = p_rotationKeys[i].GetY(); a[2] = p_rotationKeys[i].GetZ(); a[3] = p_rotationKeys[i].GetAngle(); - if (p_rotationKeys[i + 1].TestBit3()) { + if (p_rotationKeys[i + 1].ShouldSkipInterpolation()) { p_matrix.FromQuaternion(a); return; } Mx4DPointFloat c; - if (p_rotationKeys[i + 1].TestBit2()) { + if (p_rotationKeys[i + 1].ShouldNegateRotation()) { c[0] = -p_rotationKeys[i + 1].GetX(); c[1] = -p_rotationKeys[i + 1].GetY(); c[2] = -p_rotationKeys[i + 1].GetZ(); @@ -920,7 +920,7 @@ inline void LegoAnimNodeData::GetScale( } // FUNCTION: LEGO1 0x100a0990 -LegoBool LegoAnimNodeData::FUN_100a0990(LegoFloat p_time) +LegoBool LegoAnimNodeData::GetVisibility(LegoFloat p_time) { LegoU32 i, n; LegoU32 index = GetMorphIndex(); @@ -935,7 +935,7 @@ LegoBool LegoAnimNodeData::FUN_100a0990(LegoFloat p_time) break; case 1: case 2: - result = m_morphKeys[i].GetUnknown0x08(); + result = m_morphKeys[i].IsVisible(); break; } @@ -1171,7 +1171,7 @@ undefined4 LegoAnim::GetActorUnknown0x04(LegoU32 p_index) // FUNCTION: BETA10 0x1018027c LegoMorphKey::LegoMorphKey() { - m_unk0x08 = 0; + m_visible = FALSE; } // FUNCTION: LEGO1 0x100a0f70 @@ -1183,7 +1183,7 @@ LegoResult LegoMorphKey::Read(LegoStorage* p_storage) return result; } - if ((result = p_storage->Read(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) { + if ((result = p_storage->Read(&m_visible, sizeof(LegoU8))) != SUCCESS) { return result; } @@ -1200,7 +1200,7 @@ LegoResult LegoMorphKey::Write(LegoStorage* p_storage) return result; } - if ((result = p_storage->Write(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) { + if ((result = p_storage->Write(&m_visible, sizeof(LegoU8))) != SUCCESS) { return result; } diff --git a/LEGO1/lego/sources/anim/legoanim.h b/LEGO1/lego/sources/anim/legoanim.h index 0df350a9..9b81b531 100644 --- a/LEGO1/lego/sources/anim/legoanim.h +++ b/LEGO1/lego/sources/anim/legoanim.h @@ -11,9 +11,9 @@ class Matrix4; class LegoAnimKey { public: enum Flags { - c_bit1 = 0x01, - c_bit2 = 0x02, - c_bit3 = 0x04 + c_active = 0x01, + c_negateRotation = 0x02, + c_skipInterpolation = 0x04 }; LegoAnimKey(); @@ -25,18 +25,18 @@ class LegoAnimKey { // FUNCTION: BETA10 0x100738a0 void SetTime(MxS32 p_time) { m_time = p_time; } - LegoU32 TestBit1() { return m_flags & c_bit1; } - LegoU32 TestBit2() { return m_flags & c_bit2; } - LegoU32 TestBit3() { return m_flags & c_bit3; } + LegoU32 IsActive() { return m_flags & c_active; } + LegoU32 ShouldNegateRotation() { return m_flags & c_negateRotation; } + LegoU32 ShouldSkipInterpolation() { return m_flags & c_skipInterpolation; } // FUNCTION: BETA10 0x100739a0 void FUN_100739a0(MxS32 p_param) { if (p_param) { - m_flags |= c_bit1; + m_flags |= c_active; } else { - m_flags &= ~c_bit1; + m_flags &= ~c_active; } } @@ -127,13 +127,13 @@ class LegoMorphKey : public LegoAnimKey { LegoMorphKey(); LegoResult Read(LegoStorage* p_storage); LegoResult Write(LegoStorage* p_storage); - LegoBool GetUnknown0x08() { return m_unk0x08; } + LegoBool IsVisible() { return m_visible; } // FUNCTION: BETA10 0x100738d0 - void SetUnknown0x08(LegoBool p_unk0x08) { m_unk0x08 = p_unk0x08; } + void SetVisible(LegoBool p_visible) { m_visible = p_visible; } protected: - LegoBool m_unk0x08; // 0x08 + LegoBool m_visible; // 0x08 }; // SIZE 0x0c @@ -160,7 +160,7 @@ class LegoAnimNodeData : public LegoTreeNodeData { void SetName(LegoChar* p_name); LegoResult CreateLocalTransform(LegoFloat p_time, Matrix4& p_matrix); - LegoBool FUN_100a0990(LegoFloat p_time); + LegoBool GetVisibility(LegoFloat p_time); // FUNCTION: BETA10 0x100595d0 LegoChar* GetName() { return m_name; } @@ -187,7 +187,7 @@ class LegoAnimNodeData : public LegoTreeNodeData { LegoU32 GetMorphIndex() { return m_morphIndex; } // FUNCTION: BETA10 0x1005abc0 - LegoU16 GetUnknown0x20() { return m_unk0x20; } + LegoU16 GetROIIndex() { return m_roiIndex; } // FUNCTION: BETA10 0x1005d5c0 LegoU16 GetUnknown0x22() { return m_unk0x22; } @@ -214,7 +214,7 @@ class LegoAnimNodeData : public LegoTreeNodeData { void SetNumMorphKeys(LegoU16 p_numMorphKeys) { m_numMorphKeys = p_numMorphKeys; } // FUNCTION: BETA10 0x10059600 - void SetUnknown0x20(LegoU16 p_unk0x20) { m_unk0x20 = p_unk0x20; } + void SetROIIndex(LegoU16 p_roiIndex) { m_roiIndex = p_roiIndex; } // FUNCTION: BETA10 0x1005f2e0 void SetUnknown0x22(LegoU16 p_unk0x22) { m_unk0x22 = p_unk0x22; } @@ -225,7 +225,7 @@ class LegoAnimNodeData : public LegoTreeNodeData { } // FUNCTION: BETA10 0x1005d580 - LegoBool FUN_100a0990(LegoTime p_time) { return FUN_100a0990((LegoFloat) p_time); } + LegoBool GetVisibility(LegoTime p_time) { return GetVisibility((LegoFloat) p_time); } inline static void GetTranslation( LegoU16 p_numTranslationKeys, @@ -279,7 +279,7 @@ class LegoAnimNodeData : public LegoTreeNodeData { LegoRotationKey* m_rotationKeys; // 0x14 LegoScaleKey* m_scaleKeys; // 0x18 LegoMorphKey* m_morphKeys; // 0x1c - LegoU16 m_unk0x20; // 0x20 + LegoU16 m_roiIndex; // 0x20 LegoU16 m_unk0x22; // 0x22 LegoU32 m_translationIndex; // 0x24 LegoU32 m_rotationIndex; // 0x28 diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index fd5d3e88..dd72f7f0 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -337,7 +337,7 @@ LegoResult LegoROI::Read( } // FUNCTION: LEGO1 0x100a8cb0 -LegoResult LegoROI::FUN_100a8cb0(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix) +LegoResult LegoROI::CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix) { p_matrix.SetIdentity(); p_data->CreateLocalTransform(p_time, p_matrix); @@ -379,27 +379,32 @@ LegoROI* LegoROI::FindChildROI(const LegoChar* p_name, LegoROI* p_roi) } // FUNCTION: LEGO1 0x100a8da0 -LegoResult LegoROI::FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi) +LegoResult LegoROI::ApplyAnimationTransformation( + LegoTreeNode* p_node, + const Matrix4& p_matrix, + LegoTime p_time, + LegoROI* p_parentROI +) { MxMatrix mat; LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData(); const LegoChar* name = data->GetName(); - LegoROI* roi = FindChildROI(name, p_roi); + LegoROI* roi = FindChildROI(name, p_parentROI); if (roi == NULL) { roi = FindChildROI(name, this); } if (roi != NULL) { - FUN_100a8cb0(data, p_time, mat); + CreateLocalTransform(data, p_time, mat); roi->m_local2world.Product(mat, p_matrix); roi->UpdateWorldData(); - LegoBool und = data->FUN_100a0990(p_time); + LegoBool und = data->GetVisibility(p_time); roi->SetVisibility(und); for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) { - FUN_100a8da0(p_node->GetChild(i), roi->m_local2world, p_time, roi); + ApplyAnimationTransformation(p_node->GetChild(i), roi->m_local2world, p_time, roi); } } else { @@ -416,14 +421,14 @@ void LegoROI::FUN_100a8e80(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_t MxMatrix mat; LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData(); - FUN_100a8cb0(data, p_time, mat); + CreateLocalTransform(data, p_time, mat); - LegoROI* roi = p_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = p_roiMap[data->GetROIIndex()]; if (roi != NULL) { roi->m_local2world.Product(mat, p_matrix); roi->UpdateWorldData(); - LegoBool und = data->FUN_100a0990(p_time); + LegoBool und = data->GetVisibility(p_time); roi->SetVisibility(und); for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) { @@ -447,9 +452,9 @@ void LegoROI::FUN_100a8fd0(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_t MxMatrix mat; LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData(); - FUN_100a8cb0(data, p_time, mat); + CreateLocalTransform(data, p_time, mat); - LegoROI* roi = p_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = p_roiMap[data->GetROIIndex()]; if (roi != NULL) { roi->m_local2world.Product(mat, p_matrix); @@ -474,9 +479,9 @@ LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time) MxMatrix mat; mat = m_local2world; - mat.SetIdentity(); + mat.SetIdentity(); // this clears the matrix, assignment above is redundant - return FUN_100a8da0(root, mat, p_time, this); + return ApplyAnimationTransformation(root, mat, p_time, this); } // FUNCTION: LEGO1 0x100a9170 diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index f3a76899..28119c72 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -32,7 +32,12 @@ class LegoROI : public ViewROI { LegoStorage* p_storage ); LegoROI* FindChildROI(const LegoChar* p_name, LegoROI* p_roi); - LegoResult FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi); + LegoResult ApplyAnimationTransformation( + LegoTreeNode* p_node, + const Matrix4& p_matrix, + LegoTime p_time, + LegoROI* p_roi + ); static void FUN_100a8e80(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_time, LegoROI** p_roiMap); static void FUN_100a8fd0(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_time, LegoROI** p_roiMap); LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time); @@ -51,7 +56,7 @@ class LegoROI : public ViewROI { void ClearMeshOffset(); void SetDisplayBB(int p_displayBB); - static LegoResult FUN_100a8cb0(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix); + static LegoResult CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix); static void FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name); static void configureLegoROI(int p_roi); static void SetColorOverride(ColorOverride p_colorOverride); From f64af166c8cfe3ada0d2f3c0ec83bf06a5cc35fa Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Sat, 21 Jun 2025 07:52:24 +0200 Subject: [PATCH 03/16] Add BETA10 addresses for `LegoROI` and others (#1569) --------- Co-authored-by: jonschz --- LEGO1/lego/sources/anim/legoanim.cpp | 1 + LEGO1/lego/sources/roi/legoroi.cpp | 18 +++++++++++++- LEGO1/lego/sources/roi/legoroi.h | 11 +++++++-- LEGO1/realtime/orientableroi.cpp | 9 +++++++ LEGO1/realtime/orientableroi.h | 2 ++ LEGO1/realtime/roi.h | 20 ++++++++++++++++ LEGO1/viewmanager/viewroi.cpp | 35 ++++++++++++---------------- LEGO1/viewmanager/viewroi.h | 6 +++++ 8 files changed, 79 insertions(+), 23 deletions(-) diff --git a/LEGO1/lego/sources/anim/legoanim.cpp b/LEGO1/lego/sources/anim/legoanim.cpp index 3b8caafc..dc3c21da 100644 --- a/LEGO1/lego/sources/anim/legoanim.cpp +++ b/LEGO1/lego/sources/anim/legoanim.cpp @@ -725,6 +725,7 @@ void LegoAnimNodeData::SetName(LegoChar* p_name) } // FUNCTION: LEGO1 0x100a03c0 +// FUNCTION: BETA10 0x1017f254 LegoResult LegoAnimNodeData::CreateLocalTransform(LegoFloat p_time, Matrix4& p_matrix) { LegoU32 index; diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index dd72f7f0..97baaadf 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -58,8 +58,12 @@ ColorOverride g_colorOverride = NULL; TextureHandler g_textureHandler = NULL; // FUNCTION: LEGO1 0x100a81b0 -void LegoROI::FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name) +// FUNCTION: BETA10 0x101898c0 +// FUNCTION: ALPHA 0x100bb1c0 +void LegoROI::FUN_100a81b0(const LegoChar* p_error, ...) { + // Probably a printf-like debug function that was removed early. + // No known implementation in any of the binaries. } // FUNCTION: LEGO1 0x100a81c0 @@ -69,6 +73,7 @@ void LegoROI::configureLegoROI(int p_roiConfig) } // FUNCTION: LEGO1 0x100a81d0 +// FUNCTION: BETA10 0x101898e8 LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL) { m_parentROI = NULL; @@ -77,6 +82,7 @@ LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL) } // FUNCTION: LEGO1 0x100a82d0 +// FUNCTION: BETA10 0x10189994 LegoROI::LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList) : ViewROI(p_renderer, p_lodList) { m_parentROI = NULL; @@ -85,6 +91,7 @@ LegoROI::LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList) : ViewROI(p_ } // FUNCTION: LEGO1 0x100a83c0 +// FUNCTION: BETA10 0x10189a42 LegoROI::~LegoROI() { if (comp) { @@ -105,6 +112,7 @@ LegoROI::~LegoROI() } // FUNCTION: LEGO1 0x100a84a0 +// FUNCTION: BETA10 0x10189b99 LegoResult LegoROI::Read( OrientableROI* p_unk0xd4, Tgl::Renderer* p_renderer, @@ -337,6 +345,7 @@ LegoResult LegoROI::Read( } // FUNCTION: LEGO1 0x100a8cb0 +// FUNCTION: BETA10 0x1018a7e8 LegoResult LegoROI::CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix) { p_matrix.SetIdentity(); @@ -379,6 +388,7 @@ LegoROI* LegoROI::FindChildROI(const LegoChar* p_name, LegoROI* p_roi) } // FUNCTION: LEGO1 0x100a8da0 +// FUNCTION: BETA10 0x1018a9fb LegoResult LegoROI::ApplyAnimationTransformation( LegoTreeNode* p_node, const Matrix4& p_matrix, @@ -473,6 +483,7 @@ void LegoROI::FUN_100a8fd0(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_t } // FUNCTION: LEGO1 0x100a90f0 +// FUNCTION: BETA10 0x1018ada8 LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time) { LegoTreeNode* root = p_anim->GetRoot(); @@ -512,6 +523,7 @@ LegoResult LegoROI::SetLodColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_ } // FUNCTION: LEGO1 0x100a9210 +// FUNCTION: BETA10 0x1018af25 LegoResult LegoROI::SetTextureInfo(LegoTextureInfo* p_textureInfo) { LegoResult result = SUCCESS; @@ -735,6 +747,7 @@ LegoU32 LegoROI::FUN_100a9410( } // FUNCTION: LEGO1 0x100a9a50 +// FUNCTION: BETA10 0x1018bb6b TimeROI::TimeROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList, LegoTime p_time) : LegoROI(p_renderer, p_lodList) { m_time = p_time; @@ -760,6 +773,7 @@ void TimeROI::FUN_100a9b40(Matrix4& p_matrix, LegoTime p_time) } // FUNCTION: LEGO1 0x100a9bf0 +// FUNCTION: BETA10 0x1018bc93 LegoBool LegoROI::GetRGBAColor(const LegoChar* p_name, float& p_red, float& p_green, float& p_blue, float& p_alpha) { if (p_name == NULL) { @@ -850,12 +864,14 @@ void LegoROI::SetDisplayBB(int p_displayBB) } // FUNCTION: LEGO1 0x100aa340 +// FUNCTION: BETA10 0x1018cca0 float LegoROI::IntrinsicImportance() const { return .5; } // FUNCTION: LEGO1 0x100aa350 +// FUNCTION: BETA10 0x1018ccc0 void LegoROI::UpdateWorldBoundingVolumes() { CalcWorldBoundingVolumes(m_sphere, m_local2world, m_world_bounding_box, m_world_bounding_sphere); diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index 28119c72..216bb68d 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -17,6 +17,7 @@ class LegoTreeNode; struct LegoAnimActorEntry; // VTABLE: LEGO1 0x100dbe38 +// VTABLE: BETA10 0x101c3898 // SIZE 0x108 class LegoROI : public ViewROI { public: @@ -57,7 +58,7 @@ class LegoROI : public ViewROI { void SetDisplayBB(int p_displayBB); static LegoResult CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix); - static void FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name); + static void FUN_100a81b0(const LegoChar* p_error, ...); static void configureLegoROI(int p_roi); static void SetColorOverride(ColorOverride p_colorOverride); static LegoBool GetRGBAColor(const LegoChar* p_name, float& p_red, float& p_green, float& p_blue, float& p_alpha); @@ -86,6 +87,7 @@ class LegoROI : public ViewROI { void SetBoundingBox(const BoundingBox& p_box) { m_bounding_box = p_box; } // SYNTHETIC: LEGO1 0x100a82b0 + // SYNTHETIC: BETA10 0x1018c490 // LegoROI::`scalar deleting destructor' private: @@ -96,15 +98,20 @@ class LegoROI : public ViewROI { }; // VTABLE: LEGO1 0x100dbea8 +// VTABLE: BETA10 0x101c38d0 // SIZE 0x10c class TimeROI : public LegoROI { public: TimeROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList, LegoTime p_time); + void FUN_100a9b40(Matrix4& p_matrix, LegoTime p_time); + // SYNTHETIC: LEGO1 0x100a9ad0 + // SYNTHETIC: BETA10 0x1018c540 // TimeROI::`scalar deleting destructor' - void FUN_100a9b40(Matrix4& p_matrix, LegoTime p_time); + // SYNTHETIC: BETA10 0x1018c580 + // TimeROI::~TimeROI private: LegoTime m_time; // 0x108 diff --git a/LEGO1/realtime/orientableroi.cpp b/LEGO1/realtime/orientableroi.cpp index f479ca7d..92c9ac9e 100644 --- a/LEGO1/realtime/orientableroi.cpp +++ b/LEGO1/realtime/orientableroi.cpp @@ -108,6 +108,7 @@ void OrientableROI::SetLocal2World(const Matrix4& p_local2world) } // FUNCTION: LEGO1 0x100a5910 +// FUNCTION: BETA10 0x10167bac void OrientableROI::UpdateWorldData() { UpdateWorldBoundingVolumes(); @@ -115,6 +116,7 @@ void OrientableROI::UpdateWorldData() } // FUNCTION: LEGO1 0x100a5930 +// FUNCTION: BETA10 0x10167bd8 void OrientableROI::SetLocal2WorldWithWorldDataUpdate(const Matrix4& p_transform) { m_local2world = p_transform; @@ -123,6 +125,7 @@ void OrientableROI::SetLocal2WorldWithWorldDataUpdate(const Matrix4& p_transform } // FUNCTION: LEGO1 0x100a5960 +// FUNCTION: BETA10 0x10167c19 void OrientableROI::UpdateWorldDataWithTransform(const Matrix4& p_transform) { MxMatrix l_matrix(m_local2world); @@ -132,6 +135,7 @@ void OrientableROI::UpdateWorldDataWithTransform(const Matrix4& p_transform) } // FUNCTION: LEGO1 0x100a59b0 +// FUNCTION: BETA10 0x10167c6d void OrientableROI::UpdateWorldDataWithTransformAndChildren(const Matrix4& p_transform) { MxMatrix l_matrix(m_local2world); @@ -155,11 +159,13 @@ void OrientableROI::SetWorldVelocity(const Vector3& p_world_velocity) } // FUNCTION: LEGO1 0x100a5a50 +// FUNCTION: BETA10 0x10167d65 void OrientableROI::UpdateWorldVelocity() { } // FUNCTION: LEGO1 0x100a5a60 +// FUNCTION: BETA10 0x10167d7b void CalcWorldBoundingVolumes( const BoundingSphere& modelling_sphere, const Matrix4& local2world, @@ -186,18 +192,21 @@ void CalcWorldBoundingVolumes( } // FUNCTION: LEGO1 0x100a5d80 +// FUNCTION: BETA10 0x10168760 const float* OrientableROI::GetWorldVelocity() const { return m_world_velocity.GetData(); } // FUNCTION: LEGO1 0x100a5d90 +// FUNCTION: BETA10 0x10168790 const BoundingBox& OrientableROI::GetWorldBoundingBox() const { return m_world_bounding_box; } // FUNCTION: LEGO1 0x100a5da0 +// FUNCTION: BETA10 0x101687b0 const BoundingSphere& OrientableROI::GetWorldBoundingSphere() const { return m_world_bounding_sphere; diff --git a/LEGO1/realtime/orientableroi.h b/LEGO1/realtime/orientableroi.h index 031c5af7..c1354c50 100644 --- a/LEGO1/realtime/orientableroi.h +++ b/LEGO1/realtime/orientableroi.h @@ -23,6 +23,7 @@ class OrientableROI : public ROI { const BoundingSphere& GetWorldBoundingSphere() const override; // vtable+0x10 // FUNCTION: LEGO1 0x100a5db0 + // FUNCTION: BETA10 0x101687d0 virtual void WrappedUpdateWorldData() { UpdateWorldData(); } // vtable+0x14 virtual void UpdateWorldBoundingVolumes() = 0; // vtable+0x18 @@ -81,6 +82,7 @@ class OrientableROI : public ROI { // OrientableROI::`scalar deleting destructor' // SYNTHETIC: LEGO1 0x100aa2f0 +// SYNTHETIC: BETA10 0x10168600 // OrientableROI::~OrientableROI #endif // ORIENTABLEROI_H diff --git a/LEGO1/realtime/roi.h b/LEGO1/realtime/roi.h index 87cbe8f1..dd5b9993 100644 --- a/LEGO1/realtime/roi.h +++ b/LEGO1/realtime/roi.h @@ -15,9 +15,16 @@ // SIZE 0x28 class BoundingBox { public: + // The BETA10 matches may reference the wrong version + + // FUNCTION: BETA10 0x1004a7a0 const Vector3& Min() const { return min; } + Vector3& Min() { return min; } + + // FUNCTION: BETA10 0x1004a7c0 const Vector3& Max() const { return max; } + Vector3& Max() { return max; } private: @@ -31,14 +38,26 @@ class BoundingBox { // SIZE 0x18 class BoundingSphere { public: + // The BETA10 matches may reference the wrong version + + // FUNCTION: BETA10 0x1001fac0 const Vector3& Center() const { return center; } + + // FUNCTION: BETA10 0x100d55a0 Vector3& Center() { return center; } + + // FUNCTION: BETA10 0x1001fd30 const float& Radius() const { return radius; } + + // FUNCTION: BETA10 0x1001fae0 float& Radius() { return radius; } // SYNTHETIC: BETA10 0x1001fb90 // BoundingSphere::operator= + // SYNTHETIC: BETA10 0x1001fc50 + // BoundingSphere::BoundingSphere + private: Mx3DPointFloat center; // 0x00 float radius; // 0x14 @@ -136,6 +155,7 @@ class ROI { // list >::~list > // SYNTHETIC: LEGO1 0x100a5d50 +// SYNTHETIC: BETA10 0x101686a0 // ROI::~ROI #endif // ROI_H diff --git a/LEGO1/viewmanager/viewroi.cpp b/LEGO1/viewmanager/viewroi.cpp index 787e9078..05f636b6 100644 --- a/LEGO1/viewmanager/viewroi.cpp +++ b/LEGO1/viewmanager/viewroi.cpp @@ -16,65 +16,60 @@ float ViewROI::IntrinsicImportance() const } // for now // FUNCTION: LEGO1 0x100a9ec0 +// FUNCTION: BETA10 0x1018c740 Tgl::Group* ViewROI::GetGeometry() { return geometry; } // FUNCTION: LEGO1 0x100a9ed0 +// FUNCTION: BETA10 0x1018c760 const Tgl::Group* ViewROI::GetGeometry() const { return geometry; } // FUNCTION: LEGO1 0x100a9ee0 +// FUNCTION: BETA10 0x1018c780 void ViewROI::UpdateWorldDataWithTransformAndChildren(const Matrix4& parent2world) { OrientableROI::UpdateWorldDataWithTransformAndChildren(parent2world); + SetGeometryTransformation(); +} +// FUNCTION: BETA10 0x1018c7b0 +inline void ViewROI::SetGeometryTransformation() +{ if (geometry) { Tgl::FloatMatrix4 matrix; Matrix4 in(matrix); SETMAT4(in, m_local2world); - Tgl::Result result = geometry->SetTransformation(matrix); - // assert(Tgl::Succeeded(result)); + geometry->SetTransformation(matrix); } } // FUNCTION: LEGO1 0x100a9fc0 +// FUNCTION: BETA10 0x1018cad0 void ViewROI::UpdateWorldDataWithTransform(const Matrix4& p_transform) { OrientableROI::UpdateWorldDataWithTransform(p_transform); - if (geometry) { - Tgl::FloatMatrix4 matrix; - Matrix4 in(matrix); - SETMAT4(in, m_local2world); - geometry->SetTransformation(matrix); - } + SetGeometryTransformation(); } // FUNCTION: LEGO1 0x100aa0a0 +// FUNCTION: BETA10 0x1018cb00 void ViewROI::SetLocal2WorldWithWorldDataUpdate(const Matrix4& p_transform) { OrientableROI::SetLocal2WorldWithWorldDataUpdate(p_transform); - if (geometry) { - Tgl::FloatMatrix4 matrix; - Matrix4 in(matrix); - SETMAT4(in, m_local2world); - geometry->SetTransformation(matrix); - } + SetGeometryTransformation(); } // FUNCTION: LEGO1 0x100aa180 +// FUNCTION: BETA10 0x1018cb30 void ViewROI::UpdateWorldData() { OrientableROI::UpdateWorldData(); - if (geometry) { - Tgl::FloatMatrix4 matrix; - Matrix4 in(matrix); - SETMAT4(in, m_local2world); - geometry->SetTransformation(matrix); - } + SetGeometryTransformation(); } // FUNCTION: LEGO1 0x100aa500 diff --git a/LEGO1/viewmanager/viewroi.h b/LEGO1/viewmanager/viewroi.h index 63e82154..b7ba9564 100644 --- a/LEGO1/viewmanager/viewroi.h +++ b/LEGO1/viewmanager/viewroi.h @@ -13,6 +13,7 @@ */ // VTABLE: LEGO1 0x100dbe70 +// VTABLE: BETA10 0x101c3908 // SIZE 0xe4 class ViewROI : public OrientableROI { public: @@ -21,6 +22,7 @@ class ViewROI : public OrientableROI { c_lodLevelInvisible = -2, }; + // FUNCTION: BETA10 0x1018c5e0 ViewROI(Tgl::Renderer* pRenderer, ViewLODList* lodList) { SetLODList(lodList); @@ -29,6 +31,7 @@ class ViewROI : public OrientableROI { } // FUNCTION: LEGO1 0x100a9e20 + // FUNCTION: BETA10 0x1018c680 ~ViewROI() override { // SetLODList() will decrease refCount of LODList @@ -36,6 +39,7 @@ class ViewROI : public OrientableROI { delete geometry; } + // FUNCTION: BETA10 0x1007b540 void SetLODList(ViewLODList* lodList) { // ??? inherently type unsafe - kind of... because, now, ROI @@ -69,6 +73,8 @@ class ViewROI : public OrientableROI { protected: void UpdateWorldDataWithTransformAndChildren(const Matrix4& parent2world) override; // vtable+0x28 + void SetGeometryTransformation(); + Tgl::Group* geometry; // 0xdc int m_lodLevel; // 0xe0 }; From e3fc6fd13599082a8364d2e6c658e99813e41eba Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Sun, 22 Jun 2025 00:32:30 +0200 Subject: [PATCH 04/16] Use enum from `LegoActor` to map between string and id (#1577) --- LEGO1/lego/legoomni/src/common/legovariables.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legovariables.cpp b/LEGO1/lego/legoomni/src/common/legovariables.cpp index 68768e99..2c701074 100644 --- a/LEGO1/lego/legoomni/src/common/legovariables.cpp +++ b/LEGO1/lego/legoomni/src/common/legovariables.cpp @@ -1,6 +1,7 @@ #include "legovariables.h" #include "3dmanager/lego3dmanager.h" +#include "legoactor.h" #include "legogamestate.h" #include "legonavcontroller.h" #include "legovideomanager.h" @@ -157,18 +158,18 @@ void WhoAmIVariable::SetValue(const char* p_value) MxVariable::SetValue(p_value); if (!strcmpi(p_value, g_papa)) { - GameState()->SetActorId(3); + GameState()->SetActorId(LegoActor::c_papa); } else if (!strcmpi(p_value, g_mama)) { - GameState()->SetActorId(2); + GameState()->SetActorId(LegoActor::c_mama); } else if (!strcmpi(p_value, g_pepper)) { - GameState()->SetActorId(1); + GameState()->SetActorId(LegoActor::c_pepper); } else if (!strcmpi(p_value, g_nick)) { - GameState()->SetActorId(4); + GameState()->SetActorId(LegoActor::c_nick); } else if (!strcmpi(p_value, g_laura)) { - GameState()->SetActorId(5); + GameState()->SetActorId(LegoActor::c_laura); } } From 16db496832d8532fa7f5a44807fb3330cd18f2a4 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Sun, 22 Jun 2025 08:22:25 +0200 Subject: [PATCH 05/16] Match `LegoGameState::History::WriteScoreHistory()`, clear unknowns (#1576) --------- Co-authored-by: jonschz --- LEGO1/lego/legoomni/include/legogamestate.h | 26 ++- .../legoomni/src/common/legogamestate.cpp | 181 +++++++++++------- 2 files changed, 134 insertions(+), 73 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 1eec40a6..b81696fd 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -150,7 +150,18 @@ class LegoGameState { MxS16 m_totalScore; // 0x00 MxU8 m_scores[5][5]; // 0x02 Username m_name; // 0x1c - MxS16 m_unk0x2a; // 0x2a + MxS16 m_playerId; // 0x2a + + ScoreItem& operator=(const ScoreItem& p_other) + { + // MSVC auto-generates an operator=, but LegoGameState::WriteScoreHistory() has a much better match + // with a manual implementation. + m_totalScore = p_other.m_totalScore; + memcpy(m_scores, p_other.m_scores, sizeof(m_scores)); + m_name = p_other.m_name; + m_playerId = p_other.m_playerId; + return *this; + } }; // SIZE 0x372 @@ -158,7 +169,7 @@ class LegoGameState { History(); void WriteScoreHistory(); MxResult Serialize(LegoStorage* p_storage); - ScoreItem* FUN_1003cc90(Username* p_player, MxS16 p_unk0x24, MxS32& p_unk0x2c); + ScoreItem* FindPlayerInScoreHistory(Username* p_player, MxS16 p_unk0x24, MxS32& p_unk0x2c); // FUNCTION: BETA10 0x1002c2b0 MxS16 GetCount() { return m_count; } @@ -167,9 +178,12 @@ class LegoGameState { // FUNCTION: BETA10 0x1002c540 ScoreItem* GetScore(MxS32 p_index) { return p_index >= m_count ? NULL : &m_scores[p_index]; } - MxS16 m_count; // 0x00 - ScoreItem m_scores[20]; // 0x02 - MxS16 m_unk0x372; // 0x372 + MxS16 m_count; // 0x00 +#ifdef BETA10 + MxS16 m_indices[20]; // 0x02 +#endif + ScoreItem m_scores[20]; // 0x02 (0x22 for BETA10) + MxS16 m_nextPlayerId; // 0x372 (0x392 for BETA10) }; LegoGameState(); @@ -243,7 +257,7 @@ class LegoGameState { // TODO: Most likely getters/setters are not used according to BETA for the following members: public: - MxS16 m_unk0x24; // 0x24 + MxS16 m_currentPlayerId; // 0x24 MxS16 m_playerCount; // 0x26 Username m_players[9]; // 0x28 History m_history; // 0xa6 diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 99648947..9c67340c 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -277,7 +277,7 @@ MxResult LegoGameState::Save(MxULong p_slot) } storage.WriteS32(0x1000c); - storage.WriteS16(m_unk0x24); + storage.WriteS16(m_currentPlayerId); storage.WriteU16(m_currentAct); storage.WriteU8(m_actorId); @@ -372,7 +372,7 @@ MxResult LegoGameState::Load(MxULong p_slot) goto done; } - storage.ReadS16(m_unk0x24); + storage.ReadS16(m_currentPlayerId); storage.ReadS16(actArea); SetCurrentAct((Act) actArea); @@ -615,8 +615,8 @@ MxResult LegoGameState::AddPlayer(Username& p_player) m_playerCount++; m_players[0].Set(p_player); - m_unk0x24 = m_history.m_unk0x372; - m_history.m_unk0x372 = m_unk0x24 + 1; + m_currentPlayerId = m_history.m_nextPlayerId; + m_history.m_nextPlayerId = m_currentPlayerId + 1; m_history.WriteScoreHistory(); SetCurrentAct(e_act1); @@ -1407,7 +1407,7 @@ MxResult LegoGameState::ScoreItem::Serialize(LegoStorage* p_storage) } m_name.Serialize(p_storage); - p_storage->ReadS16(m_unk0x2a); + p_storage->ReadS16(m_playerId); } else if (p_storage->IsWriteMode()) { p_storage->WriteS16(m_totalScore); @@ -1419,7 +1419,7 @@ MxResult LegoGameState::ScoreItem::Serialize(LegoStorage* p_storage) } m_name.Serialize(p_storage); - p_storage->WriteS16(m_unk0x2a); + p_storage->WriteS16(m_playerId); } return SUCCESS; @@ -1430,7 +1430,7 @@ MxResult LegoGameState::ScoreItem::Serialize(LegoStorage* p_storage) LegoGameState::History::History() { m_count = 0; - m_unk0x372 = 0; + m_nextPlayerId = 0; } // FUNCTION: LEGO1 0x1003c870 @@ -1441,83 +1441,130 @@ void LegoGameState::History::WriteScoreHistory() MxU8 scores[5][5]; InfocenterState* state = (InfocenterState*) GameState()->GetState("InfocenterState"); - if (state->m_letters[0]) { - JetskiRaceState* jetskiRaceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState"); - CarRaceState* carRaceState = (CarRaceState*) GameState()->GetState("CarRaceState"); - TowTrackMissionState* towTrackMissionState = - (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState"); - PizzaMissionState* pizzaMissionState = (PizzaMissionState*) GameState()->GetState("PizzaMissionState"); - AmbulanceMissionState* ambulanceMissionState = - (AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState"); - for (MxS32 actor = 1; actor <= 5; actor++) { - scores[0][actor - 1] = carRaceState ? carRaceState->GetState(actor)->GetHighScore() : 0; - totalScore += scores[0][actor - 1]; + if (!state->m_letters[0]) { + return; + } - scores[1][actor - 1] = jetskiRaceState ? jetskiRaceState->GetState(actor)->GetHighScore() : 0; - totalScore += scores[1][actor - 1]; + JetskiRaceState* jetskiRaceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState"); + CarRaceState* carRaceState = (CarRaceState*) GameState()->GetState("CarRaceState"); + TowTrackMissionState* towTrackMissionState = (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState"); + PizzaMissionState* pizzaMissionState = (PizzaMissionState*) GameState()->GetState("PizzaMissionState"); + AmbulanceMissionState* ambulanceMissionState = + (AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState"); - scores[2][actor - 1] = pizzaMissionState ? pizzaMissionState->GetHighScore(actor) : 0; - totalScore += scores[2][actor - 1]; + for (MxS32 actor = 1; actor <= 5; actor++) { + scores[0][actor - 1] = carRaceState ? carRaceState->GetState(actor)->GetHighScore() : 0; + totalScore += scores[0][actor - 1]; - scores[3][actor - 1] = towTrackMissionState ? towTrackMissionState->GetHighScore(actor) : 0; - totalScore += scores[3][actor - 1]; +#ifdef BETA10 + // likely a bug in BETA10 + scores[1][actor - 1] = carRaceState ? carRaceState->GetState(actor)->GetHighScore() : 0; +#else + scores[1][actor - 1] = jetskiRaceState ? jetskiRaceState->GetState(actor)->GetHighScore() : 0; +#endif + totalScore += scores[1][actor - 1]; - scores[4][actor - 1] = ambulanceMissionState ? ambulanceMissionState->GetHighScore(actor) : 0; - totalScore += scores[4][actor - 1]; - } + scores[2][actor - 1] = pizzaMissionState ? pizzaMissionState->GetHighScore(actor) : 0; + totalScore += scores[2][actor - 1]; - MxS32 unk0x2c; - ScoreItem* p_scorehist = FUN_1003cc90(&GameState()->m_players[0], GameState()->m_unk0x24, unk0x2c); + scores[3][actor - 1] = towTrackMissionState ? towTrackMissionState->GetHighScore(actor) : 0; + totalScore += scores[3][actor - 1]; - if (p_scorehist != NULL) { - p_scorehist->m_totalScore = totalScore; - memcpy(p_scorehist->m_scores, scores, sizeof(p_scorehist->m_scores)); - } - else { - if (m_count < (MxS16) sizeOfArray(m_scores)) { - m_scores[m_count].m_totalScore = totalScore; - memcpy(m_scores[m_count].m_scores, scores, sizeof(m_scores[m_count].m_scores)); - m_scores[m_count].m_name = GameState()->m_players[0]; - m_scores[m_count].m_unk0x2a = GameState()->m_unk0x24; - m_count++; - } - else if (m_scores[19].m_totalScore <= totalScore) { - m_scores[19].m_totalScore = totalScore; - memcpy(m_scores[19].m_scores, scores, sizeof(m_scores[19].m_scores)); - m_scores[19].m_name = GameState()->m_players[0]; - m_scores[19].m_unk0x2a = GameState()->m_unk0x24; + scores[4][actor - 1] = ambulanceMissionState ? ambulanceMissionState->GetHighScore(actor) : 0; + totalScore += scores[4][actor - 1]; + } + + MxS32 playerScoreHistoryIndex; + ScoreItem* p_scorehist = + FindPlayerInScoreHistory(GameState()->m_players, GameState()->m_currentPlayerId, playerScoreHistoryIndex); + +#ifdef BETA10 + if (!p_scorehist) { + MxS32 playerScoreRank; + // LINE: BETA10 0x100870ee + for (playerScoreRank = 0; playerScoreRank < m_count; playerScoreRank++) { + if (totalScore > m_scores[m_indices[playerScoreRank]].m_totalScore) { + break; } } + // LINE: BETA10 0x1008713f + if (playerScoreRank < m_count) { + if (m_count < 20) { + playerScoreHistoryIndex = m_count++; + } + else { + playerScoreHistoryIndex = m_indices[19]; + } - MxU8 tmpScores[5][5]; - Username tmpPlayer; - MxS16 tmpUnk0x2a; + MxS32 max = m_count - 1; + for (MxS32 j = max; playerScoreRank < j; j--) { + m_indices[j - 1] = m_indices[j - 2]; + } - // TODO: Match bubble sort loops - for (MxS32 i = m_count - 1; i > 0; i--) { - for (MxS32 j = 1; j <= i; j++) { - if (m_scores[j - 1].m_totalScore < m_scores[j].m_totalScore) { - memcpy(tmpScores, m_scores[j - 1].m_scores, sizeof(tmpScores)); - tmpPlayer = m_scores[j - 1].m_name; - tmpUnk0x2a = m_scores[j - 1].m_unk0x2a; + m_indices[playerScoreRank] = playerScoreHistoryIndex; + p_scorehist = &m_scores[playerScoreHistoryIndex]; + } + else if (playerScoreRank < 20) { + m_indices[m_count] = m_count; + p_scorehist = &m_scores[m_count++]; + } + } + else if (p_scorehist->m_totalScore != totalScore) { + assert(totalScore > p_scorehist->m_totalScore); - memcpy(m_scores[j - 1].m_scores, m_scores[j].m_scores, sizeof(m_scores[j - 1].m_scores)); - m_scores[j - 1].m_name = m_scores[j].m_name; - m_scores[j - 1].m_unk0x2a = m_scores[j].m_unk0x2a; + for (MxS32 i = playerScoreHistoryIndex; i > 0 && m_indices[i - 1] < m_indices[i]; i--) { + MxU8 tmp = m_indices[i - 1]; + m_indices[i - 1] = m_indices[i]; + m_indices[i] = tmp; + } + } + if (p_scorehist) { + p_scorehist->m_totalScore = totalScore; + memcpy(p_scorehist->m_scores[0], scores[0], sizeof(scores)); + p_scorehist->m_name = GameState()->m_players[0]; + p_scorehist->m_playerId = GameState()->m_currentPlayerId; + } +#else + if (p_scorehist != NULL) { + p_scorehist->m_totalScore = totalScore; + memcpy(p_scorehist->m_scores, scores, sizeof(p_scorehist->m_scores)); + } + else { + if (m_count < (MxS16) sizeOfArray(m_scores)) { + assert(totalScore > p_scorehist->m_totalScore); - memcpy(m_scores[j].m_scores, tmpScores, sizeof(m_scores[j].m_scores)); - m_scores[j].m_name = tmpPlayer; - m_scores[j].m_unk0x2a = tmpUnk0x2a; - } + m_scores[m_count].m_totalScore = totalScore; + memcpy(m_scores[m_count].m_scores, scores, sizeof(m_scores[m_count].m_scores)); + m_scores[m_count].m_name = GameState()->m_players[0]; + m_scores[m_count].m_playerId = GameState()->m_currentPlayerId; + m_count++; + } + else if (m_scores[19].m_totalScore <= totalScore) { + m_scores[19].m_totalScore = totalScore; + memcpy(m_scores[19].m_scores, scores, sizeof(m_scores[19].m_scores)); + m_scores[19].m_name = GameState()->m_players[0]; + m_scores[19].m_playerId = GameState()->m_currentPlayerId; + } + } + + ScoreItem tmpItem; + + for (MxS32 i = m_count - 1; i >= 0; i--) { + for (MxS32 j = 1; j <= i; j++) { + if (m_scores[j].m_totalScore > m_scores[j - 1].m_totalScore) { + tmpItem = m_scores[j - 1]; + m_scores[j - 1] = m_scores[j]; + m_scores[j] = tmpItem; } } } +#endif } // FUNCTION: LEGO1 0x1003cc90 // FUNCTION: BETA10 0x1008732a -LegoGameState::ScoreItem* LegoGameState::History::FUN_1003cc90( +LegoGameState::ScoreItem* LegoGameState::History::FindPlayerInScoreHistory( LegoGameState::Username* p_player, MxS16 p_unk0x24, MxS32& p_unk0x2c @@ -1525,7 +1572,7 @@ LegoGameState::ScoreItem* LegoGameState::History::FUN_1003cc90( { MxS32 i = 0; for (; i < m_count; i++) { - if (!memcmp(p_player, &m_scores[i].m_name, sizeof(*p_player)) && m_scores[i].m_unk0x2a == p_unk0x24) { + if (!memcmp(p_player, &m_scores[i].m_name, sizeof(*p_player)) && m_scores[i].m_playerId == p_unk0x24) { break; } } @@ -1544,7 +1591,7 @@ LegoGameState::ScoreItem* LegoGameState::History::FUN_1003cc90( MxResult LegoGameState::History::Serialize(LegoStorage* p_storage) { if (p_storage->IsReadMode()) { - p_storage->ReadS16(m_unk0x372); + p_storage->ReadS16(m_nextPlayerId); p_storage->ReadS16(m_count); for (MxS16 i = 0; i < m_count; i++) { @@ -1554,7 +1601,7 @@ MxResult LegoGameState::History::Serialize(LegoStorage* p_storage) } } else if (p_storage->IsWriteMode()) { - p_storage->WriteS16(m_unk0x372); + p_storage->WriteS16(m_nextPlayerId); p_storage->WriteS16(m_count); for (MxS16 i = 0; i < m_count; i++) { From 2595537c4cbdaff80786beac32d51d0e10763347 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Sun, 22 Jun 2025 14:34:29 +0200 Subject: [PATCH 06/16] Clear unknowns in `LegoAnimActorEntry` and `LegoAnimKey` (#1580) --- .../src/build/legocarbuildpresenter.cpp | 4 ++-- .../legoomni/src/video/legoanimpresenter.cpp | 12 ++++++------ LEGO1/lego/sources/anim/legoanim.cpp | 8 ++++---- LEGO1/lego/sources/anim/legoanim.h | 18 +++++++++++++----- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp index 87c896dc..d6512c8b 100644 --- a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp +++ b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp @@ -577,10 +577,10 @@ void LegoCarBuildAnimPresenter::RotateAroundYAxis(MxFloat p_angle) newRotation.EqualsHamiltonProduct(currentRotation, additionalRotation); if (newRotation[3] < 0.9999) { - rotationKey->FUN_100739a0(TRUE); + rotationKey->SetActive(TRUE); } else { - rotationKey->FUN_100739a0(FALSE); + rotationKey->SetActive(FALSE); } m_platformAnimNodeData->GetRotationKey(0)->SetX(newRotation[0]); diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 54b1da70..852263fc 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -221,10 +221,10 @@ void LegoAnimPresenter::FUN_100692b0() for (LegoU32 i = 0; i < numActors; i++) { LegoChar* str = GetVariableOrIdentity(m_anim->GetActorName(i), NULL); - undefined4 unk0x04 = m_anim->GetActorUnknown0x04(i); + LegoU32 actorType = m_anim->GetActorType(i); LegoROI* roi = NULL; - if (unk0x04 == 2) { + if (actorType == LegoAnimActorEntry::e_actorType2) { LegoChar* src; if (str[0] == '*') { src = str + 1; @@ -239,7 +239,7 @@ void LegoAnimPresenter::FUN_100692b0() roi->SetVisibility(FALSE); } } - else if (unk0x04 == 4) { + else if (actorType == LegoAnimActorEntry::e_actorType4) { LegoChar* baseName = new LegoChar[strlen(str)]; strcpy(baseName, str + 1); strlwr(baseName); @@ -254,7 +254,7 @@ void LegoAnimPresenter::FUN_100692b0() delete[] baseName; delete[] und; } - else if (unk0x04 == 3) { + else if (actorType == LegoAnimActorEntry::e_actorType3) { LegoChar* lodName = new LegoChar[strlen(str)]; strcpy(lodName, str + 1); @@ -300,9 +300,9 @@ void LegoAnimPresenter::FUN_100695c0() for (LegoU32 i = 0; i < numActors; i++) { if (FUN_100698b0(rois, m_anim->GetActorName(i)) == FALSE) { - undefined4 unk0x04 = m_anim->GetActorUnknown0x04(i); + LegoU32 actorType = m_anim->GetActorType(i); - if (unk0x04 == 5 || unk0x04 == 6) { + if (actorType == LegoAnimActorEntry::e_actorType5 || actorType == LegoAnimActorEntry::e_actorType6) { LegoChar lodName[256]; const LegoChar* actorName = m_anim->GetActorName(i); diff --git a/LEGO1/lego/sources/anim/legoanim.cpp b/LEGO1/lego/sources/anim/legoanim.cpp index dc3c21da..8ec3ee2d 100644 --- a/LEGO1/lego/sources/anim/legoanim.cpp +++ b/LEGO1/lego/sources/anim/legoanim.cpp @@ -1063,7 +1063,7 @@ LegoResult LegoAnim::Read(LegoStorage* p_storage, LegoS32 p_parseScene) m_modelList[i].m_name[length] = '\0'; - if (p_storage->Read(&m_modelList[i].m_unk0x04, sizeof(undefined4)) != SUCCESS) { + if (p_storage->Read(&m_modelList[i].m_type, sizeof(LegoU32)) != SUCCESS) { goto done; } } @@ -1124,7 +1124,7 @@ LegoResult LegoAnim::Write(LegoStorage* p_storage) goto done; } - if (p_storage->Write(&m_modelList[i].m_unk0x04, sizeof(m_modelList[i].m_unk0x04)) != SUCCESS) { + if (p_storage->Write(&m_modelList[i].m_type, sizeof(m_modelList[i].m_type)) != SUCCESS) { goto done; } } @@ -1159,10 +1159,10 @@ const LegoChar* LegoAnim::GetActorName(LegoU32 p_index) // FUNCTION: LEGO1 0x100a0f40 // FUNCTION: BETA10 0x1018023c -undefined4 LegoAnim::GetActorUnknown0x04(LegoU32 p_index) +LegoU32 LegoAnim::GetActorType(LegoU32 p_index) { if (p_index < m_numActors) { - return m_modelList[p_index].m_unk0x04; + return m_modelList[p_index].m_type; } return 0; diff --git a/LEGO1/lego/sources/anim/legoanim.h b/LEGO1/lego/sources/anim/legoanim.h index 9b81b531..372128b5 100644 --- a/LEGO1/lego/sources/anim/legoanim.h +++ b/LEGO1/lego/sources/anim/legoanim.h @@ -30,9 +30,9 @@ class LegoAnimKey { LegoU32 ShouldSkipInterpolation() { return m_flags & c_skipInterpolation; } // FUNCTION: BETA10 0x100739a0 - void FUN_100739a0(MxS32 p_param) + void SetActive(MxS32 p_active) { - if (p_param) { + if (p_active) { m_flags |= c_active; } else { @@ -289,8 +289,16 @@ class LegoAnimNodeData : public LegoTreeNodeData { // SIZE 0x08 struct LegoAnimActorEntry { - LegoChar* m_name; // 0x00 - undefined4 m_unk0x04; // 0x04 + enum { + e_actorType2 = 2, + e_actorType3 = 3, + e_actorType4 = 4, + e_actorType5 = 5, + e_actorType6 = 6, + }; + + LegoChar* m_name; // 0x00 + LegoU32 m_type; // 0x04 }; // TODO: Possibly called `LegoCameraAnim(ation)`? @@ -338,7 +346,7 @@ class LegoAnim : public LegoTree { virtual LegoResult Read(LegoStorage* p_storage, LegoS32 p_parseScene); // vtable+0x10 const LegoChar* GetActorName(LegoU32 p_index); - undefined4 GetActorUnknown0x04(LegoU32 p_index); + LegoU32 GetActorType(LegoU32 p_index); // FUNCTION: BETA10 0x1005abf0 LegoAnimScene* GetCamAnim() { return m_camAnim; } From 0a5091531253edb05826fa12588d81e6219ee418 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 22 Jun 2025 08:55:36 -0700 Subject: [PATCH 07/16] Fix implicit signed char-ness (#1581) --- LEGO1/omni/src/video/flic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LEGO1/omni/src/video/flic.cpp b/LEGO1/omni/src/video/flic.cpp index afdebebc..d262e517 100644 --- a/LEGO1/omni/src/video/flic.cpp +++ b/LEGO1/omni/src/video/flic.cpp @@ -288,7 +288,7 @@ void DecodeBrun(LPBITMAPINFOHEADER p_bitmapHeader, BYTE* p_pixelData, BYTE* p_da while (--line >= 0) { short column = 0; data++; - char count = 0; + signed char count = 0; while ((column += count) < width2) { count = *data++; @@ -331,7 +331,7 @@ void DecodeLC(LPBITMAPINFOHEADER p_bitmapHeader, BYTE* p_pixelData, BYTE* p_data while (packets > 0) { column += *data++; // skip byte - char type = *((char*) data++); + signed char type = *((signed char*) data++); if (type < 0) { type = -type; @@ -417,7 +417,7 @@ void DecodeSS2(LPBITMAPINFOHEADER p_bitmapHeader, BYTE* p_pixelData, BYTE* p_dat // LINE: BETA10 0x1013e726 column += *data.byte++; // LINE: BETA10 0x1013e73a - short type = *(char*) data.byte++; + short type = *(signed char*) data.byte++; type += type; if (type >= 0) { From 8195d2b251b4b9436cabddc2b4c12e63ea35e88e Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 22 Jun 2025 09:48:09 -0700 Subject: [PATCH 08/16] Update legogamestate.cpp (#1582) --- LEGO1/lego/legoomni/src/common/legogamestate.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 9c67340c..0a2c452a 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -1532,8 +1532,6 @@ void LegoGameState::History::WriteScoreHistory() } else { if (m_count < (MxS16) sizeOfArray(m_scores)) { - assert(totalScore > p_scorehist->m_totalScore); - m_scores[m_count].m_totalScore = totalScore; memcpy(m_scores[m_count].m_scores, scores, sizeof(m_scores[m_count].m_scores)); m_scores[m_count].m_name = GameState()->m_players[0]; From 1677193635a650c4275fa73f73ecb7e7f573d825 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Mon, 23 Jun 2025 12:32:19 +0200 Subject: [PATCH 09/16] Add reference to `isle-portable` to README (#1579) * Add reference to `isle-portable` to README * Fix uppercase * Address review comments --------- Co-authored-by: jonschz --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c246e850..6d62e581 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This is a functionally complete decompilation of LEGO Island (Version 1.1, English). It aims to be as accurate as possible, matching the recompiled instructions to the original machine code as much as possible. The goal is to provide a workable codebase that can be modified, improved, and ported to other platforms later on. +> **Note:** This repository is for decompilation only and its code is true to the original release. It will not compile for targets other than 32-bit Windows. For a modern adaptation of the LEGO Island codebase with native compatibility for all major platforms and the Web, see [isle-portable](https://github.com/isledecomp/isle-portable) instead. + ## Status From 1701117e6fc085daf74f5b85d46beed9cab27532 Mon Sep 17 00:00:00 2001 From: MS Date: Mon, 23 Jun 2025 10:24:13 -0400 Subject: [PATCH 10/16] Improve `MeshBuilderImpl::CreateMesh` (#1584) * CreateMesh * Effective match for Clone() --- LEGO1/tgl/d3drm/impl.h | 3 ++ LEGO1/tgl/d3drm/meshbuilder.cpp | 82 +++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index 25a3a8a1..0d9851fa 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -866,4 +866,7 @@ inline D3DRMMATERIALMODE Translate(MaterialMode mode) // GLOBAL: LEGO1 0x100dd1e0 // IID_IDirect3DRMMeshBuilder +// GLOBAL: LEGO1 0x100dd1f0 +// IID_IDirect3DRMMesh + #endif diff --git a/LEGO1/tgl/d3drm/meshbuilder.cpp b/LEGO1/tgl/d3drm/meshbuilder.cpp index 3cabb29a..1f9da01a 100644 --- a/LEGO1/tgl/d3drm/meshbuilder.cpp +++ b/LEGO1/tgl/d3drm/meshbuilder.cpp @@ -15,6 +15,7 @@ void* MeshBuilderImpl::ImplementationDataPtr() } // FUNCTION: LEGO1 0x100a3840 +// FUNCTION: BETA10 0x1016ca40 Mesh* MeshBuilderImpl::CreateMesh( unsigned long faceCount, unsigned long vertexCount, @@ -26,6 +27,8 @@ Mesh* MeshBuilderImpl::CreateMesh( ShadingModel shadingModel ) { + assert(m_data); + MeshImpl* pMeshImpl = new MeshImpl; if (CreateMeshImpl( pMeshImpl, @@ -45,63 +48,67 @@ Mesh* MeshBuilderImpl::CreateMesh( return pMeshImpl; } +// FUNCTION: BETA10 0x1016fef0 inline Result CreateMesh( IDirect3DRMMesh* pD3DRM, - unsigned long faceCount, - unsigned long vertexCount, - float (*pPositions)[3], - float (*pNormals)[3], - float (*pTextureCoordinates)[2], - unsigned long (*pFaceIndices)[3], - unsigned long (*pTextureIndices)[3], + unsigned long p_numFaces, + unsigned long p_numVertices, + float(*p_positions), + float(*p_normals), + float(*p_textureCoordinates), + unsigned long (*p_faceIndices)[3], + unsigned long (*p_textureIndices)[3], ShadingModel shadingModel, MeshImpl::MeshDataType& rpMesh ) { - unsigned long* faceIndices = (unsigned long*) pFaceIndices; + unsigned short* faceIndices = (unsigned short*) p_faceIndices; D3DRMGROUPINDEX groupIndex = 0; - int count = faceCount * 3; - int index = 0; + int faceCount = p_numFaces * 3; + int count = 0; - unsigned int* fData = new unsigned int[count]; + unsigned int* fData = new unsigned int[faceCount]; - D3DRMVERTEX* vertices = new D3DRMVERTEX[vertexCount]; - memset(vertices, 0, sizeof(*vertices) * vertexCount); + D3DRMVERTEX* vertices = new D3DRMVERTEX[p_numVertices]; + memset(vertices, 0, sizeof(*vertices) * p_numVertices); rpMesh = new MeshImpl::MeshData; rpMesh->groupMesh = pD3DRM; - for (int i = 0; i < count; i++) { - if ((*((unsigned short*) &faceIndices[i] + 1) >> 0x0f) & 0x01) { - unsigned long j = *(unsigned short*) &faceIndices[i]; - vertices[index].position.x = pPositions[j][0]; - vertices[index].position.y = pPositions[j][1]; - vertices[index].position.z = pPositions[j][2]; - j = *((unsigned short*) &faceIndices[i] + 1) & MAXSHORT; - vertices[index].normal.x = pNormals[j][0]; - vertices[index].normal.y = pNormals[j][1]; - vertices[index].normal.z = pNormals[j][2]; + for (int i = 0; i < faceCount; i++) { + if (((faceIndices[2 * i + 1]) >> 0x0f) & 0x01) { + unsigned long j = 3 * faceIndices[2 * i]; + vertices[count].position.x = p_positions[j]; + vertices[count].position.y = p_positions[j + 1]; + vertices[count].position.z = p_positions[j + 2]; - if (pTextureIndices != NULL && pTextureCoordinates != NULL) { - j = ((unsigned long*) pTextureIndices)[i]; - vertices[index].tu = pTextureCoordinates[j][0]; - vertices[index].tv = pTextureCoordinates[j][1]; + int k = 3 * (faceIndices[2 * i + 1] & MAXSHORT); + vertices[count].normal.x = p_normals[k]; + vertices[count].normal.y = p_normals[k + 1]; + vertices[count].normal.z = p_normals[k + 2]; + + if (p_textureIndices != NULL && p_textureCoordinates != NULL) { + int kk = 2 * ((unsigned long*) p_textureIndices)[i]; + vertices[count].tu = p_textureCoordinates[kk]; + vertices[count].tv = p_textureCoordinates[kk + 1]; } - fData[i] = index; - index++; + fData[i] = count; + count++; } else { - fData[i] = *(unsigned short*) &faceIndices[i]; + fData[i] = faceIndices[2 * i]; } } + assert(count == (int) p_numVertices); + Result result; - result = ResultVal(pD3DRM->AddGroup(vertexCount, faceCount, 3, fData, &groupIndex)); + result = ResultVal(pD3DRM->AddGroup(p_numVertices, p_numFaces, 3, fData, &groupIndex)); if (Succeeded(result)) { rpMesh->groupIndex = groupIndex; - result = ResultVal(pD3DRM->SetVertices(groupIndex, 0, vertexCount, vertices)); + result = ResultVal(pD3DRM->SetVertices(groupIndex, 0, p_numVertices, vertices)); } if (!Succeeded(result)) { @@ -112,6 +119,7 @@ inline Result CreateMesh( } else { result = MeshSetTextureMappingMode(rpMesh, PerspectiveCorrect); + assert(Succeeded(result)); } if (fData != NULL) { @@ -125,6 +133,7 @@ inline Result CreateMesh( return result; } +// FUNCTION: BETA10 0x1016fe40 inline Result MeshBuilderImpl::CreateMeshImpl( MeshImpl* pMeshImpl, unsigned long faceCount, @@ -137,13 +146,16 @@ inline Result MeshBuilderImpl::CreateMeshImpl( ShadingModel shadingModel ) { + assert(m_data); + assert(!pMeshImpl->ImplementationData()); + return ::CreateMesh( m_data, faceCount, vertexCount, - pPositions, - pNormals, - pTextureCoordinates, + reinterpret_cast(pPositions), + reinterpret_cast(pNormals), + reinterpret_cast(pTextureCoordinates), pFaceIndices, pTextureIndices, shadingModel, From edae5f58ec40a387139dc3dbf9c4dcf1ab6327e9 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:58:16 +0200 Subject: [PATCH 11/16] Remove getters/setters that (likely) don't exist (#1583) Co-authored-by: jonschz --- LEGO1/lego/legoomni/include/legogamestate.h | 9 --------- LEGO1/lego/legoomni/src/common/legogamestate.cpp | 1 + LEGO1/lego/legoomni/src/worlds/act3.cpp | 6 +++--- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 12 ++++++------ LEGO1/lego/legoomni/src/worlds/isle.cpp | 2 +- LEGO1/lego/legoomni/src/worlds/legoact2.cpp | 6 +++--- 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index b81696fd..e5dd9a26 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -223,14 +223,8 @@ class LegoGameState { Act GetCurrentAct() { return m_currentAct; } Act GetLoadedAct() { return m_loadedAct; } - Area GetPreviousArea() { return m_previousArea; } - Area GetUnknown0x42c() { return m_unk0x42c; } - void SetDirty(MxBool p_isDirty) { m_isDirty = p_isDirty; } - void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; } void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; } - Username* GetPlayersIndex(MxS32 p_index) { return &m_players[p_index]; } - MxS16 GetPlayerCount() { return m_playerCount; } LegoBackgroundColor* GetBackgroundColor() { return m_backgroundColor; } void SetCurrentAct(Act p_currentAct); @@ -254,14 +248,11 @@ class LegoGameState { LegoBackgroundColor* m_tempBackgroundColor; // 0x1c LegoFullScreenMovie* m_fullScreenMovie; // 0x20 - // TODO: Most likely getters/setters are not used according to BETA for the following members: - public: MxS16 m_currentPlayerId; // 0x24 MxS16 m_playerCount; // 0x26 Username m_players[9]; // 0x28 History m_history; // 0xa6 - undefined2 m_unk0x41a; // 0x41a JukeboxScript::Script m_jukeboxMusic; // 0x41c MxBool m_isDirty; // 0x420 Area m_currentArea; // 0x424 diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 0a2c452a..1e53cb4f 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -1629,6 +1629,7 @@ void LegoGameState::SerializeScoreHistory(MxS16 p_flags) } // FUNCTION: LEGO1 0x1003cea0 +// FUNCTION: BETA10 0x10017840 void LegoGameState::SetCurrentAct(Act p_currentAct) { m_currentAct = p_currentAct; diff --git a/LEGO1/lego/legoomni/src/worlds/act3.cpp b/LEGO1/lego/legoomni/src/worlds/act3.cpp index 48aacd92..64ed8d6c 100644 --- a/LEGO1/lego/legoomni/src/worlds/act3.cpp +++ b/LEGO1/lego/legoomni/src/worlds/act3.cpp @@ -488,7 +488,7 @@ MxResult Act3::Create(MxDSAction& p_dsAction) case LegoGameState::e_act1: case LegoGameState::e_actNotFound: GameState()->StopArea(LegoGameState::e_undefined); - if (GameState()->GetPreviousArea() == LegoGameState::e_infomain) { + if (GameState()->m_previousArea == LegoGameState::e_infomain) { GameState()->StopArea(LegoGameState::e_isle); } } @@ -505,7 +505,7 @@ MxResult Act3::Create(MxDSAction& p_dsAction) GameState()->m_currentArea = LegoGameState::e_act3script; GameState()->SetCurrentAct(LegoGameState::e_act3); - GameState()->SetDirty(TRUE); + GameState()->m_isDirty = TRUE; } return result; @@ -883,7 +883,7 @@ void Act3::Enable(MxBool p_enable) FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); PlayMusic(JukeboxScript::c_Act3Music); - GameState()->SetDirty(TRUE); + GameState()->m_isDirty = TRUE; if (m_time > 0) { MxFloat delta = Timer()->GetTime() - m_time - 100.0f; diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 8a41663e..90078e6d 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -219,7 +219,7 @@ MxResult Infocenter::Create(MxDSAction& p_dsAction) if (m_infocenterState->m_unk0x74 == 4) { LegoGameState* state = GameState(); - state->SetPreviousArea(GameState()->GetUnknown0x42c()); + state->m_previousArea = GameState()->m_unk0x42c; } InputManager()->Register(this); @@ -1020,13 +1020,13 @@ MxU8 Infocenter::HandleControl(LegoControlManagerNotificationParam& p_param) case InfomainScript::c_BigInfo_Ctl: switch (state->GetCurrentAct()) { case LegoGameState::e_act1: - if (state->GetPreviousArea()) { - switch (state->GetPreviousArea()) { + if (state->m_previousArea) { + switch (state->m_previousArea) { case LegoGameState::e_infodoor: case LegoGameState::e_regbook: case LegoGameState::e_infoscor: m_infocenterState->m_unk0x74 = 5; - m_destLocation = state->GetPreviousArea(); + m_destLocation = state->m_previousArea; actionToPlay = (InfomainScript::Script) m_infocenterState->GetNextLeaveDialogue(); m_radio.Stop(); InputManager()->DisableInputProcessing(); @@ -1081,7 +1081,7 @@ MxU8 Infocenter::HandleControl(LegoControlManagerNotificationParam& p_param) actionToPlay = GameState()->GetCurrentAct() != LegoGameState::e_act1 ? InfomainScript::c_GoTo_RegBook_Red : InfomainScript::c_GoTo_RegBook; m_radio.Stop(); - GameState()->m_unk0x42c = GameState()->GetPreviousArea(); + GameState()->m_unk0x42c = GameState()->m_previousArea; InputManager()->DisableInputProcessing(); break; case InfomainScript::c_Mama_Ctl: @@ -1390,7 +1390,7 @@ void Infocenter::Reset() AnimationManager()->Reset(FALSE); CharacterManager()->ReleaseAllActors(); GameState()->SetCurrentAct(LegoGameState::e_act1); - GameState()->SetPreviousArea(LegoGameState::e_undefined); + GameState()->m_previousArea = LegoGameState::e_undefined; GameState()->m_unk0x42c = LegoGameState::e_undefined; InitializeBitmaps(); diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index 1aa352fe..050aae97 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -121,7 +121,7 @@ MxResult Isle::Create(MxDSAction& p_dsAction) m_act1state = act1state; EnableAnimations(TRUE); - GameState()->SetDirty(TRUE); + GameState()->m_isDirty = TRUE; } return result; diff --git a/LEGO1/lego/legoomni/src/worlds/legoact2.cpp b/LEGO1/lego/legoomni/src/worlds/legoact2.cpp index 2b9dd80b..ddc97f1c 100644 --- a/LEGO1/lego/legoomni/src/worlds/legoact2.cpp +++ b/LEGO1/lego/legoomni/src/worlds/legoact2.cpp @@ -141,7 +141,7 @@ MxResult LegoAct2::Create(MxDSAction& p_dsAction) case LegoGameState::e_act1: case LegoGameState::e_actNotFound: GameState()->StopArea(LegoGameState::e_undefined); - if (GameState()->GetPreviousArea() == LegoGameState::e_infomain) { + if (GameState()->m_previousArea == LegoGameState::e_infomain) { GameState()->StopArea(LegoGameState::e_isle); } } @@ -149,7 +149,7 @@ MxResult LegoAct2::Create(MxDSAction& p_dsAction) GameState()->m_currentArea = LegoGameState::e_act2main; GameState()->SetCurrentAct(LegoGameState::e_act2); InputManager()->Register(this); - GameState()->SetDirty(TRUE); + GameState()->m_isDirty = TRUE; } return result; @@ -536,7 +536,7 @@ void LegoAct2::Enable(MxBool p_enable) ((IslePathActor*) m_pepper->GetEntity())->VTable0xec(m_unk0x10dc, m_unk0x1124, TRUE); - if (GameState()->GetPreviousArea() == LegoGameState::e_infomain) { + if (GameState()->m_previousArea == LegoGameState::e_infomain) { GameState()->StopArea(LegoGameState::e_infomain); } From 7f10f7ae147d874bd0332129362b4bd5040e8516 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Mon, 23 Jun 2025 23:34:02 +0200 Subject: [PATCH 12/16] Clear unknown in `ModelDbModel` (#1586) --- LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp | 2 +- LEGO1/modeldb/modeldb.cpp | 2 +- LEGO1/modeldb/modeldb.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 7aa4220e..91c413e1 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -393,7 +393,7 @@ MxResult LegoWorldPresenter::LoadWorldModel(ModelDbModel& p_model, FILE* p_wdbFi } modelPresenter.SetAction(&action); - modelPresenter.FUN_1007ff70(chunk, createdEntity, p_model.m_unk0x34, p_world); + modelPresenter.FUN_1007ff70(chunk, createdEntity, p_model.m_visible, p_world); delete[] buff; return SUCCESS; diff --git a/LEGO1/modeldb/modeldb.cpp b/LEGO1/modeldb/modeldb.cpp index c59e5c8e..82e673ec 100644 --- a/LEGO1/modeldb/modeldb.cpp +++ b/LEGO1/modeldb/modeldb.cpp @@ -52,7 +52,7 @@ MxResult ModelDbModel::Read(FILE* p_file) if (fread(&m_up, sizeof(float), 3, p_file) != 3) { return FAILURE; } - if (fread(&m_unk0x34, sizeof(undefined), 1, p_file) != 1) { + if (fread(&m_visible, sizeof(MxU8), 1, p_file) != 1) { return FAILURE; } diff --git a/LEGO1/modeldb/modeldb.h b/LEGO1/modeldb/modeldb.h index 02642926..b9091e1f 100644 --- a/LEGO1/modeldb/modeldb.h +++ b/LEGO1/modeldb/modeldb.h @@ -101,7 +101,7 @@ struct ModelDbModel { float m_location[3]; // 0x10 float m_direction[3]; // 0x1c float m_up[3]; // 0x28 - undefined m_unk0x34; // 0x34 + MxU8 m_visible; // 0x34 }; // SIZE 0x18 From ce85377f18a574998320845ce30af1c37b5f4efe Mon Sep 17 00:00:00 2001 From: MattKC <34096995+itsmattkc@users.noreply.github.com> Date: Tue, 24 Jun 2025 09:00:23 -0700 Subject: [PATCH 13/16] Create LICENSE (#1497) --- LICENSE | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..0a041280 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. From 8498c69af1b7428828ef5a03f120df851f87dde3 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Tue, 24 Jun 2025 22:38:08 +0200 Subject: [PATCH 14/16] Clear unknowns in `LegoPlantManager` (#1587) --- LEGO1/lego/legoomni/include/legoplantmanager.h | 12 ++++++------ .../lego/legoomni/src/common/legoplantmanager.cpp | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoplantmanager.h b/LEGO1/lego/legoomni/include/legoplantmanager.h index 8a8c7902..91fe49c8 100644 --- a/LEGO1/lego/legoomni/include/legoplantmanager.h +++ b/LEGO1/lego/legoomni/include/legoplantmanager.h @@ -54,7 +54,7 @@ class LegoPlantManager : public MxCore { LegoEntity* CreatePlant(MxS32 p_index, LegoWorld* p_world, LegoOmni::World p_worldId); MxBool DecrementCounter(LegoEntity* p_entity); void ScheduleAnimation(LegoEntity* p_entity, MxLong p_length); - MxResult FUN_10026410(); + MxResult DetermineBoundaries(); void ClearCounters(); void SetInitialCounters(); @@ -77,11 +77,11 @@ class LegoPlantManager : public MxCore { static MxS32 g_maxMove[4]; static MxU32 g_maxSound; - LegoOmni::World m_worldId; // 0x08 - undefined m_unk0x0c; // 0x0c - AnimEntry* m_entries[5]; // 0x10 - MxS8 m_numEntries; // 0x24 - LegoWorld* m_world; // 0x28 + LegoOmni::World m_worldId; // 0x08 + MxBool m_boundariesDetermined; // 0x0c + AnimEntry* m_entries[5]; // 0x10 + MxS8 m_numEntries; // 0x24 + LegoWorld* m_world; // 0x28 }; #endif // LEGOPLANTMANAGER_H diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index 734806fc..766edf79 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -83,7 +83,7 @@ void LegoPlantManager::Init() } m_worldId = LegoOmni::e_undefined; - m_unk0x0c = 0; + m_boundariesDetermined = FALSE; m_numEntries = 0; } @@ -98,7 +98,7 @@ void LegoPlantManager::LoadWorldInfo(LegoOmni::World p_worldId) CreatePlant(i, world, p_worldId); } - m_unk0x0c = 0; + m_boundariesDetermined = FALSE; } // FUNCTION: LEGO1 0x100263a0 @@ -119,12 +119,12 @@ void LegoPlantManager::Reset(LegoOmni::World p_worldId) } m_worldId = LegoOmni::e_undefined; - m_unk0x0c = 0; + m_boundariesDetermined = FALSE; } // FUNCTION: LEGO1 0x10026410 // FUNCTION: BETA10 0x100c50e9 -MxResult LegoPlantManager::FUN_10026410() +MxResult LegoPlantManager::DetermineBoundaries() { // similar to LegoBuildingManager::FUN_10030630() @@ -192,7 +192,7 @@ MxResult LegoPlantManager::FUN_10026410() } } - m_unk0x0c = TRUE; + m_boundariesDetermined = TRUE; return SUCCESS; } @@ -200,8 +200,8 @@ MxResult LegoPlantManager::FUN_10026410() // FUNCTION: BETA10 0x100c55e0 LegoPlantInfo* LegoPlantManager::GetInfoArray(MxS32& p_length) { - if (!m_unk0x0c) { - FUN_10026410(); + if (!m_boundariesDetermined) { + DetermineBoundaries(); } p_length = sizeOfArray(g_plantInfo); From b66d1e2f64547d29854f36275ffa9a0fb584f23d Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Thu, 26 Jun 2025 20:31:30 +0200 Subject: [PATCH 15/16] Clear unknowns in `Ambulance` and `AmbulanceMissionState` (#1588) --- LEGO1/lego/legoomni/include/ambulance.h | 46 +++++++---- LEGO1/lego/legoomni/src/actors/ambulance.cpp | 84 ++++++++++---------- LEGO1/lego/legoomni/src/worlds/isle.cpp | 6 +- 3 files changed, 74 insertions(+), 62 deletions(-) diff --git a/LEGO1/lego/legoomni/include/ambulance.h b/LEGO1/lego/legoomni/include/ambulance.h index 97e6ba38..cb6a396a 100644 --- a/LEGO1/lego/legoomni/include/ambulance.h +++ b/LEGO1/lego/legoomni/include/ambulance.h @@ -11,6 +11,12 @@ class MxEndActionNotificationParam; // SIZE 0x24 class AmbulanceMissionState : public LegoState { public: + enum { + e_ready = 0, + e_enteredAmbulance = 1, + e_prepareAmbulance = 2, + }; + AmbulanceMissionState(); // FUNCTION: LEGO1 0x10037440 @@ -125,18 +131,18 @@ class AmbulanceMissionState : public LegoState { // SYNTHETIC: LEGO1 0x100376c0 // AmbulanceMissionState::`scalar deleting destructor' - undefined4 m_unk0x08; // 0x08 - MxLong m_startTime; // 0x0c - MxS16 m_peScore; // 0x10 - MxS16 m_maScore; // 0x12 - MxS16 m_paScore; // 0x14 - MxS16 m_niScore; // 0x16 - MxS16 m_laScore; // 0x18 - MxS16 m_peHighScore; // 0x1a - MxS16 m_maHighScore; // 0x1c - MxS16 m_paHighScore; // 0x1e - MxS16 m_niHighScore; // 0x20 - MxS16 m_laHighScore; // 0x22 + MxU32 m_state; // 0x08 + MxLong m_startTime; // 0x0c + MxS16 m_peScore; // 0x10 + MxS16 m_maScore; // 0x12 + MxS16 m_paScore; // 0x14 + MxS16 m_niScore; // 0x16 + MxS16 m_laScore; // 0x18 + MxS16 m_peHighScore; // 0x1a + MxS16 m_maHighScore; // 0x1c + MxS16 m_paHighScore; // 0x1e + MxS16 m_niHighScore; // 0x20 + MxS16 m_laHighScore; // 0x22 }; // VTABLE: LEGO1 0x100d71a8 @@ -177,15 +183,21 @@ class Ambulance : public IslePathActor { virtual MxLong HandleEndAction(MxEndActionNotificationParam& p_param); // vtable+0xf4 void CreateState(); - void FUN_10036e60(); + void Init(); void ActivateSceneActions(); void StopActions(); - void FUN_10037250(); + void Reset(); // SYNTHETIC: LEGO1 0x10036130 // Ambulance::`scalar deleting destructor' private: + enum { + e_none = 0, + e_waiting = 1, + e_finished = 3, + }; + void PlayAnimation(IsleScript::Script p_objectId); void PlayFinalAnimation(IsleScript::Script p_objectId); void StopAction(IsleScript::Script p_objectId); @@ -196,9 +208,9 @@ class Ambulance : public IslePathActor { AmbulanceMissionState* m_state; // 0x164 MxS16 m_unk0x168; // 0x168 MxS16 m_actorId; // 0x16a - MxS16 m_unk0x16c; // 0x16c - MxS16 m_unk0x16e; // 0x16e - MxS16 m_unk0x170; // 0x170 + MxS16 m_atPoliceTask; // 0x16c + MxS16 m_atBeachTask; // 0x16e + MxS16 m_taskState; // 0x170 MxS16 m_unk0x172; // 0x172 IsleScript::Script m_lastAction; // 0x174 IsleScript::Script m_lastAnimation; // 0x178 diff --git a/LEGO1/lego/legoomni/src/actors/ambulance.cpp b/LEGO1/lego/legoomni/src/actors/ambulance.cpp index 22c1e701..95ca6975 100644 --- a/LEGO1/lego/legoomni/src/actors/ambulance.cpp +++ b/LEGO1/lego/legoomni/src/actors/ambulance.cpp @@ -37,9 +37,9 @@ Ambulance::Ambulance() m_state = NULL; m_unk0x168 = 0; m_actorId = -1; - m_unk0x16c = 0; - m_unk0x16e = 0; - m_unk0x170 = 0; + m_atPoliceTask = 0; + m_atBeachTask = 0; + m_taskState = Ambulance::e_none; m_lastAction = IsleScript::c_noneIsle; m_unk0x172 = 0; m_lastAnimation = IsleScript::c_noneIsle; @@ -70,7 +70,7 @@ MxResult Ambulance::Create(MxDSAction& p_dsAction) m_state = (AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState"); if (!m_state) { m_state = new AmbulanceMissionState(); - m_state->m_unk0x08 = 0; + m_state->m_state = AmbulanceMissionState::e_ready; GameState()->RegisterState(m_state); } } @@ -170,25 +170,25 @@ MxLong Ambulance::HandleEndAction(MxEndActionNotificationParam& p_param) m_lastAction = IsleScript::c_noneIsle; } else if (objectId == IsleScript::c_hho027en_RunAnim) { - m_state->m_unk0x08 = 1; + m_state->m_state = AmbulanceMissionState::e_enteredAmbulance; CurrentWorld()->PlaceActor(UserActor()); HandleClick(); m_unk0x172 = 0; TickleManager()->RegisterClient(this, 40000); } else if (objectId == IsleScript::c_hpz047pe_RunAnim || objectId == IsleScript::c_hpz048pe_RunAnim || objectId == IsleScript::c_hpz049bd_RunAnim || objectId == IsleScript::c_hpz053pa_RunAnim) { - if (m_unk0x170 == 3) { + if (m_taskState == Ambulance::e_finished) { PlayAnimation(IsleScript::c_hpz055pa_RunAnim); - m_unk0x170 = 0; + m_taskState = Ambulance::e_none; } else { PlayAnimation(IsleScript::c_hpz053pa_RunAnim); } } else if (objectId == IsleScript::c_hpz050bd_RunAnim || objectId == IsleScript::c_hpz052ma_RunAnim) { - if (m_unk0x170 == 3) { + if (m_taskState == Ambulance::e_finished) { PlayAnimation(IsleScript::c_hpz057ma_RunAnim); - m_unk0x170 = 0; + m_taskState = Ambulance::e_none; } else { PlayAnimation(IsleScript::c_hpz052ma_RunAnim); @@ -201,18 +201,18 @@ MxLong Ambulance::HandleEndAction(MxEndActionNotificationParam& p_param) m_unk0x172 = 0; TickleManager()->RegisterClient(this, 40000); - if (m_unk0x16c != 0) { + if (m_atPoliceTask != 0) { StopActions(); } } else if (objectId == IsleScript::c_hps116bd_RunAnim || objectId == IsleScript::c_hps118re_RunAnim) { - if (objectId == IsleScript::c_hps116bd_RunAnim && m_unk0x170 != 3) { + if (objectId == IsleScript::c_hps116bd_RunAnim && m_taskState != Ambulance::e_finished) { PlayAction(IsleScript::c_Avo923In_PlayWav); } - if (m_unk0x170 == 3) { + if (m_taskState == Ambulance::e_finished) { PlayAnimation(IsleScript::c_hps117bd_RunAnim); - m_unk0x170 = 0; + m_taskState = Ambulance::e_none; } else { PlayAnimation(IsleScript::c_hps118re_RunAnim); @@ -225,12 +225,12 @@ MxLong Ambulance::HandleEndAction(MxEndActionNotificationParam& p_param) m_unk0x172 = 0; TickleManager()->RegisterClient(this, 40000); - if (m_unk0x16e != 0) { + if (m_atBeachTask != 0) { StopActions(); } } else if (objectId == IsleScript::c_hho142cl_RunAnim || objectId == IsleScript::c_hho143cl_RunAnim || objectId == IsleScript::c_hho144cl_RunAnim) { - FUN_10037250(); + Reset(); } } @@ -241,18 +241,18 @@ MxLong Ambulance::HandleEndAction(MxEndActionNotificationParam& p_param) // FUNCTION: BETA10 0x100230bf MxLong Ambulance::HandleButtonDown(LegoControlManagerNotificationParam& p_param) { - if (m_unk0x170 == 1) { + if (m_taskState == Ambulance::e_waiting) { LegoROI* roi = PickROI(p_param.GetX(), p_param.GetY()); if (roi != NULL && !strcmpi(roi->GetName(), "ps-gate")) { - m_unk0x170 = 3; + m_taskState = Ambulance::e_finished; return 1; } roi = PickRootROI(p_param.GetX(), p_param.GetY()); if (roi != NULL && !strcmpi(roi->GetName(), "gd")) { - m_unk0x170 = 3; + m_taskState = Ambulance::e_finished; return 1; } } @@ -270,9 +270,9 @@ MxLong Ambulance::HandlePathStruct(LegoPathStructNotificationParam& p_param) } if (p_param.GetTrigger() == LegoPathStruct::c_camAnim && p_param.GetData() == 0x0b) { - if (m_unk0x16e != 0) { - if (m_unk0x16c != 0) { - m_state->m_unk0x08 = 2; + if (m_atBeachTask != 0) { + if (m_atPoliceTask != 0) { + m_state->m_state = AmbulanceMissionState::e_prepareAmbulance; if (m_lastAction != IsleScript::c_noneIsle) { InvokeAction(Extra::e_stop, *g_isleScript, m_lastAction, NULL); @@ -297,7 +297,7 @@ MxLong Ambulance::HandlePathStruct(LegoPathStructNotificationParam& p_param) return 0; } - if (m_unk0x16e != 0) { + if (m_atBeachTask != 0) { if (m_lastAction != IsleScript::c_noneIsle) { InvokeAction(Extra::e_stop, *g_isleScript, m_lastAction, NULL); } @@ -307,7 +307,7 @@ MxLong Ambulance::HandlePathStruct(LegoPathStructNotificationParam& p_param) } } - if (m_unk0x16c != 0) { + if (m_atPoliceTask != 0) { if (m_lastAction != IsleScript::c_noneIsle) { InvokeAction(Extra::e_stop, *g_isleScript, m_lastAction, NULL); } @@ -315,9 +315,9 @@ MxLong Ambulance::HandlePathStruct(LegoPathStructNotificationParam& p_param) PlayAction(IsleScript::c_Avo915In_PlayWav); } } - else if (p_param.GetTrigger() == LegoPathStruct::c_s && p_param.GetData() == 0x131 && m_unk0x16e == 0) { - m_unk0x16e = 1; - m_unk0x170 = 1; + else if (p_param.GetTrigger() == LegoPathStruct::c_s && p_param.GetData() == 0x131 && m_atBeachTask == 0) { + m_atBeachTask = 1; + m_taskState = Ambulance::e_waiting; if (m_lastAction != IsleScript::c_noneIsle) { InvokeAction(Extra::e_stop, *g_isleScript, m_lastAction, NULL); @@ -345,9 +345,9 @@ MxLong Ambulance::HandlePathStruct(LegoPathStructNotificationParam& p_param) break; } } - else if (p_param.GetTrigger() == LegoPathStruct::c_camAnim && (p_param.GetData() == 0x22 || p_param.GetData() == 0x23 || p_param.GetData() == 0x24) && m_unk0x16c == 0) { - m_unk0x16c = 1; - m_unk0x170 = 1; + else if (p_param.GetTrigger() == LegoPathStruct::c_camAnim && (p_param.GetData() == 0x22 || p_param.GetData() == 0x23 || p_param.GetData() == 0x24) && m_atPoliceTask == 0) { + m_atPoliceTask = 1; + m_taskState = Ambulance::e_waiting; if (m_lastAction != IsleScript::c_noneIsle) { InvokeAction(Extra::e_stop, *g_isleScript, m_lastAction, NULL); @@ -368,7 +368,7 @@ MxLong Ambulance::HandleClick() return 1; } - if (m_state->m_unk0x08 == 2) { + if (m_state->m_state == AmbulanceMissionState::e_prepareAmbulance) { return 1; } @@ -387,7 +387,7 @@ MxLong Ambulance::HandleClick() InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_AmbulanceDashboard, NULL); ControlManager()->Register(this); - if (m_state->m_unk0x08 == 1) { + if (m_state->m_state == AmbulanceMissionState::e_enteredAmbulance) { SpawnPlayer(LegoGameState::e_hospitalExited, TRUE, 0); m_state->m_startTime = Timer()->GetTime(); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_pns018rd_RunAnim, NULL); @@ -398,9 +398,9 @@ MxLong Ambulance::HandleClick() // FUNCTION: LEGO1 0x10036e60 // FUNCTION: BETA10 0x100236bb -void Ambulance::FUN_10036e60() +void Ambulance::Init() { - m_state->m_unk0x08 = 2; + m_state->m_state = AmbulanceMissionState::e_prepareAmbulance; PlayAnimation(IsleScript::c_hho027en_RunAnim); m_lastAction = IsleScript::c_noneIsle; m_lastAnimation = IsleScript::c_noneIsle; @@ -411,7 +411,7 @@ void Ambulance::Exit() { GameState()->m_currentArea = LegoGameState::e_hospitalExterior; StopActions(); - FUN_10037250(); + Reset(); Leave(); } @@ -467,11 +467,11 @@ void Ambulance::ActivateSceneActions() { PlayMusic(JukeboxScript::c_Hospital_Music); - if (m_state->m_unk0x08 == 1) { - m_state->m_unk0x08 = 0; + if (m_state->m_state == AmbulanceMissionState::e_enteredAmbulance) { + m_state->m_state = AmbulanceMissionState::e_ready; PlayAction(IsleScript::c_ham033cl_PlayWav); } - else if (m_unk0x16c != 0 && m_unk0x16e != 0) { + else if (m_atPoliceTask != 0 && m_atBeachTask != 0) { IsleScript::Script objectId; switch (rand() % 2) { @@ -571,14 +571,14 @@ void Ambulance::StopActions() } // FUNCTION: LEGO1 0x10037250 -void Ambulance::FUN_10037250() +void Ambulance::Reset() { StopAction(m_lastAction); BackgroundAudioManager()->RaiseVolume(); ((Act1State*) GameState()->GetState("Act1State"))->m_unk0x018 = 0; - m_state->m_unk0x08 = 0; - m_unk0x16e = 0; - m_unk0x16c = 0; + m_state->m_state = AmbulanceMissionState::e_ready; + m_atBeachTask = 0; + m_atPoliceTask = 0; g_isleFlags |= Isle::c_playMusic; AnimationManager()->EnableCamAnims(TRUE); AnimationManager()->FUN_1005f6d0(TRUE); @@ -626,7 +626,7 @@ void Ambulance::PlayAction(IsleScript::Script p_objectId) // FUNCTION: LEGO1 0x100373a0 AmbulanceMissionState::AmbulanceMissionState() { - m_unk0x08 = 0; + m_state = AmbulanceMissionState::e_ready; m_startTime = 0; m_peScore = 0; m_maScore = 0; diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index 050aae97..2eb47874 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -810,7 +810,7 @@ void Isle::Enable(MxBool p_enable) AnimationManager()->EnableCamAnims(FALSE); g_isleFlags &= ~c_playMusic; - m_ambulance->FUN_10036e60(); + m_ambulance->Init(); break; case 11: m_act1state->m_unk0x018 = 0; @@ -1209,7 +1209,7 @@ MxBool Isle::Escape() case 10: if (UserActor() != NULL && !UserActor()->IsA("Ambulance")) { m_ambulance->StopActions(); - m_ambulance->FUN_10037250(); + m_ambulance->Reset(); } break; } @@ -1250,7 +1250,7 @@ void Isle::FUN_10033350() if (m_act1state->m_unk0x018 == 10) { if (UserActor() != NULL && !UserActor()->IsA("Ambulance")) { m_ambulance->StopActions(); - m_ambulance->FUN_10037250(); + m_ambulance->Reset(); } } From 056064f9d4f4d9c69faae65012ff6de0c22f56e7 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Thu, 26 Jun 2025 22:35:04 +0200 Subject: [PATCH 16/16] Clear unknown in `LegoLOD` (#1590) The function does mostly the same as `SetTextureInfo` but does not explicitly set the color as well. --- LEGO1/lego/legoomni/src/common/legocharactermanager.cpp | 2 +- LEGO1/lego/sources/roi/legolod.cpp | 2 +- LEGO1/lego/sources/roi/legolod.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 485d3511..80b69efc 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -634,7 +634,7 @@ MxBool LegoCharacterManager::SetHeadTexture(LegoROI* p_roi, LegoTextureInfo* p_t LegoLOD* clone = lod->Clone(renderer); if (p_texture != NULL) { - clone->FUN_100aad70(p_texture); + clone->UpdateTextureInfo(p_texture); } dupLodList->PushBack(clone); diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index 2291a3e7..bf157b56 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -351,7 +351,7 @@ LegoResult LegoLOD::SetTextureInfo(LegoTextureInfo* p_textureInfo) } // FUNCTION: LEGO1 0x100aad70 -LegoResult LegoLOD::FUN_100aad70(LegoTextureInfo* p_textureInfo) +LegoResult LegoLOD::UpdateTextureInfo(LegoTextureInfo* p_textureInfo) { for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) { if (m_melems[i].m_textured) { diff --git a/LEGO1/lego/sources/roi/legolod.h b/LEGO1/lego/sources/roi/legolod.h index 114e377b..e787d377 100644 --- a/LEGO1/lego/sources/roi/legolod.h +++ b/LEGO1/lego/sources/roi/legolod.h @@ -31,7 +31,7 @@ class LegoLOD : public ViewLOD { LegoLOD* Clone(Tgl::Renderer* p_renderer); LegoResult SetColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); LegoResult SetTextureInfo(LegoTextureInfo* p_textureInfo); - LegoResult FUN_100aad70(LegoTextureInfo* p_textureInfo); + LegoResult UpdateTextureInfo(LegoTextureInfo* p_textureInfo); void ClearMeshOffset(); LegoResult GetTextureInfo(LegoTextureInfo*& p_textureInfo);