MRI: add $RGSS_SCRIPTS

This commit is contained in:
cremno 2014-04-09 22:36:56 +02:00
parent 96d2707edb
commit cb8af6dd33
1 changed files with 17 additions and 3 deletions

View File

@ -210,6 +210,8 @@ static void runRMXPScripts()
return;
}
rb_gv_set("$RGSS_SCRIPTS", scriptArray);
long scriptCount = RARRAY_LEN(scriptArray);
std::string decodeBuffer;
@ -259,14 +261,25 @@ static void runRMXPScripts()
break;
}
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
}
for (long i = 0; i < scriptCount; ++i)
{
VALUE script = rb_ary_entry(scriptArray, i);
VALUE scriptDecoded = rb_ary_entry(script, 3);
/* Store encoding header + the decoded script
* in 'sc.decData' */
std::string decData = "#encoding:utf-8\n";
size_t hdSize = decData.size();
decData.resize(hdSize + bufferLen);
memcpy(&decData[hdSize], decodeBuffer.c_str(), bufferLen);
const char *scriptDecPtr;
long scriptDecLen;
RSTRING_GETMEM(scriptDecoded, scriptDecPtr, scriptDecLen);
decData.resize(hdSize + scriptDecLen);
memcpy(&decData[hdSize], scriptDecPtr, scriptDecLen);
ruby_script(RSTRING_PTR(scriptName));
ruby_script(RSTRING_PTR(rb_ary_entry(script, 1)));
rb_gc_start();
@ -279,6 +292,7 @@ static void runRMXPScripts()
}
}
static void mriBindingExecute()
{
ruby_setup();