From 47554b57e4bce237e7092a3c77c959cf1d029b05 Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Mon, 29 Jul 2019 14:55:36 +0100
Subject: [PATCH] * Made the evaluation screen even more attractive. * Fixed an
 unused variable warning in lua_skinlib.c. - fixed post-level cutscenes
 playing when you get game over in MP (still kinda on-topic) Also with
 apologies to MI: - golden egg statue mode for tutorial, since the grey
 doesn't contrast enough with the blue and lime green - fixed closed captions
 for replaced player sounds being incorrect - fixed closed captions
 overlapping tutorial text

---
 src/doomstat.h    |  2 +-
 src/f_finale.c    | 91 +++++++++++++++++++++++++++--------------------
 src/g_game.c      |  6 ++--
 src/g_game.h      |  2 ++
 src/lua_baselib.c |  4 +--
 src/lua_skinlib.c |  1 -
 src/m_cond.c      |  2 +-
 src/p_mobj.c      |  6 ++++
 src/p_setup.c     |  2 +-
 src/p_spec.c      |  2 +-
 src/s_sound.c     |  5 +--
 src/screen.c      |  4 ++-
 12 files changed, 76 insertions(+), 51 deletions(-)

diff --git a/src/doomstat.h b/src/doomstat.h
index 87b98ab40c..18300967c1 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -234,7 +234,7 @@ extern textprompt_t *textprompts[MAX_PROMPTS];
 
 // For the Custom Exit linedef.
 extern INT16 nextmapoverride;
-extern boolean skipstats;
+extern UINT8 skipstats;
 
 extern UINT32 ssspheres; //  Total # of spheres in a level
 
diff --git a/src/f_finale.c b/src/f_finale.c
index 72bf17f1f7..cb315be03a 100644
--- a/src/f_finale.c
+++ b/src/f_finale.c
@@ -110,7 +110,7 @@ static INT32 sparklloop;
 //
 // PROMPT STATE
 //
-static boolean promptactive = false;
+boolean promptactive = false;
 static mobj_t *promptmo;
 static INT16 promptpostexectag;
 static boolean promptblockcontrols;
@@ -1284,6 +1284,7 @@ boolean F_CreditResponder(event_t *event)
 // ============
 //  EVALUATION
 // ============
+
 #define SPARKLLOOPTIME 7 // must be odd
 
 void F_StartGameEvaluation(void)
@@ -1322,14 +1323,11 @@ void F_GameEvaluationDrawer(void)
 	angle_t fa;
 	INT32 eemeralds_cur;
 	char patchname[7] = "CEMGx0";
+	const char* endingtext = (goodending ? "CONGRATULATIONS!" : "TRY AGAIN...");
 
 	V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
 
 	// Draw all the good crap here.
-	if (goodending)
-		V_DrawString(114, 16, 0, "GOT THEM ALL!");
-	else
-		V_DrawString(124, 16, 0, "TRY AGAIN!");
 
 	if (finalecount > 0)
 	{
@@ -1420,6 +1418,9 @@ void F_GameEvaluationDrawer(void)
 		V_DrawFixedPatch(x, y, FRACUNIT, ((emeralds & (1<<i)) ? 0 : V_80TRANS), W_CachePatchName(patchname, PU_LEVEL), NULL);
 	}
 
+	V_DrawCreditString((BASEVIDWIDTH - V_CreditStringWidth(endingtext))<<(FRACBITS-1), (BASEVIDHEIGHT-100)<<(FRACBITS-1), 0, endingtext);
+
+#if 0 // the following looks like hot garbage the more unlockables we add, and we now have a lot of unlockables
 	if (finalecount >= 5*TICRATE)
 	{
 		V_DrawString(8, 16, V_YELLOWMAP, "Unlocked:");
@@ -1444,28 +1445,18 @@ void F_GameEvaluationDrawer(void)
 		else
 			V_DrawString(8, 96, V_YELLOWMAP, "Prizes not\nawarded in\nmodified games!");
 	}
