1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00
This commit is contained in:
Bertrand Songis 2019-09-10 14:59:33 +02:00
parent d983138f77
commit 6684a75d92
No known key found for this signature in database
GPG key ID: F189F79290FEC50F

View file

@ -636,18 +636,22 @@ bool luaLoadMixScript(uint8_t index)
bool luaLoadFunctionScript(uint8_t index, uint8_t ref)
{
if (ref >= SCRIPT_GFUNC_FIRST && g_model.noGlobalFunctions)
return false;
CustomFunctionData * fn;
CustomFunctionData & fn = (ref < SCRIPT_GFUNC_FIRST ? g_model.customFn[index] : g_eeGeneral.customFn[index]);
if (ref < SCRIPT_GFUNC_FIRST)
fn = &g_model.customFn[index];
else if (!g_model.noGlobalFunctions)
fn = &g_eeGeneral.customFn[index];
else
return true;
if (fn.func == FUNC_PLAY_SCRIPT && ZEXIST(fn.play.name)) {
if (fn->func == FUNC_PLAY_SCRIPT && ZEXIST(fn->play.name)) {
if (luaScriptsCount < MAX_SCRIPTS) {
ScriptInternalData & sid = scriptInternalData[luaScriptsCount++];
sid.reference = ref + index;
sid.state = SCRIPT_NOFILE;
char filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME + sizeof(SCRIPT_EXT)] = SCRIPTS_FUNCS_PATH "/";
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn.play.name, LEN_FUNCTION_NAME);
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn->play.name, LEN_FUNCTION_NAME);
filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME] = '\0';
strcat(filename + sizeof(SCRIPTS_FUNCS_PATH), SCRIPT_EXT);
if (luaLoad(lsScripts, filename, sid) == SCRIPT_PANIC) {