From 6bde90f887b66dc2f709dcfc7131bb9fa8dc16f6 Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Fri, 2 Mar 2018 14:14:59 -0500
Subject: [PATCH] Lua: Make S_SpeedMusic and S_ChangeMusic return nil for
 invalid players

---
 src/lua_baselib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/lua_baselib.c b/src/lua_baselib.c
index 7b25c424de..06c374c853 100644
--- a/src/lua_baselib.c
+++ b/src/lua_baselib.c
@@ -2232,7 +2232,12 @@ static int lib_sChangeMusic(lua_State *L)
 	music_flags = (UINT16)luaL_optinteger(L, 4, 0);
 
 	if (!player || P_IsLocalPlayer(player))
+	{
 		S_ChangeMusic(music_name, music_flags, looping);
+		lua_pushboolean(L, true);
+	}
+	else
+		lua_pushnil(L);
 	return 0;
 }
 
@@ -2251,7 +2256,7 @@ static int lib_sSpeedMusic(lua_State *L)
 	if (!player || P_IsLocalPlayer(player))
 		lua_pushboolean(L, S_SpeedMusic(speed));
 	else
-		lua_pushboolean(L, false);
+		lua_pushnil(L);
 	return 1;
 }
 
-- 
GitLab