From f0d663ea90f95c2735962922b15c60c0e3e7cfb2 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 11 Jan 2020 15:38:50 +0100 Subject: [PATCH] Adapt setup of linedef type 443 (Call Lua function) to UDMF --- src/lua_hooklib.c | 2 +- src/p_setup.c | 9 +++++++++ src/p_spec.c | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 56a4fa3f7..08a67ea04 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1132,7 +1132,7 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next) { - if (strcmp(hookp->s.funcname, line->text)) + if (strcmp(hookp->s.funcname, line->stringargs[0])) continue; if (lua_gettop(gL) == 0) diff --git a/src/p_setup.c b/src/p_setup.c index 0454f6892..747a0d5e0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2665,6 +2665,15 @@ static void P_ConvertBinaryMap(void) { switch (lines[i].special) { + case 443: //Call Lua function + if (lines[i].text) + { + lines[i].stringargs[0] = Z_Malloc(strlen(lines[i].text) + 1, PU_LEVEL, NULL); + M_Memcpy(lines[i].stringargs[0], lines[i].text, strlen(lines[i].text) + 1); + } + else + CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(i)); + break; case 700: //Slope front sector floor case 701: //Slope front sector ceiling case 702: //Slope front sector floor and ceiling diff --git a/src/p_spec.c b/src/p_spec.c index 00a71602b..1c2b43f66 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3367,10 +3367,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 443: // Calls a named Lua function #ifdef HAVE_BLUA - if (line->text) + if (line->stringargs[0]) LUAh_LinedefExecute(line, mo, callsec); else - CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines)); + CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in arg0str)\n", sizeu1(line-lines)); #else CONS_Alert(CONS_ERROR, "The map is trying to run a Lua script, but this exe was not compiled with Lua support!\n"); #endif