From c0a85c42a3afad87b55a994652c1a001959e84c5 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 20 Aug 2025 16:34:14 -0700 Subject: [PATCH] Add SiLoader adjustments --- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 6 ++++- extensions/include/extensions/siloader.h | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 6b847211..b51011b5 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -2,6 +2,7 @@ #include "act3.h" #include "credits_actions.h" +#include "extensions/siloader.h" #include "helicopter.h" #include "infomain_actions.h" #include "intro_actions.h" @@ -36,6 +37,8 @@ DECOMP_SIZE_ASSERT(Infocenter, 0x1d8) DECOMP_SIZE_ASSERT(InfocenterMapEntry, 0x18) DECOMP_SIZE_ASSERT(InfocenterState, 0x94) +using namespace Extensions; + // GLOBAL: LEGO1 0x100f76a0 const char* g_object2x4red = "2x4red"; @@ -339,7 +342,8 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param) MxLong result = m_radio.Notify(p_param); - if (result || (action->GetAtomId() != m_atomId && action->GetAtomId() != *g_introScript)) { + if (result || (action->GetAtomId() != m_atomId && action->GetAtomId() != *g_introScript && + !Extension::Call(ReplacedIn, *action, m_atomId, *g_introScript).value_or(false))) { return result; } diff --git a/extensions/include/extensions/siloader.h b/extensions/include/extensions/siloader.h index 3f50d08a..2a82bd3b 100644 --- a/extensions/include/extensions/siloader.h +++ b/extensions/include/extensions/siloader.h @@ -27,6 +27,9 @@ class SiLoader { static std::optional HandleDelete(MxDSAction& p_action); static MxBool HandleEndAction(MxEndActionNotificationParam& p_param); + template + static bool ReplacedIn(MxDSAction& p_action, Args... p_args); + static std::map options; static std::vector files; static std::vector directives; @@ -47,12 +50,30 @@ class SiLoader { }; #ifdef EXTENSIONS +template +bool SiLoader::ReplacedIn(MxDSAction& p_action, Args... p_args) +{ + StreamObject object{p_action.GetAtomId(), p_action.GetObjectId()}; + auto checkAtomId = [&p_action, &object](const auto& p_atomId) -> bool { + for (const auto& key : replace) { + if (key.second == object && key.first.first == p_atomId) { + return true; + } + } + + return false; + }; + + return (checkAtomId(p_args) || ...); +} + constexpr auto Load = &SiLoader::Load; constexpr auto HandleFind = &SiLoader::HandleFind; constexpr auto HandleStart = &SiLoader::HandleStart; constexpr auto HandleRemove = &SiLoader::HandleRemove; constexpr auto HandleDelete = &SiLoader::HandleDelete; constexpr auto HandleEndAction = &SiLoader::HandleEndAction; +constexpr auto ReplacedIn = [](auto&&... args) { return SiLoader::ReplacedIn(std::forward(args)...); }; #else constexpr decltype(&SiLoader::Load) Load = nullptr; constexpr decltype(&SiLoader::HandleFind) HandleFind = nullptr; @@ -60,5 +81,9 @@ constexpr decltype(&SiLoader::HandleStart) HandleStart = nullptr; constexpr decltype(&SiLoader::HandleRemove) HandleRemove = nullptr; constexpr decltype(&SiLoader::HandleDelete) HandleDelete = nullptr; constexpr decltype(&SiLoader::HandleEndAction) HandleEndAction = nullptr; +constexpr auto ReplacedIn = [](auto&&... args) { + ((void) args, ...); + return false; +}; #endif }; // namespace Extensions