From cbc51e81489bbdcb2fad8f94feae94c504f248e0 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 4 Sep 2025 09:36:26 -0700 Subject: [PATCH] (SiLoader) Remove Replace directive recursion (#705) --- extensions/include/extensions/siloader.h | 2 +- extensions/src/siloader.cpp | 27 +++++++----------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/extensions/include/extensions/siloader.h b/extensions/include/extensions/siloader.h index eb61521d..e7618615 100644 --- a/extensions/include/extensions/siloader.h +++ b/extensions/include/extensions/siloader.h @@ -47,7 +47,7 @@ class SiLoader { static bool LoadFile(const char* p_file); static bool LoadDirective(const char* p_directive); static MxStreamController* OpenStream(const char* p_file); - static void ParseExtra(const MxAtomId& p_atom, si::Core* p_core, MxAtomId p_parentReplacedAtom = MxAtomId()); + static void ParseExtra(const MxAtomId& p_atom, si::Core* p_core); static bool IsWorld(const StreamObject& p_object); }; diff --git a/extensions/src/siloader.cpp b/extensions/src/siloader.cpp index 9e11edd5..4e3a7beb 100644 --- a/extensions/src/siloader.cpp +++ b/extensions/src/siloader.cpp @@ -316,11 +316,9 @@ MxStreamController* SiLoader::OpenStream(const char* p_file) return controller; } -void SiLoader::ParseExtra(const MxAtomId& p_atom, si::Core* p_core, MxAtomId p_parentReplacedAtom) +void SiLoader::ParseExtra(const MxAtomId& p_atom, si::Core* p_core) { for (si::Core* child : p_core->GetChildren()) { - MxAtomId replacedAtom = p_parentReplacedAtom; - if (si::Object* object = dynamic_cast(child)) { if (object->type() != si::MxOb::Null) { std::string extra(object->extra_.data(), object->extra_.size()); @@ -346,21 +344,12 @@ void SiLoader::ParseExtra(const MxAtomId& p_atom, si::Core* p_core, MxAtomId p_p } } - if (p_parentReplacedAtom.GetInternal()) { - replace.emplace_back( - StreamObject{p_parentReplacedAtom, object->id_}, - StreamObject{p_atom, object->id_} - ); - } - else { - if ((directive = SDL_strstr(extra.c_str(), "Replace:"))) { - if (SDL_sscanf(directive, "Replace:%255[^:;]%*[:;]%u", atom, &id) == 2) { - replace.emplace_back( - StreamObject{MxAtomId{atom, e_lowerCase2}, id}, - StreamObject{p_atom, object->id_} - ); - replacedAtom = replace.back().first.first; - } + if ((directive = SDL_strstr(extra.c_str(), "Replace:"))) { + if (SDL_sscanf(directive, "Replace:%255[^:;]%*[:;]%u", atom, &id) == 2) { + replace.emplace_back( + StreamObject{MxAtomId{atom, e_lowerCase2}, id}, + StreamObject{p_atom, object->id_} + ); } } @@ -383,7 +372,7 @@ void SiLoader::ParseExtra(const MxAtomId& p_atom, si::Core* p_core, MxAtomId p_p } } - ParseExtra(p_atom, child, replacedAtom); + ParseExtra(p_atom, child); } }