+#endif
 }
 
 void F_GameEvaluationTicker(void)
 {
-	finalecount++;
-
-	if (goodending)
+	if (++finalecount > 10*TICRATE)
 	{
-		if (++sparklloop == SPARKLLOOPTIME) // time to roll the randomisation again
-		{
-			angle_t workingangle = FixedAngle((M_RandomKey(360))<<FRACBITS)>>ANGLETOFINESHIFT;
-			fixed_t workingradius = M_RandomKey(26);
-			sparkloffs[2][0] = sparkloffs[1][0];
-			sparkloffs[2][1] = sparkloffs[1][1];
-			sparkloffs[1][0] = sparkloffs[0][0];
-			sparkloffs[1][1] = sparkloffs[0][1];
-			sparkloffs[0][0] = (30<<FRACBITS) + workingradius*FINECOSINE(workingangle);
-			sparkloffs[0][1] = (30<<FRACBITS) + workingradius*FINESINE(workingangle);
-			sparklloop = 0;
-		}
+		F_StartGameEnd();
+		return;
 	}
-	else
+
+	if (!goodending)
 	{
 		if (sparklloop)
 			sparklloop--;
@@ -1478,10 +1469,31 @@ void F_GameEvaluationTicker(void)
 			sparklloop = 10;
 		}
 	}
+	else if (++sparklloop == SPARKLLOOPTIME) // time to roll the randomisation again
+	{
+		angle_t workingangle = FixedAngle((M_RandomKey(360))<<FRACBITS)>>ANGLETOFINESHIFT;
+		fixed_t workingradius = M_RandomKey(26);
+
+		sparkloffs[2][0] = sparkloffs[1][0];
+		sparkloffs[2][1] = sparkloffs[1][1];
+		sparkloffs[1][0] = sparkloffs[0][0];
+		sparkloffs[1][1] = sparkloffs[0][1];
+
+		sparkloffs[0][0] = (30<<FRACBITS) + workingradius*FINECOSINE(workingangle);
+		sparkloffs[0][1] = (30<<FRACBITS) + workingradius*FINESINE(workingangle);
+		sparklloop = 0;
+	}
 
 	if (finalecount == 5*TICRATE)
 	{
-		if ((!modifiedgame || savemoddata) && !(netgame || multiplayer))
+		if (netgame || multiplayer) // modify this when we finally allow unlocking stuff in 2P
+		{
+			HU_SetCEchoFlags(V_YELLOWMAP|V_RETURN8);
+			HU_SetCEchoDuration(6);
+			HU_DoCEcho("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Prizes only awarded in singleplayer!");
+			S_StartSound(NULL, sfx_s3k68);
+		}
+		else if (!modifiedgame || savemoddata)
 		{
 			++timesBeaten;
 
@@ -1496,10 +1508,14 @@ void F_GameEvaluationTicker(void)
 
 			G_SaveGameData();
 		}
+		else
+		{
+			HU_SetCEchoFlags(V_YELLOWMAP|V_RETURN8);
+			HU_SetCEchoDuration(6);
+			HU_DoCEcho("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Prizes not awarded in modified games!");
+			S_StartSound(NULL, sfx_s3k68);
+		}
 	}
-
-	if (finalecount > 10*TICRATE)
-		F_StartGameEnd();
 }
 
 #undef SPARKLLOOPTIME
@@ -1508,8 +1524,8 @@ void F_GameEvaluationTicker(void)
 //   ENDING
 // ==========
 
-#define SPARKLLOOPTIME 15 // must be odd
 #define INFLECTIONPOINT (6*TICRATE)
