Add SiLoader adjustments

This commit is contained in:
Christian Semmler 2025-08-20 16:34:14 -07:00
parent 9967aca509
commit c0a85c42a3
2 changed files with 30 additions and 1 deletions

View File

@ -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<SiLoader>::Call(ReplacedIn, *action, m_atomId, *g_introScript).value_or(false))) {
return result;
}

View File

@ -27,6 +27,9 @@ class SiLoader {
static std::optional<MxBool> HandleDelete(MxDSAction& p_action);
static MxBool HandleEndAction(MxEndActionNotificationParam& p_param);
template <typename... Args>
static bool ReplacedIn(MxDSAction& p_action, Args... p_args);
static std::map<std::string, std::string> options;
static std::vector<std::string> files;
static std::vector<std::string> directives;
@ -47,12 +50,30 @@ class SiLoader {
};
#ifdef EXTENSIONS
template <typename... Args>
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<decltype(args)>(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