From 283bb52e7d381a85bd8026a9fabf8e7daf150bdf Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 23 Feb 2020 12:45:43 -0600 Subject: [PATCH 01/10] Disable NOHUD/INLEVEL checks on Lua sound functions None of these are implicitly sync-safe anyway, and most have no need to be walled off from HUD code or intermission thinkers. --- src/lua_baselib.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 03f142446..e41f81674 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1675,8 +1675,8 @@ static int lib_pPlayVictorySound(lua_State *L) static int lib_pPlayLivesJingle(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL + //NOHUD + //INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_PlayLivesJingle(player); @@ -2342,7 +2342,7 @@ static int lib_sStartSound(lua_State *L) const void *origin = NULL; sfxenum_t sound_id = luaL_checkinteger(L, 2); player_t *player = NULL; - //NOHUD // kys @whoever did this. + //NOHUD if (sound_id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1); if (!lua_isnil(L, 1)) @@ -2373,7 +2373,7 @@ static int lib_sStartSoundAtVolume(lua_State *L) sfxenum_t sound_id = luaL_checkinteger(L, 2); INT32 volume = (INT32)luaL_checkinteger(L, 3); player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnil(L, 1)) { @@ -2397,7 +2397,7 @@ static int lib_sStartSoundAtVolume(lua_State *L) static int lib_sStopSound(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - NOHUD + //NOHUD if (!origin) return LUA_ErrInvalid(L, "mobj_t"); S_StopSound(origin); @@ -2414,7 +2414,7 @@ static int lib_sChangeMusic(lua_State *L) boolean looping; player_t *player = NULL; UINT16 music_flags = 0; - NOHUD + //NOHUD if (lua_isnumber(L, 1)) { @@ -2443,7 +2443,7 @@ static int lib_sChangeMusic(lua_State *L) boolean looping = (boolean)lua_opttrueboolean(L, 2); player_t *player = NULL; UINT16 music_flags = 0; - NOHUD + //NOHUD #endif if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) @@ -2474,7 +2474,7 @@ static int lib_sSpeedMusic(lua_State *L) fixed_t fixedspeed = luaL_checkfixed(L, 1); float speed = FIXED_TO_FLOAT(fixedspeed); player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) { player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); @@ -2489,7 +2489,7 @@ static int lib_sSpeedMusic(lua_State *L) static int lib_sStopMusic(lua_State *L) { player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) { player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -2505,7 +2505,7 @@ static int lib_sSetInternalMusicVolume(lua_State *L) { UINT32 volume = (UINT32)luaL_checkinteger(L, 1); player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) { player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); @@ -2525,7 +2525,7 @@ static int lib_sSetInternalMusicVolume(lua_State *L) static int lib_sStopFadingMusic(lua_State *L) { player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) { player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -2548,7 +2548,7 @@ static int lib_sFadeMusic(lua_State *L) UINT32 ms; INT32 source_volume; player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) { player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); @@ -2576,8 +2576,6 @@ static int lib_sFadeMusic(lua_State *L) ms = (UINT32)luaL_checkinteger(L, 3); } - NOHUD - if (!player || P_IsLocalPlayer(player)) lua_pushboolean(L, S_FadeMusicFromVolume(target_volume, source_volume, ms)); else @@ -2589,7 +2587,7 @@ static int lib_sFadeOutStopMusic(lua_State *L) { UINT32 ms = (UINT32)luaL_checkinteger(L, 1); player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) { player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); @@ -2608,7 +2606,7 @@ static int lib_sFadeOutStopMusic(lua_State *L) static int lib_sOriginPlaying(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - NOHUD + //NOHUD INLEVEL if (!origin) return LUA_ErrInvalid(L, "mobj_t"); @@ -2619,7 +2617,7 @@ static int lib_sOriginPlaying(lua_State *L) static int lib_sIdPlaying(lua_State *L) { sfxenum_t id = luaL_checkinteger(L, 1); - NOHUD + //NOHUD if (id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1); lua_pushboolean(L, S_IdPlaying(id)); @@ -2630,7 +2628,7 @@ static int lib_sSoundPlaying(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); sfxenum_t id = luaL_checkinteger(L, 2); - NOHUD + //NOHUD INLEVEL if (!origin) return LUA_ErrInvalid(L, "mobj_t"); @@ -2648,7 +2646,7 @@ static int lib_sStartMusicCaption(lua_State *L) const char *caption = luaL_checkstring(L, 1); UINT16 lifespan = (UINT16)luaL_checkinteger(L, 2); //HUDSAFE - INLEVEL + //INLEVEL if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) { From 40488096c014153680d00a11d2707381930c9b2d Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 23 Feb 2020 15:40:59 -0600 Subject: [PATCH 02/10] Make P_PlayLivesJingle player optional in Lua --- src/lua_baselib.c | 10 +++++++--- src/p_user.c | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e41f81674..8344fca91 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1674,11 +1674,15 @@ static int lib_pPlayVictorySound(lua_State *L) static int lib_pPlayLivesJingle(lua_State *L) { - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + player_t *player = NULL; //NOHUD //INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } P_PlayLivesJingle(player); return 0; } diff --git a/src/p_user.c b/src/p_user.c index 880d932af..2dcfd872c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -392,7 +392,7 @@ void P_GiveFinishFlags(player_t *player) mobj_t* flag = P_SpawnMobjFromMobj(player->mo, xoffs, yoffs, 0, MT_FINISHFLAG); flag->angle = angle; angle += FixedAngle(120*FRACUNIT); - + P_SetTarget(&flag->target, player->mo); } } @@ -1533,7 +1533,7 @@ void P_PlayJingle(player_t *player, jingletype_t jingletype) void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status) { // If gamestate != GS_LEVEL, always play the jingle (1-up intermission) - if (gamestate == GS_LEVEL && !P_IsLocalPlayer(player)) + if (gamestate == GS_LEVEL && player && !P_IsLocalPlayer(player)) return; S_RetainMusic(musname, musflags, looping, 0, status); From c5f386881988c51b6e7f752516ac55cc1706a815 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 23 Feb 2020 17:19:18 -0600 Subject: [PATCH 03/10] Expose P_PlayJingle/Music() to Lua --- src/lua_baselib.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8344fca91..c360007de 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1040,11 +1040,60 @@ static int lib_pSetObjectMomZ(lua_State *L) return 0; } +static int lib_pPlayJingle(lua_State *L) +{ + player_t *player = NULL; + jingletype_t jingletype = (jingletype_t)luaL_checkinteger(L, 2); + //NOHUD + //INLEVEL + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (jingletype >= NUMJINGLES) + return luaL_error(L, "jingletype %d out of range (0 - %d)", jingletype, NUMJINGLES-1); + P_PlayJingle(player, jingletype); + return 0; +} + +static int lib_pPlayJingleMusic(lua_State *L) +{ + player_t *player = NULL; + const char *musnamearg = luaL_checkstring(L, 2); + char musname[7], *p = musname; + UINT16 musflags = luaL_optinteger(L, 3, 0); + boolean looping = lua_opttrueboolean(L, 4); + jingletype_t jingletype = (jingletype_t)luaL_optinteger(L, 5, JT_OTHER); + //NOHUD + //INLEVEL + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (jingletype >= NUMJINGLES) + return luaL_error(L, "jingletype %d out of range (0 - %d)", jingletype, NUMJINGLES-1); + + musname[6] = '\0'; + strncpy(musname, musnamearg, 6); + + while (*p) { + *p = tolower(*p); + ++p; + } + + P_PlayJingleMusic(player, musname, musflags, looping, jingletype); + return 0; +} + static int lib_pRestoreMusic(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL + //NOHUD + //INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); if (P_IsLocalPlayer(player)) @@ -3071,6 +3120,8 @@ static luaL_Reg lib[] = { {"P_InSpaceSector",lib_pInSpaceSector}, {"P_InQuicksand",lib_pInQuicksand}, {"P_SetObjectMomZ",lib_pSetObjectMomZ}, + {"P_PlayJingle",lib_pPlayJingle}, + {"P_PlayJingleMusic",lib_pPlayJingleMusic}, {"P_RestoreMusic",lib_pRestoreMusic}, {"P_SpawnShieldOrb",lib_pSpawnShieldOrb}, {"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, From f2c968dea84ee76db8e8e38327427675c07fd8e9 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 23 Feb 2020 17:20:44 -0600 Subject: [PATCH 04/10] Add JingleStatus hook for carrying custom jingle tunes The extra argument is the music name, as passed into P_PlayJingleMusic(player, musname), to run the hook for, optional. Arguments are (player, musname) - the latter to allow global hooks that still differentiate between different tracks. --- src/lua_hook.h | 2 ++ src/lua_hooklib.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++- src/p_local.h | 2 +- src/p_user.c | 7 +++++-- src/s_sound.c | 2 +- 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 265700e4f..ea11d0236 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -58,6 +58,7 @@ enum hook { hook_ViewpointSwitch, hook_SeenPlayer, hook_PlayerThink, + hook_JingleStatus, hook_MAX // last hook }; @@ -110,5 +111,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK #endif #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink +boolean LUAh_JingleStatus(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index efed9adb7..c56336fca 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -69,6 +69,7 @@ const char *const hookNames[hook_MAX+1] = { "ViewpointSwitch", "SeenPlayer", "PlayerThink", + "JingleStatus", NULL }; @@ -80,7 +81,7 @@ struct hook_s UINT16 id; union { mobjtype_t mt; - char *skinname; + char *skinname; // also used as musname for JingleStatus... I'm lazy char *funcname; } s; boolean error; @@ -148,6 +149,7 @@ static int lib_addHook(lua_State *L) luaL_argcheck(L, hook.s.mt < NUMMOBJTYPES, 2, "invalid mobjtype_t"); break; case hook_BotAI: + case hook_JingleStatus: hook.s.skinname = NULL; if (lua_isstring(L, 2)) { // lowercase copy @@ -1632,4 +1634,49 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) } #endif // SEENAMES +boolean LUAh_JingleStatus(player_t *player, const char *musname) +{ + hook_p hookp; + boolean keepplaying = false; + if (!gL || !(hooksAvailable[hook_JingleStatus/8] & (1<<(hook_JingleStatus%8)))) + return true; + + lua_settop(gL, 0); + hud_running = true; // local hook + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type == hook_JingleStatus) CONS_Printf("jingle status hook for %s vs %s\n", hookp->s.skinname, musname); + + if (hookp->type != hook_JingleStatus + || (hookp->s.skinname && strcmp(hookp->s.skinname, musname))) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + lua_pushstring(gL, musname); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1) && lua_toboolean(gL, -1)) + keepplaying = true; // Keep playing this boolean + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + hud_running = false; + + return keepplaying; +} + #endif diff --git a/src/p_local.h b/src/p_local.h index 5e27379a7..99c465f9b 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -250,7 +250,7 @@ extern jingle_t jingleinfo[NUMJINGLES]; #define JINGLEPOSTFADE 1000 void P_PlayJingle(player_t *player, jingletype_t jingletype); -boolean P_EvaluateMusicStatus(UINT16 status); +boolean P_EvaluateMusicStatus(UINT16 status, const char *musname); void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status); // diff --git a/src/p_user.c b/src/p_user.c index 2dcfd872c..ab85897a5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1541,7 +1541,7 @@ void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, b S_ChangeMusicInternal(musname, looping); } -boolean P_EvaluateMusicStatus(UINT16 status) +boolean P_EvaluateMusicStatus(UINT16 status, const char *musname) { // \todo lua hook int i; @@ -1598,8 +1598,11 @@ boolean P_EvaluateMusicStatus(UINT16 status) result = (players[i].nightstime && players[i].nightstime <= 10*TICRATE); break; - case JT_NONE: // Null state case JT_OTHER: // Other state + result = LUAh_JingleStatus(&players[i], musname); + break; + + case JT_NONE: // Null state case JT_MASTER: // Main level music default: result = true; diff --git a/src/s_sound.c b/src/s_sound.c index 8193fdb9b..6507ffc02 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2045,7 +2045,7 @@ static musicstack_t *S_GetMusicStackEntry(UINT16 status, boolean fromfirst, INT1 if (!status || mst->status == status) { - if (P_EvaluateMusicStatus(mst->status)) + if (P_EvaluateMusicStatus(mst->status, mst->musname)) { if (!S_MusicExists(mst->musname, !midi_disabled, !digital_disabled)) // paranoia S_RemoveMusicStackEntry(mst); // then continue From 352029fd76805029e9f8bea5d92fc307cc5e6d68 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 23 Feb 2020 17:58:32 -0600 Subject: [PATCH 05/10] Add music position functions to Lua --- src/lua_baselib.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c360007de..b6fa1b7aa 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2656,6 +2656,25 @@ static int lib_sFadeOutStopMusic(lua_State *L) return 1; } +static int lib_sGetMusicLength(lua_State *L) +{ + lua_pushinteger(L, S_GetMusicLength()); + return 1; +} + +static int lib_sGetMusicPosition(lua_State *L) +{ + lua_pushinteger(L, S_GetMusicPosition()); + return 1; +} + +static int lib_sSetMusicPosition(lua_State *L) +{ + UINT32 pos = (UINT32)luaL_checkinteger(L, 1); + lua_pushboolean(L, S_SetMusicPosition(pos)); + return 1; +} + static int lib_sOriginPlaying(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -3242,6 +3261,9 @@ static luaL_Reg lib[] = { {"S_StopFadingMusic",lib_sStopFadingMusic}, {"S_FadeMusic",lib_sFadeMusic}, {"S_FadeOutStopMusic",lib_sFadeOutStopMusic}, + {"S_GetMusicLength",lib_sGetMusicLength}, + {"S_GetMusicPosition",lib_sGetMusicPosition}, + {"S_SetMusicPosition",lib_sSetMusicPosition}, {"S_OriginPlaying",lib_sOriginPlaying}, {"S_IdPlaying",lib_sIdPlaying}, {"S_SoundPlaying",lib_sSoundPlaying}, From e0badd1e5b7dfb89d19a04be82a9543ceb60820e Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 18 Mar 2020 22:35:21 -0500 Subject: [PATCH 06/10] Rename hook to ShouldJingleContinue --- src/lua_hook.h | 4 ++-- src/lua_hooklib.c | 14 +++++++------- src/p_user.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index ea11d0236..dde8d4c41 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -58,7 +58,7 @@ enum hook { hook_ViewpointSwitch, hook_SeenPlayer, hook_PlayerThink, - hook_JingleStatus, + hook_ShouldJingleContinue, hook_MAX // last hook }; @@ -111,6 +111,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK #endif #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink -boolean LUAh_JingleStatus(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing +boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index c56336fca..3a4d67492 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -69,7 +69,7 @@ const char *const hookNames[hook_MAX+1] = { "ViewpointSwitch", "SeenPlayer", "PlayerThink", - "JingleStatus", + "ShouldJingleContinue", NULL }; @@ -81,7 +81,7 @@ struct hook_s UINT16 id; union { mobjtype_t mt; - char *skinname; // also used as musname for JingleStatus... I'm lazy + char *skinname; // also used as musname for ShouldJingleContinue... I'm lazy char *funcname; } s; boolean error; @@ -149,7 +149,7 @@ static int lib_addHook(lua_State *L) luaL_argcheck(L, hook.s.mt < NUMMOBJTYPES, 2, "invalid mobjtype_t"); break; case hook_BotAI: - case hook_JingleStatus: + case hook_ShouldJingleContinue: hook.s.skinname = NULL; if (lua_isstring(L, 2)) { // lowercase copy @@ -1634,11 +1634,11 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) } #endif // SEENAMES -boolean LUAh_JingleStatus(player_t *player, const char *musname) +boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) { hook_p hookp; boolean keepplaying = false; - if (!gL || !(hooksAvailable[hook_JingleStatus/8] & (1<<(hook_JingleStatus%8)))) + if (!gL || !(hooksAvailable[hook_ShouldJingleContinue/8] & (1<<(hook_ShouldJingleContinue%8)))) return true; lua_settop(gL, 0); @@ -1646,9 +1646,9 @@ boolean LUAh_JingleStatus(player_t *player, const char *musname) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_JingleStatus) CONS_Printf("jingle status hook for %s vs %s\n", hookp->s.skinname, musname); + if (hookp->type == hook_ShouldJingleContinue) CONS_Printf("jingle status hook for %s vs %s\n", hookp->s.skinname, musname); - if (hookp->type != hook_JingleStatus + if (hookp->type != hook_ShouldJingleContinue || (hookp->s.skinname && strcmp(hookp->s.skinname, musname))) continue; diff --git a/src/p_user.c b/src/p_user.c index ab85897a5..b7b95f9f0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1599,7 +1599,7 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname) break; case JT_OTHER: // Other state - result = LUAh_JingleStatus(&players[i], musname); + result = LUAh_ShouldJingleContinue(&players[i], musname); break; case JT_NONE: // Null state From dd0d86120b09c2a2f7d2a06c34f9abbf82d5111c Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 18 Mar 2020 22:38:18 -0500 Subject: [PATCH 07/10] > building SRB2 without Lua in 2020 --- src/p_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index b7b95f9f0..3694a1a3b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1599,8 +1599,10 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname) break; case JT_OTHER: // Other state +#ifdef HAVE_BLUA result = LUAh_ShouldJingleContinue(&players[i], musname); break; +#endif case JT_NONE: // Null state case JT_MASTER: // Main level music From 647f73c8f26d66370de86723b80428efbfb1f7f3 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 18 Mar 2020 22:38:51 -0500 Subject: [PATCH 08/10] Clean up after myself --- src/lua_hooklib.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 3a4d67492..4f873dd99 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1646,8 +1646,6 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_ShouldJingleContinue) CONS_Printf("jingle status hook for %s vs %s\n", hookp->s.skinname, musname); - if (hookp->type != hook_ShouldJingleContinue || (hookp->s.skinname && strcmp(hookp->s.skinname, musname))) continue; From 520e3c5dc32e1970c339be3b2fc9eee80ab168bb Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 18 Mar 2020 22:40:11 -0500 Subject: [PATCH 09/10] Are these casts unnecessary...?? --- src/lua_baselib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index b6fa1b7aa..4694b56ba 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1043,7 +1043,7 @@ static int lib_pSetObjectMomZ(lua_State *L) static int lib_pPlayJingle(lua_State *L) { player_t *player = NULL; - jingletype_t jingletype = (jingletype_t)luaL_checkinteger(L, 2); + jingletype_t jingletype = luaL_checkinteger(L, 2); //NOHUD //INLEVEL if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) @@ -1065,7 +1065,7 @@ static int lib_pPlayJingleMusic(lua_State *L) char musname[7], *p = musname; UINT16 musflags = luaL_optinteger(L, 3, 0); boolean looping = lua_opttrueboolean(L, 4); - jingletype_t jingletype = (jingletype_t)luaL_optinteger(L, 5, JT_OTHER); + jingletype_t jingletype = luaL_optinteger(L, 5, JT_OTHER); //NOHUD //INLEVEL if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) From 9c86cd0bc2e7895d9c46b79cb5e368e74dece2b0 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 18 Mar 2020 22:42:31 -0500 Subject: [PATCH 10/10] More union types for the union type god --- src/lua_hooklib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 4f873dd99..2843b0228 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -81,7 +81,8 @@ struct hook_s UINT16 id; union { mobjtype_t mt; - char *skinname; // also used as musname for ShouldJingleContinue... I'm lazy + char *skinname; + char *musname; char *funcname; } s; boolean error; @@ -1647,7 +1648,7 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_ShouldJingleContinue - || (hookp->s.skinname && strcmp(hookp->s.skinname, musname))) + || (hookp->s.musname && strcmp(hookp->s.musname, musname))) continue; if (lua_gettop(gL) == 0)