From fb1922941e95ecaaefa2fa4b7b389e1e9744a2dc Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 3 Nov 2025 19:50:49 -0600 Subject: [PATCH] feat(model): process attached models in CM2Model::InitializeLoaded --- src/model/CM2Model.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/model/CM2Model.cpp b/src/model/CM2Model.cpp index c31c9de..c83f9e4 100644 --- a/src/model/CM2Model.cpp +++ b/src/model/CM2Model.cpp @@ -1298,6 +1298,27 @@ int32_t CM2Model::InitializeLoaded() { // TODO + // Process model attachments that occurred during load + + CM2Model* attachNext = nullptr; + for (auto attachModel = this->m_attachList; attachModel; attachModel = attachNext) { + attachNext = attachModel->m_attachNext; + + uint16_t attachIndex = 0xFFFF; + + if (attachModel->m_attachId < this->m_shared->m_data->attachments.Count()) { + attachIndex = this->m_shared->m_data->attachmentIndicesById[attachModel->m_attachId]; + } + + if (attachIndex != 0xFFFF || attachModel->m_flag40000) { + attachModel->m_attachIndex = attachIndex; + } else { + attachModel->DetachFromParent(); + } + } + + // TODO + this->m_loaded = 1; uint32_t savedTime = this->m_scene->m_time;