From dabd7f99e60734eb2d18a50e3f8854ade9607f6e Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Sat, 1 Sep 2018 13:10:50 -0400
Subject: [PATCH] Add MUSICPOSTBOSSFADEIN

---
 src/dehacked.c   | 2 ++
 src/doomstat.h   | 3 ++-
 src/lua_maplib.c | 2 ++
 src/p_enemy.c    | 3 ++-
 src/p_setup.c    | 1 +
 5 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/dehacked.c b/src/dehacked.c
index 3f021847a..f95695e4f 100644
--- a/src/dehacked.c
+++ b/src/dehacked.c
@@ -1160,6 +1160,8 @@ static void readlevelheader(MYFILE *f, INT32 num)
 				mapheaderinfo[num-1]->muspostbosstrack = ((UINT16)i - 1);
 			else if (fastcmp(word, "MUSICPOSTBOSSPOS"))
 				mapheaderinfo[num-1]->muspostbosspos = (UINT32)get_number(word2);
+			else if (fastcmp(word, "MUSICPOSTBOSSFADEIN"))
+				mapheaderinfo[num-1]->muspostbossfadein = (UINT32)get_number(word2);
 			else if (fastcmp(word, "FORCECHARACTER"))
 			{
 				strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1);
diff --git a/src/doomstat.h b/src/doomstat.h
index f51baec23..5682dcff6 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -262,7 +262,8 @@ typedef struct
 	// Music stuff.
 	char muspostbossname[7];    ///< Post-bossdeath music.
 	UINT16 muspostbosstrack;    ///< Post-bossdeath track.
-	UINT32 muspostbosspos; ///< Post-bossdeath position
+	UINT32 muspostbosspos;      ///< Post-bossdeath position
+	UINT32 muspostbossfadein;   ///< Post-bossdeath fade-in milliseconds.
 
 	// Lua stuff.
 	// (This is not ifdeffed so the map header structure can stay identical, just in case.)
diff --git a/src/lua_maplib.c b/src/lua_maplib.c
index 77b6120ba..878ff03c9 100644
--- a/src/lua_maplib.c
+++ b/src/lua_maplib.c
@@ -1768,6 +1768,8 @@ static int mapheaderinfo_get(lua_State *L)
 		lua_pushinteger(L, header->muspostbosstrack);
 	else if (fastcmp(field,"muspostbosspos"))
 		lua_pushinteger(L, header->muspostbosspos);
+	else if (fastcmp(field,"muspostbossfadein"))
+		lua_pushinteger(L, header->muspostbossfadein);
 	else if (fastcmp(field,"forcecharacter"))
 		lua_pushstring(L, header->forcecharacter);
 	else if (fastcmp(field,"weather"))
diff --git a/src/p_enemy.c b/src/p_enemy.c
index 7670aa543..8964691cc 100644
--- a/src/p_enemy.c
+++ b/src/p_enemy.c
@@ -3544,7 +3544,8 @@ void A_BossDeath(mobj_t *mo)
 			// don't change if we're in another tune
 			// but in case we're in jingle, use our parked mapmus variables so the correct track restores
 			if (!changed)
-				S_ChangeMusicAdvanced(mapmusname, mapmusflags, true, mapmusposition, (1*MUSICRATE)+(MUSICRATE/2), 0);
+				S_ChangeMusicAdvanced(mapmusname, mapmusflags, true, mapmusposition, (1*MUSICRATE)+(MUSICRATE/2),
+					mapheaderinfo[gamemap-1]->muspostbossfadein);
 		}
 	}
 
diff --git a/src/p_setup.c b/src/p_setup.c
index 716d51d7b..e18dadaa8 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -212,6 +212,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
 	mapheaderinfo[num]->muspostbossname[6] = 0;
 	mapheaderinfo[num]->muspostbosstrack = 0;
 	mapheaderinfo[num]->muspostbosspos = 0;
+	mapheaderinfo[num]->muspostbossfadein = 0;
 	mapheaderinfo[num]->forcecharacter[0] = '\0';
 	mapheaderinfo[num]->weather = 0;
 	mapheaderinfo[num]->skynum = 1;
-- 
GitLab