From d93ca34859939e9906ec3e1e6b5061b32e92d9ef Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Wed, 15 Aug 2018 03:37:11 -0400
Subject: [PATCH] Hide MusicPlus lua behind an #ifdef HAVE_LUA_MUSICPLUS

# Conflicts:
#	src/lua_hook.h
#	src/lua_hooklib.c
#	src/p_user.c
---
 src/lua_baselib.c | 5 ++++-
 src/lua_hook.h    | 2 ++
 src/lua_hooklib.c | 5 +++++
 src/lua_script.h  | 3 +++
 src/s_sound.c     | 2 +-
 5 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/lua_baselib.c b/src/lua_baselib.c
index f62ba12aa..d6aeb9a31 100644
--- a/src/lua_baselib.c
+++ b/src/lua_baselib.c
@@ -2265,6 +2265,7 @@ static int lib_sSpeedMusic(lua_State *L)
 	return 1;
 }
 
+#ifdef HAVE_LUA_MUSICPLUS
 static int lib_sSetMusicPosition(lua_State *L)
 {
 	UINT32 position = 0;
@@ -2470,7 +2471,7 @@ static int lib_sMusicExists(lua_State *L)
 	lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi));
 	return 1;
 }
-
+#endif
 static int lib_sOriginPlaying(lua_State *L)
 {
 	void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@@ -2848,6 +2849,7 @@ static luaL_Reg lib[] = {
 	{"S_StopSound",lib_sStopSound},
 	{"S_ChangeMusic",lib_sChangeMusic},
 	{"S_SpeedMusic",lib_sSpeedMusic},
+#ifdef HAVE_LUA_MUSICPLUS
 	{"S_SetMusicPosition",lib_sSetMusicPosition},
 	{"S_GetMusicPosition",lib_sGetMusicPosition},
 	{"S_PauseMusic",lib_sPauseMusic},
@@ -2859,6 +2861,7 @@ static luaL_Reg lib[] = {
 	{"S_MusicPaused",lib_sMusicPaused},
 	{"S_MusicName",lib_sMusicName},
 	{"S_MusicExists",lib_sMusicExists},
+#endif
 	{"S_OriginPlaying",lib_sOriginPlaying},
 	{"S_IdPlaying",lib_sIdPlaying},
 	{"S_SoundPlaying",lib_sSoundPlaying},
diff --git a/src/lua_hook.h b/src/lua_hook.h
index 6df58bbc6..8249bacfc 100644
--- a/src/lua_hook.h
+++ b/src/lua_hook.h
@@ -88,6 +88,8 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8
 #define LUAh_MobjMoveBlocked(mo) LUAh_MobjHook(mo, hook_MobjMoveBlocked) // Hook for P_XYMovement (when movement is blocked)
 boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnMapThing by mobj type
 boolean LUAh_FollowMobj(player_t *player, mobj_t *mo); // Hook for P_PlayerAfterThink Smiles mobj-following
+#ifdef HAVE_LUA_MUSICPLUS
 boolean LUAh_MusicChange(const char *oldname, const char *newname, char *newmusic, UINT16 *mflags, boolean *looping); // Hook for music changes
+#endif
 
 #endif
diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c
index e67ba9040..aeecf8071 100644
--- a/src/lua_hooklib.c
+++ b/src/lua_hooklib.c
@@ -1192,6 +1192,9 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj)
 	lua_settop(gL, 0);
 	return hooked;
 }
+
+#ifdef HAVE_LUA_MUSICPLUS
+
 // Hook for music changes
 boolean LUAh_MusicChange(const char *oldname, const char *newname, char *newmusic, UINT16 *mflags, boolean *looping)
 {
@@ -1241,3 +1244,5 @@ boolean LUAh_MusicChange(const char *oldname, const char *newname, char *newmusi
 }
 
 #endif
+
+#endif
diff --git a/src/lua_script.h b/src/lua_script.h
index 51f1eaeaa..ce95ae6f0 100644
--- a/src/lua_script.h
+++ b/src/lua_script.h
@@ -97,4 +97,7 @@ void COM_Lua_f(void);
 // uncomment if you want seg_t/node_t in Lua
 // #define HAVE_LUA_SEGS
 
+// uncomment for extended music features
+// #define HAVE_LUA_MUSICPLUS
+
 #endif
diff --git a/src/s_sound.c b/src/s_sound.c
index 3dab5261a..bd27e4da2 100644
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -1385,7 +1385,7 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
 		return;
 
 	char newmusic[7];
-#ifdef HAVE_BLUA
+#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS)
 	if(LUAh_MusicChange(music_name, mmusic, newmusic, &mflags, &looping))
 		return;
 #else
-- 
GitLab