MRI: rewrite script eval (was: Question about $0) #24
|
@ -295,11 +295,20 @@ static void runRMXPScripts()
|
||||||
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded),
|
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded),
|
||||||
RSTRING_LEN(scriptDecoded));
|
RSTRING_LEN(scriptDecoded));
|
||||||
|
|
||||||
char fname[32];
|
VALUE fname;
|
||||||
int len = snprintf(fname, sizeof(fname), "Section%03ld", i);
|
if (shState->rtData().config.useScriptNames)
|
||||||
|
{
|
||||||
|
fname = rb_ary_entry(script, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf[32];
|
||||||
|
int len = snprintf(buf, sizeof(buf), "Section%03ld", i);
|
||||||
|
fname = newStringUTF8(buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
int state;
|
int state;
|
||||||
evalString(string, newStringUTF8(fname, len), &state);
|
evalString(string, fname, &state);
|
||||||
if (state)
|
if (state)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,3 +113,9 @@
|
||||||
# RTP=/path/to/rtp1
|
# RTP=/path/to/rtp1
|
||||||
# RTP=/path/to/rtp2.zip
|
# RTP=/path/to/rtp2.zip
|
||||||
# RTP=/path/to/game.rgssad
|
# RTP=/path/to/game.rgssad
|
||||||
|
|
||||||
|
|
||||||
|
# Use the script's name as filename in warnings and error messages
|
||||||
|
# (default: disabled)
|
||||||
|
#
|
||||||
|
# useScriptNames=false
|
||||||
|
|
|
@ -49,7 +49,8 @@ Config::Config()
|
||||||
gameFolder("."),
|
gameFolder("."),
|
||||||
anyAltToggleFS(false),
|
anyAltToggleFS(false),
|
||||||
allowSymlinks(false),
|
allowSymlinks(false),
|
||||||
pathCache(true)
|
pathCache(true),
|
||||||
|
useScriptNames(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Config::read(int argc, char *argv[])
|
void Config::read(int argc, char *argv[])
|
||||||
|
@ -72,7 +73,8 @@ void Config::read(int argc, char *argv[])
|
||||||
PO_DESC(allowSymlinks, bool) \
|
PO_DESC(allowSymlinks, bool) \
|
||||||
PO_DESC(iconPath, std::string) \
|
PO_DESC(iconPath, std::string) \
|
||||||
PO_DESC(customScript, std::string) \
|
PO_DESC(customScript, std::string) \
|
||||||
PO_DESC(pathCache, bool)
|
PO_DESC(pathCache, bool) \
|
||||||
|
PO_DESC(useScriptNames, bool)
|
||||||
|
|
||||||
// Not gonna take your shit boost
|
// Not gonna take your shit boost
|
||||||
#define GUARD_ALL( exp ) try { exp } catch(...) {}
|
#define GUARD_ALL( exp ) try { exp } catch(...) {}
|
||||||
|
|
|
@ -51,6 +51,8 @@ struct Config
|
||||||
|
|
||||||
std::string iconPath;
|
std::string iconPath;
|
||||||
|
|
||||||
|
bool useScriptNames;
|
||||||
|
|
||||||
std::string customScript;
|
std::string customScript;
|
||||||
std::vector<std::string> rtps;
|
std::vector<std::string> rtps;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue