From 967fca8daac23b4a9859a3bb1a371a8f88f504c0 Mon Sep 17 00:00:00 2001 From: Inori Date: Fri, 6 Sep 2019 05:29:50 -0400 Subject: [PATCH] Execute/skip scripts based on a platform marker --- binding/binding-mri.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/binding/binding-mri.cpp b/binding/binding-mri.cpp index f3662bb5..b61c506c 100644 --- a/binding/binding-mri.cpp +++ b/binding/binding-mri.cpp @@ -479,6 +479,7 @@ static void runRMXPScripts(BacktraceData &btData) { const Config &conf = shState->rtData().config; const std::string &scriptPack = conf.game.scripts; + const char *platform = SDL_GetPlatform(); if (scriptPack.empty()) { @@ -599,7 +600,23 @@ static void runRMXPScripts(BacktraceData &btData) fname = newStringUTF8(buf, len); btData.scriptNames.insert(buf, scriptName); - + + // if the script name starts with |s|, only execute + // it if "s" is the same first letter as the platform + // we're running on + + // |W| - Windows, |M| - Mac OS X, |L| - Linux + + if (strlen(scriptName) > 2 && + scriptName[0] == '|' && scriptName[2] == scriptName[0]) + { + if (scriptName[1] != platform[0]) + { + Debug() << RSTRING_PTR(fname) << ": Skipped due to platform check mismatch"; + continue; + } + } + int state; evalString(string, fname, &state);