From fe904b0eb28ba4d32280a86c5ee0364c67f14710 Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Sun, 12 Aug 2018 19:45:34 -0400
Subject: [PATCH] NiGHTS lap score bonus

---
 src/dehacked.c |  6 ++++--
 src/y_inter.c  | 26 ++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/dehacked.c b/src/dehacked.c
index 41d41405c..c672cbee4 100644
--- a/src/dehacked.c
+++ b/src/dehacked.c
@@ -1198,9 +1198,11 @@ static void readlevelheader(MYFILE *f, INT32 num)
 				else if (fastcmp(word2, "ERZ3"))   i =  2;
 				else if (fastcmp(word2, "NIGHTS")) i =  3;
 				else if (fastcmp(word2, "NIGHTSLINK")) i =  4;
-				else if (fastcmp(word2, "NIGHTSALL")) i =  5;
+				else if (fastcmp(word2, "NIGHTSLAP")) i =  5;
+				else if (fastcmp(word2, "NIGHTSLINKLAP")) i =  6;
+				else if (fastcmp(word2, "NIGHTSALL")) i =  7;
 
-				if (i >= -1 && i <= 5) // -1 for no bonus. Max is 2.
+				if (i >= -1 && i <= 7) // -1 for no bonus. Max is 2.
 					mapheaderinfo[num-1]->bonustype = (SINT8)i;
 				else
 					deh_warning("Level header %d: invalid bonus type number %d", num, i);
diff --git a/src/y_inter.c b/src/y_inter.c
index de0335523..f34bc06c0 100644
--- a/src/y_inter.c
+++ b/src/y_inter.c
@@ -1764,6 +1764,16 @@ static void Y_SetNightsBonus(player_t *player, y_bonus_t *bstruct)
 	bstruct->points = player->totalmarescore;
 }
 
+//
+// Y_SetLapBonus
+//
+static void Y_SetLapBonus(player_t *player, y_bonus_t *bstruct)
+{
+	strncpy(bstruct->patch, "YB_LAP", sizeof(bstruct->patch));
+	bstruct->display = true;
+	bstruct->points = max(0, (player->totalmarebonuslap) * 100);
+}
+
 //
 // Y_SetLinkBonus
 //
@@ -1825,7 +1835,7 @@ static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct)
 
 // This list can be extended in the future with SOC/Lua, perhaps.
 typedef void (*bonus_f)(player_t *, y_bonus_t *);
-bonus_f bonuses_list[7][4] = {
+bonus_f bonuses_list[9][4] = {
 	{
 		Y_SetNullBonus,
 		Y_SetNullBonus,
@@ -1862,11 +1872,23 @@ bonus_f bonuses_list[7][4] = {
 		Y_SetLinkBonus,
 		Y_SetNullBonus,
 	},
+	{
+		Y_SetNullBonus,
+		Y_SetNullBonus,
+		Y_SetLapBonus,
+		Y_SetNullBonus,
+	},
+	{
+		Y_SetNullBonus,
+		Y_SetLinkBonus,
+		Y_SetLapBonus,
+		Y_SetNullBonus,
+	},
 	{
 		Y_SetNullBonus,
 		Y_SetNightsBonus,
 		Y_SetLinkBonus,
-		Y_SetNullBonus,
+		Y_SetLapBonus,
 	},
 };