From 56827fb2c485a39ce13e3ac61bc976adb93fe67b Mon Sep 17 00:00:00 2001 From: MS Date: Tue, 2 Apr 2024 18:45:57 -0400 Subject: [PATCH 1/6] Use colorama.just_fix_windows_console (#766) --- tools/datacmp.py | 2 +- tools/decomplint/decomplint.py | 2 +- tools/reccmp/reccmp.py | 2 +- tools/requirements.txt | 2 +- tools/vtable/vtable.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/datacmp.py b/tools/datacmp.py index 28895876..7073fc09 100644 --- a/tools/datacmp.py +++ b/tools/datacmp.py @@ -16,7 +16,7 @@ from isledecomp.bin import Bin as IsleBin import colorama -colorama.init() +colorama.just_fix_windows_console() # Ignore all compare-db messages. diff --git a/tools/decomplint/decomplint.py b/tools/decomplint/decomplint.py index cfe9155b..6c7c1b4c 100755 --- a/tools/decomplint/decomplint.py +++ b/tools/decomplint/decomplint.py @@ -7,7 +7,7 @@ from isledecomp.dir import walk_source_dir, is_file_cpp from isledecomp.parser import DecompLinter -colorama.init() +colorama.just_fix_windows_console() def display_errors(alerts, filename): diff --git a/tools/reccmp/reccmp.py b/tools/reccmp/reccmp.py index e77020cc..84266773 100755 --- a/tools/reccmp/reccmp.py +++ b/tools/reccmp/reccmp.py @@ -19,7 +19,7 @@ from pystache import Renderer import colorama -colorama.init() +colorama.just_fix_windows_console() def gen_json(json_file: str, orig_file: str, data): diff --git a/tools/requirements.txt b/tools/requirements.txt index 61249c09..3f5e4e84 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,7 +1,7 @@ tools/isledecomp capstone clang==16.* -colorama +colorama>=0.4.6 isledecomp pystache pyyaml diff --git a/tools/vtable/vtable.py b/tools/vtable/vtable.py index c5dc27a7..aa294659 100755 --- a/tools/vtable/vtable.py +++ b/tools/vtable/vtable.py @@ -12,7 +12,7 @@ # Ignore all compare-db messages. logging.getLogger("isledecomp.compare").addHandler(logging.NullHandler()) -colorama.init() +colorama.just_fix_windows_console() def parse_args() -> argparse.Namespace: From ce134e79efe905ee650a0e7e919ffff6bfe757b1 Mon Sep 17 00:00:00 2001 From: MS Date: Wed, 3 Apr 2024 12:06:53 -0400 Subject: [PATCH 2/6] Use reference on MxDSObject Deserialize calls (#767) --- LEGO1/omni/include/mxdsaction.h | 2 +- LEGO1/omni/include/mxdsmediaaction.h | 2 +- LEGO1/omni/include/mxdsmultiaction.h | 2 +- LEGO1/omni/include/mxdsobject.h | 4 +-- LEGO1/omni/include/mxdsselectaction.h | 2 +- LEGO1/omni/include/mxdssound.h | 2 +- LEGO1/omni/include/mxutilities.h | 24 +++++++-------- LEGO1/omni/src/action/mxdsaction.cpp | 10 ++++--- LEGO1/omni/src/action/mxdsmediaaction.cpp | 4 +-- LEGO1/omni/src/action/mxdsmultiaction.cpp | 18 +++++------ LEGO1/omni/src/action/mxdsobject.cpp | 12 ++++---- LEGO1/omni/src/action/mxdsselectaction.cpp | 30 +++++++++---------- LEGO1/omni/src/action/mxdssound.cpp | 2 +- LEGO1/omni/src/common/mxutilities.cpp | 2 +- LEGO1/omni/src/stream/mxdsbuffer.cpp | 2 +- LEGO1/omni/src/stream/mxramstreamprovider.cpp | 2 +- LEGO1/omni/src/stream/mxstreamchunk.cpp | 19 ++++++++---- 17 files changed, 74 insertions(+), 65 deletions(-) diff --git a/LEGO1/omni/include/mxdsaction.h b/LEGO1/omni/include/mxdsaction.h index 1ba24f40..c7aa5008 100644 --- a/LEGO1/omni/include/mxdsaction.h +++ b/LEGO1/omni/include/mxdsaction.h @@ -45,7 +45,7 @@ class MxDSAction : public MxDSObject { undefined4 VTable0x14() override; // vtable+14; MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8** p_source, MxS16 p_unk0x24) override; // vtable+1c; + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; virtual MxLong GetDuration(); // vtable+24; virtual void SetDuration(MxLong p_duration); // vtable+28; virtual MxDSAction* Clone(); // vtable+2c; diff --git a/LEGO1/omni/include/mxdsmediaaction.h b/LEGO1/omni/include/mxdsmediaaction.h index 32664156..1fb95cc0 100644 --- a/LEGO1/omni/include/mxdsmediaaction.h +++ b/LEGO1/omni/include/mxdsmediaaction.h @@ -33,7 +33,7 @@ class MxDSMediaAction : public MxDSAction { undefined4 VTable0x14() override; // vtable+14; MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8** p_source, MxS16 p_unk0x24) override; // vtable+1c; + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; MxDSAction* Clone() override; // vtable+2c; void CopyMediaSrcPath(const char* p_mediaSrcPath); diff --git a/LEGO1/omni/include/mxdsmultiaction.h b/LEGO1/omni/include/mxdsmultiaction.h index d97e6116..c74d62f0 100644 --- a/LEGO1/omni/include/mxdsmultiaction.h +++ b/LEGO1/omni/include/mxdsmultiaction.h @@ -29,7 +29,7 @@ class MxDSMultiAction : public MxDSAction { undefined4 VTable0x14() override; // vtable+14; MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8** p_source, MxS16 p_unk0x24) override; // vtable+1c; + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; void SetAtomId(MxAtomId p_atomId) override; // vtable+20; MxDSAction* Clone() override; // vtable+2c; void MergeFrom(MxDSAction& p_dsAction) override; // vtable+30; diff --git a/LEGO1/omni/include/mxdsobject.h b/LEGO1/omni/include/mxdsobject.h index 48702793..f141afc0 100644 --- a/LEGO1/omni/include/mxdsobject.h +++ b/LEGO1/omni/include/mxdsobject.h @@ -46,7 +46,7 @@ class MxDSObject : public MxCore { virtual undefined4 VTable0x14(); // vtable+14; virtual MxU32 GetSizeOnDisk(); // vtable+18; - virtual void Deserialize(MxU8** p_source, MxS16 p_unk0x24); // vtable+1c; + virtual void Deserialize(MxU8*& p_source, MxS16 p_unk0x24); // vtable+1c; inline virtual void SetAtomId(MxAtomId p_atomId) { this->m_atomId = p_atomId; } // vtable+20; inline Type GetType() const { return (Type) this->m_type; } @@ -79,7 +79,7 @@ class MxDSObject : public MxCore { MxPresenter* m_unk0x28; // 0x28 }; -MxDSObject* DeserializeDSObjectDispatch(MxU8**, MxS16); +MxDSObject* DeserializeDSObjectDispatch(MxU8*&, MxS16); // FUNCTION: ISLE 0x401c40 // MxDSObject::SetAtomId diff --git a/LEGO1/omni/include/mxdsselectaction.h b/LEGO1/omni/include/mxdsselectaction.h index ab2e6609..24c8a6d5 100644 --- a/LEGO1/omni/include/mxdsselectaction.h +++ b/LEGO1/omni/include/mxdsselectaction.h @@ -29,7 +29,7 @@ class MxDSSelectAction : public MxDSParallelAction { } MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8** p_source, MxS16 p_unk0x24) override; // vtable+1c; + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; MxDSAction* Clone() override; // vtable+2c; // SYNTHETIC: LEGO1 0x100cb840 diff --git a/LEGO1/omni/include/mxdssound.h b/LEGO1/omni/include/mxdssound.h index 193fde3a..c406ba92 100644 --- a/LEGO1/omni/include/mxdssound.h +++ b/LEGO1/omni/include/mxdssound.h @@ -27,7 +27,7 @@ class MxDSSound : public MxDSMediaAction { } MxU32 GetSizeOnDisk() override; // vtable+18; - void Deserialize(MxU8** p_source, MxS16 p_unk0x24) override; // vtable+1c; + void Deserialize(MxU8*& p_source, MxS16 p_unk0x24) override; // vtable+1c; MxDSAction* Clone() override; // vtable+2c; inline MxS32 GetVolume() const { return m_volume; } diff --git a/LEGO1/omni/include/mxutilities.h b/LEGO1/omni/include/mxutilities.h index 5959518c..59ff7d89 100644 --- a/LEGO1/omni/include/mxutilities.h +++ b/LEGO1/omni/include/mxutilities.h @@ -30,32 +30,32 @@ inline T Max(T p_t1, T p_t2) } template -inline void GetScalar(MxU8** p_source, T& p_dest) +inline void GetScalar(MxU8*& p_source, T& p_dest) { - p_dest = *(T*) *p_source; - *p_source += sizeof(T); + p_dest = *(T*) p_source; + p_source += sizeof(T); } template -inline T GetScalar(T** p_source) +inline T GetScalar(T*& p_source) { - T val = **p_source; - *p_source += 1; + T val = *p_source; + p_source += 1; return val; } template -inline void GetDouble(MxU8** p_source, T& p_dest) +inline void GetDouble(MxU8*& p_source, T& p_dest) { - p_dest = *(double*) *p_source; - *p_source += sizeof(double); + p_dest = *(double*) p_source; + p_source += sizeof(double); } template -inline void GetString(MxU8** p_source, char** p_dest, T* p_obj, void (T::*p_setter)(const char*)) +inline void GetString(MxU8*& p_source, char*& p_dest, T* p_obj, void (T::*p_setter)(const char*)) { - (p_obj->*p_setter)((char*) *p_source); - *p_source += strlen(*p_dest) + 1; + (p_obj->*p_setter)((char*) p_source); + p_source += strlen(p_dest) + 1; } MxBool GetRectIntersection( diff --git a/LEGO1/omni/src/action/mxdsaction.cpp b/LEGO1/omni/src/action/mxdsaction.cpp index 26322ceb..b72481e2 100644 --- a/LEGO1/omni/src/action/mxdsaction.cpp +++ b/LEGO1/omni/src/action/mxdsaction.cpp @@ -221,7 +221,7 @@ void MxDSAction::AppendData(MxU16 p_extraLength, const char* p_extraData) } // FUNCTION: LEGO1 0x100adf70 -void MxDSAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) +void MxDSAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { MxDSObject::Deserialize(p_source, p_unk0x24); @@ -239,9 +239,11 @@ void MxDSAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) GetDouble(p_source, this->m_up[1]); GetDouble(p_source, this->m_up[2]); - MxU16 extraLength = GetScalar((MxU16**) p_source); + MxU16 extraLength = *(MxU16*) p_source; + p_source += 2; + if (extraLength) { - AppendData(extraLength, (char*) *p_source); - *p_source += extraLength; + AppendData(extraLength, (char*) p_source); + p_source += extraLength; } } diff --git a/LEGO1/omni/src/action/mxdsmediaaction.cpp b/LEGO1/omni/src/action/mxdsmediaaction.cpp index 26699fcb..9da0946a 100644 --- a/LEGO1/omni/src/action/mxdsmediaaction.cpp +++ b/LEGO1/omni/src/action/mxdsmediaaction.cpp @@ -104,11 +104,11 @@ MxU32 MxDSMediaAction::GetSizeOnDisk() } // FUNCTION: LEGO1 0x100c8f60 -void MxDSMediaAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) +void MxDSMediaAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { MxDSAction::Deserialize(p_source, p_unk0x24); - GetString(p_source, &this->m_mediaSrcPath, this, &MxDSMediaAction::CopyMediaSrcPath); + GetString(p_source, this->m_mediaSrcPath, this, &MxDSMediaAction::CopyMediaSrcPath); GetScalar(p_source, this->m_unk0x9c.m_unk0x00); GetScalar(p_source, this->m_unk0x9c.m_unk0x04); GetScalar(p_source, this->m_framesPerSecond); diff --git a/LEGO1/omni/src/action/mxdsmultiaction.cpp b/LEGO1/omni/src/action/mxdsmultiaction.cpp index 40216ae7..d18c75de 100644 --- a/LEGO1/omni/src/action/mxdsmultiaction.cpp +++ b/LEGO1/omni/src/action/mxdsmultiaction.cpp @@ -129,29 +129,29 @@ MxU32 MxDSMultiAction::GetSizeOnDisk() } // FUNCTION: LEGO1 0x100ca7b0 -void MxDSMultiAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) +void MxDSMultiAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { MxDSAction::Deserialize(p_source, p_unk0x24); - MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1; - *p_source += 12; + MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; + p_source += 12; - MxU32 count = *(MxU32*) *p_source; - *p_source += sizeof(count); + MxU32 count = *(MxU32*) p_source; + p_source += sizeof(count); if (count) { while (count--) { - MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1; - *p_source += 8; + MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; + p_source += 8; MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24); - *p_source += extraFlag; + p_source += extraFlag; this->m_actions->Append(action); } } - *p_source += extraFlag; + p_source += extraFlag; } // FUNCTION: LEGO1 0x100ca8c0 diff --git a/LEGO1/omni/src/action/mxdsobject.cpp b/LEGO1/omni/src/action/mxdsobject.cpp index c0db27d9..e99a12d4 100644 --- a/LEGO1/omni/src/action/mxdsobject.cpp +++ b/LEGO1/omni/src/action/mxdsobject.cpp @@ -131,21 +131,21 @@ MxU32 MxDSObject::GetSizeOnDisk() } // FUNCTION: LEGO1 0x100bfa20 -void MxDSObject::Deserialize(MxU8** p_source, MxS16 p_unk0x24) +void MxDSObject::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { - GetString(p_source, &this->m_sourceName, this, &MxDSObject::SetSourceName); + GetString(p_source, this->m_sourceName, this, &MxDSObject::SetSourceName); GetScalar(p_source, this->m_unk0x14); - GetString(p_source, &this->m_objectName, this, &MxDSObject::SetObjectName); + GetString(p_source, this->m_objectName, this, &MxDSObject::SetObjectName); GetScalar(p_source, this->m_objectId); this->m_unk0x24 = p_unk0x24; } // FUNCTION: LEGO1 0x100bfb30 -MxDSObject* DeserializeDSObjectDispatch(MxU8** p_source, MxS16 p_flags) +MxDSObject* DeserializeDSObjectDispatch(MxU8*& p_source, MxS16 p_flags) { - MxU16 type = *(MxU16*) *p_source; - *p_source += 2; + MxU16 type = *(MxU16*) p_source; + p_source += 2; MxDSObject* obj = NULL; diff --git a/LEGO1/omni/src/action/mxdsselectaction.cpp b/LEGO1/omni/src/action/mxdsselectaction.cpp index 2a3e7ca2..79fec8a0 100644 --- a/LEGO1/omni/src/action/mxdsselectaction.cpp +++ b/LEGO1/omni/src/action/mxdsselectaction.cpp @@ -81,15 +81,15 @@ MxU32 MxDSSelectAction::GetSizeOnDisk() } // FUNCTION: LEGO1 0x100cbf60 -void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) +void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { MxString string; MxDSAction::Deserialize(p_source, p_unk0x24); - MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1; - *p_source += 12; + MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; + p_source += 12; - this->m_unk0x9c = (char*) *p_source; + this->m_unk0x9c = (char*) p_source; if (!strnicmp(this->m_unk0x9c.GetData(), "RANDOM_", strlen("RANDOM_"))) { char buffer[10]; @@ -100,13 +100,13 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) string = itoa((MxS16) random, buffer, 10); } else { - string = VariableTable()->GetVariable((char*) *p_source); + string = VariableTable()->GetVariable((char*) p_source); } - *p_source += strlen((char*) *p_source) + 1; + p_source += strlen((char*) p_source) + 1; - MxU32 count = *(MxU32*) *p_source; - *p_source += sizeof(MxU32); + MxU32 count = *(MxU32*) p_source; + p_source += sizeof(MxU32); if (count) { MxS32 index = -1; @@ -114,17 +114,17 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) MxU32 i; for (i = 0; i < count; i++) { - if (!strcmp(string.GetData(), (char*) *p_source)) { + if (!strcmp(string.GetData(), (char*) p_source)) { index = i; } - this->m_unk0xac->Append((char*) *p_source); - *p_source += strlen((char*) *p_source) + 1; + this->m_unk0xac->Append((char*) p_source); + p_source += strlen((char*) p_source) + 1; } for (i = 0; i < count; i++) { - MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1; - *p_source += 8; + MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; + p_source += 8; MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24); @@ -135,9 +135,9 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24) delete action; } - *p_source += extraFlag; + p_source += extraFlag; } } - *p_source += extraFlag; + p_source += extraFlag; } diff --git a/LEGO1/omni/src/action/mxdssound.cpp b/LEGO1/omni/src/action/mxdssound.cpp index d2075dbd..2340ea96 100644 --- a/LEGO1/omni/src/action/mxdssound.cpp +++ b/LEGO1/omni/src/action/mxdssound.cpp @@ -48,7 +48,7 @@ MxDSAction* MxDSSound::Clone() } // FUNCTION: LEGO1 0x100c95a0 -void MxDSSound::Deserialize(MxU8** p_source, MxS16 p_unk0x24) +void MxDSSound::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) { MxDSMediaAction::Deserialize(p_source, p_unk0x24); diff --git a/LEGO1/omni/src/common/mxutilities.cpp b/LEGO1/omni/src/common/mxutilities.cpp index 26dd733b..fe45327e 100644 --- a/LEGO1/omni/src/common/mxutilities.cpp +++ b/LEGO1/omni/src/common/mxutilities.cpp @@ -185,7 +185,7 @@ MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs) // Save a copy so we can clean up properly, because // this function will alter the pointer value. MxU8* copy = buf; - MxDSObject* obj = DeserializeDSObjectDispatch(&buf, -1); + MxDSObject* obj = DeserializeDSObjectDispatch(buf, -1); delete[] copy; return obj; } diff --git a/LEGO1/omni/src/stream/mxdsbuffer.cpp b/LEGO1/omni/src/stream/mxdsbuffer.cpp index d3f075dd..bc40f71c 100644 --- a/LEGO1/omni/src/stream/mxdsbuffer.cpp +++ b/LEGO1/omni/src/stream/mxdsbuffer.cpp @@ -322,7 +322,7 @@ MxCore* MxDSBuffer::ReadChunk(MxDSBuffer* p_buffer, MxU32* p_chunkData, MxU16 p_ switch (*p_chunkData) { case FOURCC('M', 'x', 'O', 'b'): - result = DeserializeDSObjectDispatch(&dataStart, p_flags); + result = DeserializeDSObjectDispatch(dataStart, p_flags); break; case FOURCC('M', 'x', 'C', 'h'): result = new MxStreamChunk(); diff --git a/LEGO1/omni/src/stream/mxramstreamprovider.cpp b/LEGO1/omni/src/stream/mxramstreamprovider.cpp index 472930c7..d0915810 100644 --- a/LEGO1/omni/src/stream/mxramstreamprovider.cpp +++ b/LEGO1/omni/src/stream/mxramstreamprovider.cpp @@ -113,7 +113,7 @@ MxU32 ReadData(MxU8* p_buffer, MxU32 p_size) data2 = data; data += 8; - MxDSObject* obj = DeserializeDSObjectDispatch(&data, -1); + MxDSObject* obj = DeserializeDSObjectDispatch(data, -1); id = obj->GetObjectId(); delete obj; diff --git a/LEGO1/omni/src/stream/mxstreamchunk.cpp b/LEGO1/omni/src/stream/mxstreamchunk.cpp index 9d5d0fe4..7289b3e2 100644 --- a/LEGO1/omni/src/stream/mxstreamchunk.cpp +++ b/LEGO1/omni/src/stream/mxstreamchunk.cpp @@ -36,12 +36,19 @@ MxU32 MxStreamChunk::ReadChunkHeader(MxU8* p_chunkData) MxU32 headersize = 0; if (p_chunkData) { MxU8* chunkData = p_chunkData; - // Note: the alpha debug version uses memcpy calls here, - // but the code generation is the same. - GetScalar(&p_chunkData, m_flags); - GetScalar(&p_chunkData, m_objectId); - GetScalar(&p_chunkData, m_time); - GetScalar(&p_chunkData, m_length); + + memcpy(&m_flags, p_chunkData, sizeof(m_flags)); + p_chunkData += sizeof(m_flags); + + memcpy(&m_objectId, p_chunkData, sizeof(m_objectId)); + p_chunkData += sizeof(m_objectId); + + memcpy(&m_time, p_chunkData, sizeof(m_time)); + p_chunkData += sizeof(m_time); + + memcpy(&m_length, p_chunkData, sizeof(m_length)); + p_chunkData += sizeof(m_length); + m_data = p_chunkData; headersize = p_chunkData - chunkData; } From a8eebe454ebb568640c0e3302920bc6a1fee6e2c Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Thu, 4 Apr 2024 06:26:03 -0400 Subject: [PATCH 3/6] Implement/match LegoExtraActor:: WaitForAnimation, Restart (#768) * Implement/match LegoExtraActor:: WaitForAnimation, Restart * whitespace --------- Co-authored-by: Christian Semmler --- .../lego/legoomni/include/legoanimpresenter.h | 6 ++- .../lego/legoomni/include/legocarraceactor.h | 2 +- LEGO1/lego/legoomni/include/legoentity.h | 1 + LEGO1/lego/legoomni/include/legoextraactor.h | 5 +- LEGO1/lego/legoomni/include/legojetski.h | 2 +- .../legoomni/include/legojetskiraceactor.h | 2 +- LEGO1/lego/legoomni/include/legopathactor.h | 4 +- .../lego/legoomni/include/legopathboundary.h | 15 +++++- LEGO1/lego/legoomni/include/legoracecar.h | 2 +- .../legoomni/src/entity/legocarraceactor.cpp | 3 +- LEGO1/lego/legoomni/src/entity/legojetski.cpp | 3 +- .../src/entity/legojetskiraceactor.cpp | 3 +- .../legoomni/src/paths/legoextraactor.cpp | 54 +++++++++++++++++-- .../lego/legoomni/src/paths/legopathactor.cpp | 3 +- LEGO1/lego/legoomni/src/race/legoracecar.cpp | 3 +- 15 files changed, 88 insertions(+), 20 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 0c86a6b0..0eff701b 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -51,7 +51,11 @@ class LegoAnimPresenter : public MxVideoPresenter { virtual void VTable0x98(); // vtable+0x98 // STUB: LEGO1 0x1000c990 - virtual void VTable0x9c() {} // vtable+0x9c + virtual undefined4* VTable0x9c(undefined4& p_unk0x6c) + { + p_unk0x6c = m_unk0x6c; + return m_unk0x68; + } // vtable+0x9c virtual void VTable0xa0(); // vtable+0xa0 diff --git a/LEGO1/lego/legoomni/include/legocarraceactor.h b/LEGO1/lego/legoomni/include/legocarraceactor.h index 29ff1797..5671418c 100644 --- a/LEGO1/lego/legoomni/include/legocarraceactor.h +++ b/LEGO1/lego/legoomni/include/legocarraceactor.h @@ -32,7 +32,7 @@ class LegoCarRaceActor : public virtual LegoRaceActor { MxU32 VTable0x90(float, Matrix4&) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c virtual void FUN_10080590(); diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 69a482cf..775c4f6f 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -72,6 +72,7 @@ class LegoEntity : public MxEntity { inline MxBool GetUnknown0x10IsSet(MxU8 p_flag) { return m_unk0x10 & p_flag; } inline MxU8 GetFlags() { return m_flags; } + inline MxFloat GetWorldSpeed() { return m_worldSpeed; } inline LegoROI* GetROI() { return m_roi; } inline MxU8 GetUnknown0x59() { return m_unk0x59; } diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index 80da50f3..edaf6928 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -41,11 +41,12 @@ class LegoExtraActor : public virtual LegoAnimActor { void VTable0x74(Matrix4& p_transform) override; // vtable+0x74 MxU32 VTable0x90(float p_float, Matrix4& p_matrix) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c void VTable0xa4(MxU8& p_und1, MxS32& p_und2) override; // vtable+0xa4 void VTable0xc4() override; // vtable+0xc4 virtual MxResult FUN_1002aae0(); + void Restart(); inline void FUN_1002ad8a(); // SYNTHETIC: LEGO1 0x1002b760 @@ -56,7 +57,7 @@ class LegoExtraActor : public virtual LegoAnimActor { undefined m_unk0x0c; // 0x0c MxU8 m_axis; // 0x0d undefined m_unk0x0e; // 0x0e - MxFloat m_unk0x10; // 0x10 + MxFloat m_prevWorldSpeed; // 0x10 MxU8 m_unk0x14; // 0x14 MxU8 m_unk0x15; // 0x15 MxMatrix m_unk0x18; // 0x18 diff --git a/LEGO1/lego/legoomni/include/legojetski.h b/LEGO1/lego/legoomni/include/legojetski.h index a153d607..9761a3a6 100644 --- a/LEGO1/lego/legoomni/include/legojetski.h +++ b/LEGO1/lego/legoomni/include/legojetski.h @@ -37,7 +37,7 @@ class LegoJetski : public LegoJetskiRaceActor, public LegoRaceMap { void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c virtual void FUN_100136f0(float p_worldSpeed); diff --git a/LEGO1/lego/legoomni/include/legojetskiraceactor.h b/LEGO1/lego/legoomni/include/legojetskiraceactor.h index d24566f5..20bbb545 100644 --- a/LEGO1/lego/legoomni/include/legojetskiraceactor.h +++ b/LEGO1/lego/legoomni/include/legojetskiraceactor.h @@ -30,7 +30,7 @@ class LegoJetskiRaceActor : public virtual LegoCarRaceActor { void VTable0x6c() override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c void VTable0x1c() override; // vtable+0x1c // SYNTHETIC: LEGO1 0x10081d40 diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 3a9bea76..e78cae8b 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -51,8 +51,8 @@ class LegoPathActor : public LegoActor { // FUNCTION: LEGO1 0x10002d50 virtual MxResult VTable0x94(LegoPathActor*, MxBool) { return 0; } // vtable+0x94 - virtual void VTable0x98(); // vtable+0x98 - virtual void VTable0x9c(); // vtable+0x9c + virtual void VTable0x98(); // vtable+0x98 + virtual MxResult WaitForAnimation(); // vtable+0x9c // FUNCTION: LEGO1 0x10002d60 virtual MxS32 VTable0xa0() { return 0; } // vtable+0xa0 diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index 11a97230..763059f5 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -2,6 +2,7 @@ #define LEGOPATHBOUNDARY_H #include "geom/legowegedge.h" +#include "legoanimpresenter.h" #include "mxstl/stlcompat.h" #include "mxtypes.h" @@ -9,6 +10,12 @@ struct LegoPathBoundaryComparator { MxBool operator()(const undefined*, const undefined*) const { return 0; } }; +struct LegoAnimPresenterSetCompare { + MxBool operator()(const LegoAnimPresenter*, const LegoAnimPresenter*) const { return 0; } +}; + +typedef set LegoAnimPresenterSet; + // VTABLE: LEGO1 0x100d8618 // SIZE 0x74 class LegoPathBoundary : public LegoWEGEdge { @@ -17,10 +24,16 @@ class LegoPathBoundary : public LegoWEGEdge { // STUB: LEGO1 0x10047a80 // LegoPathBoundary::`scalar deleting destructor' + inline LegoAnimPresenterSet* GetUnknown0x64() { return &m_unk0x64; } private: map m_unk0x54; // 0x54 - map m_unk0x64; // 0x64 + LegoAnimPresenterSet m_unk0x64; // 0x64 }; +// clang-format off +// GLOBAL: LEGO1 0x100f3200 +// _Tree >::_Kfn,LegoAnimPresenterSetCompare,allocator >::_Nil +// clang-format on + #endif // LEGOPATHBOUNDARY_H diff --git a/LEGO1/lego/legoomni/include/legoracecar.h b/LEGO1/lego/legoomni/include/legoracecar.h index 58098a94..f6b21501 100644 --- a/LEGO1/lego/legoomni/include/legoracecar.h +++ b/LEGO1/lego/legoomni/include/legoracecar.h @@ -37,7 +37,7 @@ class LegoRaceCar : public LegoCarRaceActor, public LegoRaceMap { void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c virtual void FUN_10012ea0(float p_worldSpeed); virtual void FUN_10012ff0(float); diff --git a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp index e28ebc46..2e3524c7 100644 --- a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp @@ -70,7 +70,8 @@ void LegoCarRaceActor::VTable0x98() } // STUB: LEGO1 0x10081d30 -void LegoCarRaceActor::VTable0x9c() +MxResult LegoCarRaceActor::WaitForAnimation() { // TODO + return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/entity/legojetski.cpp b/LEGO1/lego/legoomni/src/entity/legojetski.cpp index 75cf5cff..c919276c 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetski.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetski.cpp @@ -69,7 +69,8 @@ void LegoJetski::VTable0x98() } // STUB: LEGO1 0x10014200 -void LegoJetski::VTable0x9c() +MxResult LegoJetski::WaitForAnimation() { // TODO + return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp index 14fde544..f5e8c8a4 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp @@ -36,7 +36,8 @@ void LegoJetskiRaceActor::VTable0x98() } // STUB: LEGO1 0x100822e0 -void LegoJetskiRaceActor::VTable0x9c() +MxResult LegoJetskiRaceActor::WaitForAnimation() { // TODO + return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index a1a84eba..45d43cc0 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -145,7 +145,7 @@ MxResult LegoExtraActor::FUN_1002aae0() m_boundary = oldEdge; } - LegoPathActor::VTable0x9c(); + LegoPathActor::WaitForAnimation(); return SUCCESS; } @@ -229,7 +229,7 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) FUN_1002ad8a(); SoundManager()->GetCacheSoundManager()->FUN_1003dae0("crash5", m_roi->GetName(), FALSE); m_scheduledTime = Timer()->GetTime() + m_disAnim->GetDuration(); - m_unk0x10 = m_worldSpeed; + m_prevWorldSpeed = m_worldSpeed; VTable0xc4(); SetWorldSpeed(0); m_unk0x14 = 1; @@ -273,10 +273,54 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) return SUCCESS; } -// STUB: LEGO1 0x1002b290 -void LegoExtraActor::VTable0x9c() +// FUNCTION: LEGO1 0x1002b290 +MxResult LegoExtraActor::WaitForAnimation() { - // TODO + LegoPathBoundary* oldBoundary = m_boundary; + MxResult result = LegoPathActor::WaitForAnimation(); + + if (m_boundary != oldBoundary) { + MxU32 b = FALSE; + LegoAnimPresenterSet* set = m_boundary->GetUnknown0x64(); + + for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) { + undefined4 tmp; + if ((*it)->VTable0x9c(tmp)) { + b = TRUE; + break; + } + } + + if (b) { + m_unk0x0e = 1; + m_prevWorldSpeed = GetWorldSpeed(); + SetWorldSpeed(0); + } + } + + return result; +} + +// FUNCTION: LEGO1 0x1002b370 +void LegoExtraActor::Restart() +{ + if (m_unk0x0e != 0) { + MxU32 b = FALSE; + LegoAnimPresenterSet* set = m_boundary->GetUnknown0x64(); + + for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) { + undefined4 tmp; + if ((*it)->VTable0x9c(tmp)) { + b = TRUE; + break; + } + } + + if (!b) { + SetWorldSpeed(m_prevWorldSpeed); + m_unk0x0e = 0; + } + } } // STUB: LEGO1 0x1002b440 diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 8ab1c470..e389d1b8 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -75,9 +75,10 @@ void LegoPathActor::ParseAction(char*) } // STUB: LEGO1 0x1002f1b0 -void LegoPathActor::VTable0x9c() +MxResult LegoPathActor::WaitForAnimation() { // TODO + return SUCCESS; } // STUB: LEGO1 0x1002f650 diff --git a/LEGO1/lego/legoomni/src/race/legoracecar.cpp b/LEGO1/lego/legoomni/src/race/legoracecar.cpp index b7fc1ee3..0c7484a3 100644 --- a/LEGO1/lego/legoomni/src/race/legoracecar.cpp +++ b/LEGO1/lego/legoomni/src/race/legoracecar.cpp @@ -89,7 +89,8 @@ void LegoRaceCar::VTable0x98() } // STUB: LEGO1 0x10014580 -void LegoRaceCar::VTable0x9c() +MxResult LegoRaceCar::WaitForAnimation() { // TODO + return SUCCESS; } From 32f1621ec75e45ede2fae496053400ca41672201 Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Fri, 5 Apr 2024 06:56:31 -0400 Subject: [PATCH 4/6] Implement LegoExtraActor::VTable0x70 (#769) * Implement LegoExtraActor::VTable0x70 * whitespace --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/include/legoextraactor.h | 2 +- .../legoomni/src/paths/legoextraactor.cpp | 63 +++++++++++++++++-- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index edaf6928..5da2ddcb 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -58,7 +58,7 @@ class LegoExtraActor : public virtual LegoAnimActor { MxU8 m_axis; // 0x0d undefined m_unk0x0e; // 0x0e MxFloat m_prevWorldSpeed; // 0x10 - MxU8 m_unk0x14; // 0x14 + MxU8 m_whichAnim; // 0x14 MxU8 m_unk0x15; // 0x15 MxMatrix m_unk0x18; // 0x18 LegoAnimActorStruct* m_assAnim; // 0x60 diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index 45d43cc0..07a65f73 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -29,7 +29,7 @@ LegoExtraActor::LegoExtraActor() m_scheduledTime = 0; m_unk0x0c = 0; m_unk0x0e = 0; - m_unk0x14 = 0; + m_whichAnim = 0; m_assAnim = NULL; m_disAnim = NULL; m_unk0x15 = 0; @@ -232,7 +232,7 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) m_prevWorldSpeed = m_worldSpeed; VTable0xc4(); SetWorldSpeed(0); - m_unk0x14 = 1; + m_whichAnim = 1; m_state = 0x101; } } @@ -323,16 +323,67 @@ void LegoExtraActor::Restart() } } -// STUB: LEGO1 0x1002b440 -void LegoExtraActor::VTable0x70(float) +// FUNCTION: LEGO1 0x1002b440 +void LegoExtraActor::VTable0x70(float p_time) { - // TODO + LegoAnimActorStruct* laas = NULL; + + switch (m_whichAnim) { + case 0: + LegoAnimActor::VTable0x70(p_time); + break; + case 1: + if (m_scheduledTime < p_time) { + m_whichAnim = 2; + m_state = 0x101; + m_scheduledTime = m_assAnim->GetDuration() + p_time; + break; + } + else { + laas = m_disAnim; + break; + } + case 2: + if (m_scheduledTime < p_time) { + m_whichAnim = 0; + m_state = 0; + SetWorldSpeed(m_prevWorldSpeed); + m_roi->FUN_100a58f0(m_unk0x18); + m_lastTime = p_time; + break; + } + else { + laas = m_assAnim; + break; + } + } + + if (laas) { + float duration2, duration; + duration = laas->GetDuration(); + duration2 = p_time - (m_scheduledTime - duration); + + if (duration2 < 0) { + duration2 = 0; + } + else if (duration2 > duration) { + duration2 = duration; + } + + MxMatrix matrix(m_roi->GetLocal2World()); + LegoTreeNode* root = laas->m_AnimTreePtr->GetRoot(); + MxS32 count = root->GetNumChildren(); + + for (MxS32 i = 0; i < count; i++) { + LegoROI::FUN_100a8e80(root->GetChild(i), matrix, duration2, laas->m_roiMap); + } + } } // FUNCTION: LEGO1 0x1002b5d0 void LegoExtraActor::VTable0x74(Matrix4& p_transform) { - if (m_unk0x14 == 0) { + if (m_whichAnim == 0) { LegoAnimActor::VTable0x74(p_transform); } } From c9ce9b56bbf04422c43a4eac841f919b1ac210fa Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 5 Apr 2024 09:57:20 -0400 Subject: [PATCH 5/6] Implement/match LegoCharacterManager::FUN_10084ec0 (#770) * Implement LegoCharacterManager::FUN_10084ec0 * Match * Match CreateROI * Match * Improve match --- .../legoomni/include/legocharactermanager.h | 1 + .../src/common/legocharactermanager.cpp | 87 +++++++++++++++---- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h index bc385091..d32d57a1 100644 --- a/LEGO1/lego/legoomni/include/legocharactermanager.h +++ b/LEGO1/lego/legoomni/include/legocharactermanager.h @@ -56,6 +56,7 @@ class LegoCharacterManager { LegoExtraActor* GetActor(const char* p_key); LegoCharacterData* GetData(const char* p_key); LegoCharacterData* GetData(LegoROI* p_roi); + LegoROI* FUN_10084cf0(LegoROI* p_roi, const char*); MxBool FUN_10084ec0(LegoROI* p_roi); MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und); LegoROI* FUN_10085210(const char* p_name, const char* p_lodName, MxBool p_createEntity); diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 2f2d3072..95e5c2fc 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -25,6 +25,9 @@ MxU32 g_unk0x100fc4d8 = 50; // GLOBAL: LEGO1 0x100fc4dc MxU32 g_unk0x100fc4dc = 66; +// GLOBAL: LEGO1 0x100fc4ec +MxU32 g_unk0x100fc4ec = 2; + // GLOBAL: LEGO1 0x100fc4f0 MxU32 g_unk0x100fc4f0 = 0; @@ -254,7 +257,7 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) BoundingBox boundingBox; MxMatrix mat; CompoundObject* comp; - MxS32 i, j; + MxS32 i; Tgl::Renderer* renderer = VideoManager()->GetRenderer(); ViewLODListManager* lodManager = GetViewLODListManager(); @@ -298,14 +301,10 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) roi->SetComp(comp); for (i = 0; i < _countof(g_characterLODs) - 1; i++) { - ViewLODList *lodList, *dupLodList; - LegoROI* childROI; - MxS32 lodSize; - const char* parentName; - char lodName[64]; - + char lodName[256]; LegoCharacterData::Part& part = data->m_parts[i]; + const char* parentName; if (i == 0 || i == 1) { parentName = part.m_unk0x04[part.m_unk0x00[part.m_unk0x08]]; } @@ -313,19 +312,21 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) parentName = g_characterLODs[i + 1].m_parentName; } - lodList = lodManager->Lookup(parentName); - lodSize = lodList->Size(); + ViewLODList* lodList = lodManager->Lookup(parentName); + MxS32 lodSize = lodList->Size(); sprintf(lodName, "%s%d", p_key, i); - dupLodList = lodManager->Create(lodName, lodSize); + ViewLODList* dupLodList = lodManager->Create(lodName, lodSize); - for (j = 0; j < lodSize; j++) { - dupLodList->PushBack(((LegoLOD*) (*lodList)[j])->Clone(renderer)); + for (MxS32 j = 0; j < lodSize; j++) { + LegoLOD* lod = (LegoLOD*) (*lodList)[j]; + LegoLOD* clone = lod->Clone(renderer); + dupLodList->PushBack(clone); } lodList->Release(); lodList = dupLodList; - childROI = new LegoROI(renderer, lodList); + LegoROI* childROI = new LegoROI(renderer, lodList); lodList->Release(); childROI->SetName(g_characterLODs[i + 1].m_name); @@ -454,11 +455,65 @@ LegoCharacterData* LegoCharacterManager::GetData(LegoROI* p_roi) return NULL; } -// STUB: LEGO1 0x10084ec0 -MxBool LegoCharacterManager::FUN_10084ec0(LegoROI* p_roi) +// STUB: LEGO1 0x10084cf0 +LegoROI* LegoCharacterManager::FUN_10084cf0(LegoROI* p_roi, const char*) { // TODO - return FALSE; + return NULL; +} + +// FUNCTION: LEGO1 0x10084ec0 +MxBool LegoCharacterManager::FUN_10084ec0(LegoROI* p_roi) +{ + LegoCharacterData* data = GetData(p_roi->GetName()); + + if (data == NULL) { + return FALSE; + } + + LegoCharacterData::Part& part = data->m_parts[1]; + + part.m_unk0x08++; + MxU8 unk0x00 = part.m_unk0x00[part.m_unk0x08]; + + if (unk0x00 == 0xff) { + part.m_unk0x08 = 0; + unk0x00 = part.m_unk0x00[part.m_unk0x08]; + } + + LegoROI* childROI = FUN_10084cf0(p_roi, g_characterLODs[1].m_name); + + if (childROI != NULL) { + char lodName[256]; + + ViewLODList* lodList = GetViewLODListManager()->Lookup(part.m_unk0x04[unk0x00]); + MxS32 lodSize = lodList->Size(); + sprintf(lodName, "%s%d", p_roi->GetName(), g_unk0x100fc4ec++); + ViewLODList* dupLodList = GetViewLODListManager()->Create(lodName, lodSize); + + Tgl::Renderer* renderer = VideoManager()->GetRenderer(); + LegoFloat red, green, blue, alpha; + LegoROI::FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); + + for (MxS32 i = 0; i < lodSize; i++) { + LegoLOD* lod = (LegoLOD*) (*lodList)[i]; + LegoLOD* clone = lod->Clone(renderer); + clone->FUN_100aacb0(red, green, blue, alpha); + dupLodList->PushBack(clone); + } + + lodList->Release(); + lodList = dupLodList; + + if (childROI->GetUnknown0xe0() >= 0) { + VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->FUN_100a66a0(childROI); + } + + childROI->SetLODList(lodList); + lodList->Release(); + } + + return TRUE; } // FUNCTION: LEGO1 0x10085140 From 6450774aa7d95d6d86936de8cb4690cadce348b3 Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Fri, 5 Apr 2024 11:20:30 -0400 Subject: [PATCH 6/6] Implement/Match LegoExtraActor::VTable0xc4 (#771) * Implement/Match LegoExtraActor::VTable0xc4 * Style --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/src/paths/legoextraactor.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index 07a65f73..2d3726be 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -397,9 +397,23 @@ void LegoExtraActor::SetWorldSpeed(MxFloat p_worldSpeed) LegoAnimActor::SetWorldSpeed(p_worldSpeed); } -// STUB: LEGO1 0x1002b630 +// FUNCTION: LEGO1 0x1002b630 void LegoExtraActor::VTable0xc4() { + if (m_curAnim != 0) { + return; + } + + if (m_worldSpeed > -0.001 || m_worldSpeed < 0.001) { + MxU16 name = *((MxU16*) m_roi->GetName()); + MxBool b = name == TWOCC('m', 'a') || name == TWOCC('p', 'a'); + + if (b) { + float duration = m_animMaps[m_curAnim]->GetDuration(); + MxMatrix matrix(m_unk0xec); + LegoAnimActor::FUN_1001c360(duration, matrix); + } + } } // FUNCTION: LEGO1 0x1002b6f0