Make P_PlayLivesJingle player optional in Lua

This commit is contained in:
fickleheart 2020-02-23 15:40:59 -06:00
parent c23e8d2cbd
commit d55ef8db71
2 changed files with 9 additions and 5 deletions

View file

@ -1674,11 +1674,15 @@ static int lib_pPlayVictorySound(lua_State *L)
static int lib_pPlayLivesJingle(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 //NOHUD
//INLEVEL //INLEVEL
if (!player) if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
return LUA_ErrInvalid(L, "player_t"); {
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
P_PlayLivesJingle(player); P_PlayLivesJingle(player);
return 0; return 0;
} }

View file

@ -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) 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, always play the jingle (1-up intermission)
if (gamestate == GS_LEVEL && !P_IsLocalPlayer(player)) if (gamestate == GS_LEVEL && player && !P_IsLocalPlayer(player))
return; return;
S_RetainMusic(musname, musflags, looping, 0, status); S_RetainMusic(musname, musflags, looping, 0, status);