This commit is contained in:
Christian Semmler 2025-08-19 18:09:15 -07:00
parent 0960b1a593
commit f16df112d7

View File

@ -9,6 +9,8 @@
using namespace Extensions; using namespace Extensions;
const char prependedMarker[] = ";;prepended;;";
std::map<std::string, std::string> SiLoader::options; std::map<std::string, std::string> SiLoader::options;
std::vector<std::string> SiLoader::files; std::vector<std::string> SiLoader::files;
std::vector<std::string> SiLoader::directives; std::vector<std::string> SiLoader::directives;
@ -98,16 +100,18 @@ std::optional<MxResult> SiLoader::HandleStart(MxDSAction& p_action)
} }
} }
for (const auto& key : prepend) { if (p_action.GetExtraLength() == 0 || !SDL_strstr(p_action.GetExtraData(), prependedMarker)) {
if (key.first == object) { for (const auto& key : prepend) {
MxDSAction action; if (key.first == object) {
MxResult result = start(key.second, p_action, action); MxDSAction action;
MxResult result = start(key.second, p_action, action);
if (result == SUCCESS) { if (result == SUCCESS) {
p_action.SetUnknown24(action.GetUnknown24()); p_action.SetUnknown24(action.GetUnknown24());
}
return result;
} }
return result;
} }
} }
@ -165,9 +169,9 @@ std::optional<MxBool> SiLoader::HandleDelete(MxDSAction& p_action)
MxBool SiLoader::HandleEndAction(MxEndActionNotificationParam& p_param) MxBool SiLoader::HandleEndAction(MxEndActionNotificationParam& p_param)
{ {
StreamObject object{p_param.GetAction()->GetAtomId(), p_param.GetAction()->GetObjectId()}; StreamObject object{p_param.GetAction()->GetAtomId(), p_param.GetAction()->GetObjectId()};
auto start = [](const StreamObject& p_object, MxDSAction& p_in, MxDSAction& p_out) { auto start = [](const StreamObject& p_object, MxDSAction& p_in, MxDSAction& p_out) -> MxResult {
if (!OpenStream(p_object.first.GetInternal())) { if (!OpenStream(p_object.first.GetInternal())) {
return; return FAILURE;
} }
p_out.SetAtomId(p_object.first); p_out.SetAtomId(p_object.first);
@ -175,13 +179,17 @@ MxBool SiLoader::HandleEndAction(MxEndActionNotificationParam& p_param)
p_out.SetUnknown24(-1); p_out.SetUnknown24(-1);
p_out.SetNotificationObject(p_in.GetNotificationObject()); p_out.SetNotificationObject(p_in.GetNotificationObject());
p_out.SetOrigin(p_in.GetOrigin()); p_out.SetOrigin(p_in.GetOrigin());
Start(&p_out); p_out.AppendExtra(sizeof(prependedMarker), prependedMarker);
return Start(&p_out);
}; };
for (const auto& key : prepend) { if (!p_param.GetSender() || !p_param.GetSender()->IsA("MxCompositePresenter")) {
if (key.second == object) { for (const auto& key : prepend) {
MxDSAction action; if (key.second == object) {
start(key.second, *p_param.GetAction(), action); assert(false);
MxDSAction action;
start(key.first, *p_param.GetAction(), action);
}
} }
} }
@ -218,7 +226,7 @@ bool SiLoader::LoadDirective(const char* p_directive)
char originAtom[256], targetAtom[256]; char originAtom[256], targetAtom[256];
uint32_t originId, targetId; uint32_t originId, targetId;
if (SDL_sscanf(p_directive, "StartWith:%255[^;];%d;%255[^;];%d", originAtom, &originId, targetAtom, &targetId) == if (SDL_sscanf(p_directive, "StartWith:%255[^:]:%d:%255[^:]:%d", originAtom, &originId, targetAtom, &targetId) ==
4) { 4) {
startWith.emplace_back( startWith.emplace_back(
StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId}, StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId},
@ -226,7 +234,7 @@ bool SiLoader::LoadDirective(const char* p_directive)
); );
} }
if (SDL_sscanf(p_directive, "RemoveWith:%255[^;];%d;%255[^;];%d", originAtom, &originId, targetAtom, &targetId) == if (SDL_sscanf(p_directive, "RemoveWith:%255[^:]:%d:%255[^:]:%d", originAtom, &originId, targetAtom, &targetId) ==
4) { 4) {
removeWith.emplace_back( removeWith.emplace_back(
StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId}, StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId},
@ -234,14 +242,14 @@ bool SiLoader::LoadDirective(const char* p_directive)
); );
} }
if (SDL_sscanf(p_directive, "Replace:%255[^;];%d;%255[^;];%d", originAtom, &originId, targetAtom, &targetId) == 4) { if (SDL_sscanf(p_directive, "Replace:%255[^:]:%d:%255[^:]:%d", originAtom, &originId, targetAtom, &targetId) == 4) {
replace.emplace_back( replace.emplace_back(
StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId}, StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId},
StreamObject{MxAtomId{targetAtom, e_lowerCase2}, targetId} StreamObject{MxAtomId{targetAtom, e_lowerCase2}, targetId}
); );
} }
if (SDL_sscanf(p_directive, "Prepend:%255[^;];%d;%255[^;];%d", originAtom, &originId, targetAtom, &targetId) == 4) { if (SDL_sscanf(p_directive, "Prepend:%255[^:]:%d:%255[^:]:%d", originAtom, &originId, targetAtom, &targetId) == 4) {
prepend.emplace_back( prepend.emplace_back(
StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId}, StreamObject{MxAtomId{originAtom, e_lowerCase2}, originId},
StreamObject{MxAtomId{targetAtom, e_lowerCase2}, targetId} StreamObject{MxAtomId{targetAtom, e_lowerCase2}, targetId}