+#define SPARKLLOOPTIME 15 // must be odd
 
 void F_StartEnding(void)
 {
@@ -1594,10 +1610,14 @@ void F_StartEnding(void)
 
 void F_EndingTicker(void)
 {
-	angle_t workingangle;
-	fixed_t workingradius;
+	if (++finalecount > INFLECTIONPOINT*2)
+	{
+		F_StartCredits();
+		wipetypepre = INT16_MAX;
+		return;
+	}
 
-	if (++finalecount == INFLECTIONPOINT && goodending) // time to swap some assets
+	if (goodending && finalecount == INFLECTIONPOINT) // time to swap some assets
 	{
 		endegrk[0] = W_CachePatchName("ENDEGRK2", PU_LEVEL);
 		endegrk[1] = W_CachePatchName("ENDEGRK3", PU_LEVEL);
@@ -1610,17 +1630,13 @@ void F_EndingTicker(void)
 
 	if (++sparklloop == SPARKLLOOPTIME) // time to roll the randomisation again
 	{
-		sparklloop = 0;
-		workingangle = FixedAngle((M_RandomRange(-170, 80))<<FRACBITS)>>ANGLETOFINESHIFT;
-		workingradius = M_RandomKey(26);
+		angle_t workingangle = FixedAngle((M_RandomRange(-170, 80))<<FRACBITS)>>ANGLETOFINESHIFT;
+		fixed_t workingradius = M_RandomKey(26);
+
 		sparkloffs[0][0] = (30<<FRACBITS) + workingradius*FINECOSINE(workingangle);
 		sparkloffs[0][1] = (30<<FRACBITS) + workingradius*FINESINE(workingangle);
-	}
 
-	if (finalecount > INFLECTIONPOINT*2)
-	{
-		F_StartCredits();
-		wipetypepre = INT16_MAX;
+		sparklloop = 0;
 	}
 }
 
@@ -2005,7 +2021,6 @@ void F_EndingDrawer(void)
 }
 
 #undef SPARKLLOOPTIME
-#undef INFLECTIONPOINT
 
 // ==========
 //  GAME END
diff --git a/src/g_game.c b/src/g_game.c
index c6af0f48d7..60262161a4 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -152,7 +152,7 @@ cutscene_t *cutscenes[128];
 textprompt_t *textprompts[MAX_PROMPTS];
 
 INT16 nextmapoverride;
-boolean skipstats;
+UINT8 skipstats;
 
 // Pointers to each CTF flag
 mobj_t *redflag;
@@ -2651,7 +2651,7 @@ void G_DoReborn(INT32 playernum)
 					//nextmapoverride = spstage_start;
 					nextmapoverride = gamemap;
 					countdown2 = TICRATE;
-					skipstats = true;
+					skipstats = 2;
 
 					for (i = 0; i < MAXPLAYERS; i++)
 					{
@@ -3180,7 +3180,7 @@ void G_AfterIntermission(void)
 {
 	HU_ClearCEcho();
 
-	if (mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking) // Start a custom cutscene.
+	if (mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking && skipstats <= 1) // Start a custom cutscene.
 		F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false);
 	else
 	{
diff --git a/src/g_game.h b/src/g_game.h
index 3cbde9a3c6..f03014439b 100644
--- a/src/g_game.h
+++ b/src/g_game.h
@@ -56,6 +56,8 @@ extern INT16 rw_maximums[NUM_WEAPONS];
 extern INT32 pausedelay;
 extern boolean pausebreakkey;
 
+extern boolean promptactive;
+
 // used in game menu
 extern consvar_t cv_tutorialprompt;
 extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_compactscoreboard;
diff --git a/src/lua_baselib.c b/src/lua_baselib.c
index 1d69b238bc..98f2ba3b89 100644
--- a/src/lua_baselib.c
+++ b/src/lua_baselib.c
@@ -2601,12 +2601,12 @@ static int lib_gSetCustomExitVars(lua_State *L)
 			nextmapoverride = (INT16)luaL_checknumber(L, 1);
 			lua_remove(L, 1); // remove nextmapoverride; skipstats now 1 if available
 		}
-		skipstats = lua_optboolean(L, 1);
+		skipstats = luaL_optinteger(L, 2, 0);
 	}
 	else
 	{
 		nextmapoverride = 0;
-		skipstats = false;
+		skipstats = 0;
 	}
 	// ---
 
diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c
index cc18ce860e..a28f6a3595 100644
--- a/src/lua_skinlib.c
+++ b/src/lua_skinlib.c
@@ -98,7 +98,6 @@ static int skin_get(lua_State *L)
 {
 	skin_t *skin = *((skin_t **)luaL_checkudata(L, 1, META_SKIN));
 	enum skin field = luaL_checkoption(L, 2, NULL, skin_opt);
-	INT32 i;
 
 	// skins are always valid, only added, never removed
 	I_Assert(skin != NULL);
diff --git a/src/m_cond.c b/src/m_cond.c
index e03542bf36..539c6d1f6d 100644
--- a/src/m_cond.c
+++ b/src/m_cond.c
@@ -240,7 +240,7 @@ UINT8 M_UpdateUnlockablesAndExtraEmblems(void)
 	if (cechoLines)
 	{
 		char slashed[1024] = "";
-		for (i = 0; (i < 21) && (i < 24 - cechoLines); ++i)
+		for (i = 0; (i < 19) && (i < 24 - cechoLines); ++i)
 			slashed[i] = '\\';
 		slashed[i] = 0;
 
diff --git a/src/p_mobj.c b/src/p_mobj.c
index 9a6e0f2bb2..a48ebfc409 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -11100,6 +11100,12 @@ You should think about modifying the deathmatch starts to take full advantage of
 		else
 			skyboxviewpnts[mthing->extrainfo] = mobj;
 		break;
+	case MT_EGGSTATUE:
+		if (tutorialmode != (mthing->options & MTF_OBJECTSPECIAL))
+		{
+			mobj->color = SKINCOLOR_GOLD;
+			mobj->colorized = true;
+		}
 	case MT_EGGMOBILE3:
 		mobj->cusval = mthing->extrainfo;
 		break;
diff --git a/src/p_setup.c b/src/p_setup.c
index f38ba93342..dfbba0252d 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -3126,7 +3126,7 @@ boolean P_SetupLevel(boolean skipprecip)
 		R_PrecacheLevel();
 
 	nextmapoverride = 0;
-	skipstats = false;
+	skipstats = 0;
 
 	if (!(netgame || multiplayer) && (!modifiedgame || savemoddata))
 		mapvisited[gamemap-1] |= MV_VISITED;
diff --git a/src/p_spec.c b/src/p_spec.c
index 3cd0461e24..88dfad70e5 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -4624,7 +4624,7 @@ DoneSection2:
 						nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS);
 
 					if (lines[lineindex].flags & ML_NOCLIMB)
-						skipstats = true;
+						skipstats = 1;
 				}
 			}
 			break;
