From 394c26a49e8c8cc6c33143d727358780a849bc7c Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Thu, 25 Dec 2025 21:41:38 +0100 Subject: [PATCH] this --- plugin.lua | 1 + src/lua_rds.c | 24 ++++++++++++++++-------- src/lua_rds.h | 2 +- src/rds.c | 5 +++-- src/rds_groups.c | 4 ++-- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/plugin.lua b/plugin.lua index d08b2c4..18888de 100644 --- a/plugin.lua +++ b/plugin.lua @@ -49,6 +49,7 @@ function data_handle(data) end ---@param b integer ---@param c integer ---@param d integer +---@return boolean generated ---@return integer b ---@return integer c ---@return integer d diff --git a/src/lua_rds.c b/src/lua_rds.c index 13aa05b..4111ba5 100644 --- a/src/lua_rds.c +++ b/src/lua_rds.c @@ -643,17 +643,17 @@ void run_lua(char *str, char *cmd_output) { pthread_mutex_unlock(&lua_mutex); } -int lua_group(RDSGroup* group) { +int lua_group(RDSGroup* group, const char grp) { pthread_mutex_lock(&lua_mutex); lua_getglobal(L, "group"); if (lua_isfunction(L, -1)) { - lua_pushstring(L, "L"); + lua_pushstring(L, &grp); lua_pushinteger(L, group->b); lua_pushinteger(L, group->c); lua_pushinteger(L, group->d); - if (lua_pcall(L, 4, 3, 0) == LUA_OK) { - if (!lua_isinteger(L, -1)) { + if (lua_pcall(L, 4, 4, 0) == LUA_OK) { + if (!lua_isboolean(L, -1)) { pthread_mutex_unlock(&lua_mutex); return 0; } @@ -665,10 +665,18 @@ int lua_group(RDSGroup* group) { pthread_mutex_unlock(&lua_mutex); return 0; } - group->d = luaL_checkinteger(L, -1); - group->c = luaL_checkinteger(L, -2); - group->b = luaL_checkinteger(L, -3); - lua_pop(L, 2); + if (!lua_isinteger(L, -4)) { + pthread_mutex_unlock(&lua_mutex); + return 0; + } + if(lua_toboolean(L, -1) == 0) { + pthread_mutex_unlock(&lua_mutex); + return 0; + } + group->d = luaL_checkinteger(L, -2); + group->c = luaL_checkinteger(L, -3); + group->b = luaL_checkinteger(L, -4); + lua_pop(L, 3); } else fprintf(stderr, "Lua error: %s at 'group'\n", lua_tostring(L, -1)); lua_pop(L, 1); } else lua_pop(L, 1); diff --git a/src/lua_rds.h b/src/lua_rds.h index 48a08be..5fc8c23 100644 --- a/src/lua_rds.h +++ b/src/lua_rds.h @@ -8,7 +8,7 @@ void init_lua(RDSModulator* rds_mod); void run_lua(char *str, char *cmd_output); -int lua_group(RDSGroup* group); +int lua_group(RDSGroup* group, const char grp); void lua_call_function(const char* function); void lua_group_ref(RDSGroup* group, int ref); void destroy_lua(); \ No newline at end of file diff --git a/src/rds.c b/src/rds.c index e0e18ba..b1e9bbb 100644 --- a/src/rds.c +++ b/src/rds.c @@ -26,7 +26,7 @@ void get_rds_ertplus_group(RDSEncoder* enc, RDSGroup *group); void get_rds_eon_group(RDSEncoder* enc, RDSGroup *group); uint8_t get_rds_custom_groups(RDSEncoder* enc, RDSGroup *group); uint8_t get_rds_custom_groups2(RDSEncoder* enc, RDSGroup *group); -int get_rdsp_lua_group(RDSGroup *group); +int get_rdsp_lua_group(RDSGroup *group, const char grp); void get_rds_user_oda_group(RDSEncoder* enc, RDSGroup *group); int get_rds_user_oda_group_content(RDSEncoder* enc, RDSGroup *group); @@ -105,11 +105,12 @@ static void get_rds_sequence_group(RDSEncoder* enc, RDSGroup *group, char* grp, get_rds_fasttuning_group(enc, group); break; case 'L': - if(get_rdsp_lua_group(group) == 0) get_rds_ps_group(enc, group); + if(get_rdsp_lua_group(group, *grp) == 0) get_rds_ps_group(enc, group); break; case 'O': get_rds_user_oda_group(enc, group); break; + case 'S': case 'K': if(get_rds_user_oda_group_content(enc, group) == 0) get_rds_ps_group(enc, group); break; diff --git a/src/rds_groups.c b/src/rds_groups.c index c79fd1e..de386f2 100644 --- a/src/rds_groups.c +++ b/src/rds_groups.c @@ -343,8 +343,8 @@ uint8_t get_rds_custom_groups2(RDSEncoder* enc, RDSGroup *group) { } return 0; } -int get_rdsp_lua_group(RDSGroup *group) { - int generated = lua_group(group); +int get_rdsp_lua_group(RDSGroup *group, const char grp) { + int generated = lua_group(group, grp); if(generated) group->is_type_b = (IS_TYPE_B(group->b) != 0); return generated; }