From 261bbd2b796cd327335a39544d33372929149b4d Mon Sep 17 00:00:00 2001 From: runsys Date: Tue, 5 Oct 2021 12:30:20 +0200 Subject: [PATCH] Fix Lua Mixer Scripts source naming (#842) * getSourceString() return a correct string for lcdcolor when the source es a LUA script * getSourceString() return a formated string with instanceName or scriptName and outputName Co-authored-by: Runsys16 --- radio/src/strhelpers.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/radio/src/strhelpers.cpp b/radio/src/strhelpers.cpp index 33541282bb7..75482e02436 100644 --- a/radio/src/strhelpers.cpp +++ b/radio/src/strhelpers.cpp @@ -442,8 +442,23 @@ char * getSourceString(char * dest, mixsrc_t idx) div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS); if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) { *dest++ = CHAR_LUA; - // *dest++ = '1'+qr.quot; - strcpy(dest, scriptInputsOutputs[qr.quot].outputs[qr.rem].name); + // temporary string + #define MAX_CHAR 16 + char temp[MAX_CHAR]; + strncpy( temp, g_model.scriptsData[qr.quot].name, MAX_CHAR ); + + // instance Name is empty : dest = n-ScriptFileName/OutputName + if ( temp[0]== 0) { + snprintf( temp, MAX_CHAR, "%d-%s/%s", qr.quot+1, + g_model.scriptsData[qr.quot].file, + scriptInputsOutputs[qr.quot].outputs[qr.rem].name ); + // instance Name is not empty : dest = InstanceName/OutputName + } else { + snprintf( temp, MAX_CHAR, "%s/%s", g_model.scriptsData[qr.quot].name, + scriptInputsOutputs[qr.quot].outputs[qr.rem].name ); + } + + strcpy( dest, temp); } #else strcpy(dest, "N/A");