diff --git a/src/s_sound.c b/src/s_sound.c
index 120ba5e504..9b5df072cc 100644
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -519,6 +519,7 @@ void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan)
 void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
 {
 	INT32 sep, pitch, priority, cnum;
+	const sfxenum_t actual_id = sfx_id;
 	sfxinfo_t *sfx;
 
 	const mobj_t *origin = (const mobj_t *)origin_p;
@@ -657,7 +658,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
 #endif
 
 		// Handle closed caption input.
-		S_StartCaption(sfx_id, cnum, MAXCAPTIONTICS);
+		S_StartCaption(actual_id, cnum, MAXCAPTIONTICS);
 
 		// Assigns the handle to one of the channels in the
 		// mix/output buffer.
@@ -710,7 +711,7 @@ dontplay:
 #endif
 
 	// Handle closed caption input.
-	S_StartCaption(sfx_id, cnum, MAXCAPTIONTICS);
+	S_StartCaption(actual_id, cnum, MAXCAPTIONTICS);
 
 	// Assigns the handle to one of the channels in the
 	// mix/output buffer.
diff --git a/src/screen.c b/src/screen.c
index ac7878c4a8..fc3f5b8e87 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -438,7 +438,9 @@ void SCR_ClosedCaptions(void)
 
 	if (gamestate == GS_LEVEL)
 	{
-		if (splitscreen)
+		if (promptactive)
+			basey -= 28;
+		else if (splitscreen)
 			basey -= 8;
 		else if ((modeattacking == ATTACKING_NIGHTS)
 		|| (!(maptol & TOL_NIGHTS)
-- 
GitLab