From 7a00b3a331d86a06c6a27999999623c1308bc088 Mon Sep 17 00:00:00 2001
From: Jaime Passos <lazymyuutsu@gmail.com>
Date: Sat, 28 Dec 2019 19:56:18 -0300
Subject: [PATCH] Add GTR_FRIENDLY.

---
 src/dehacked.c |  1 +
 src/doomstat.h | 49 +++++++++++++++++++++++++------------------------
 src/g_game.c   | 12 +++---------
 3 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/src/dehacked.c b/src/dehacked.c
index 3c7fe25aa..799428455 100644
--- a/src/dehacked.c
+++ b/src/dehacked.c
@@ -8905,6 +8905,7 @@ static const char *const GAMETYPERULE_LIST[] = {
 	"FRIENDLYFIRE",
 	"LIVES",
 	"TEAMS",
+	"FRIENDLY",
 	"RACE",
 	"TAG",
 	"POINTLIMIT",
diff --git a/src/doomstat.h b/src/doomstat.h
index 8046b5ed9..42c05ba63 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -400,30 +400,31 @@ enum GameTypeRules
 	GTR_FRIENDLYFIRE     = 1<<3,  // Always allow friendly fire
 	GTR_LIVES            = 1<<4,  // Co-op and Competition
 	GTR_TEAMS            = 1<<5,  // Team Match, CTF
-	GTR_RACE             = 1<<6,  // Race and Competition
-	GTR_TAG              = 1<<7,  // Tag and Hide and Seek
-	GTR_POINTLIMIT       = 1<<8,  // Ringslinger point limit
-	GTR_TIMELIMIT        = 1<<9,  // Ringslinger time limit
-	GTR_STARTCOUNTDOWN   = 1<<10, // Hide time countdown (Tag and Hide and Seek)
-	GTR_HIDEFROZEN       = 1<<11, // Frozen after hide time (Hide and Seek, but not Tag)
-	GTR_BLINDFOLDED      = 1<<12, // Blindfolded view (Tag and Hide and Seek)
-	GTR_FIRSTPERSON      = 1<<13, // First person camera
-	GTR_POWERSTONES      = 1<<14, // Power stones (Match and CTF)
-	GTR_TEAMFLAGS        = 1<<15, // Gametype has team flags (CTF)
-	GTR_PITYSHIELD       = 1<<16, // Award pity shield
-	GTR_DEATHPENALTY     = 1<<17, // Death score penalty
-	GTR_NOSPECTATORSPAWN = 1<<18, // Use with GTR_SPECTATORS, spawn in the map instead of with the spectators
-	GTR_DEATHMATCHSTARTS = 1<<19, // Use deathmatch starts
-	GTR_SPECIALSTAGES    = 1<<20, // Allow special stages
-	GTR_EMERALDTOKENS    = 1<<21, // Spawn emerald tokens
-	GTR_EMERALDHUNT      = 1<<22, // Emerald Hunt
-	GTR_SPAWNENEMIES     = 1<<23, // Spawn enemies
-	GTR_ALLOWEXIT        = 1<<24, // Allow exit sectors
-	GTR_NOTITLECARD      = 1<<25, // Don't show the title card
-	GTR_OVERTIME         = 1<<26, // Allow overtime
-	GTR_HURTMESSAGES     = 1<<27, // Hit and death messages
-	GTR_SPAWNINVUL       = 1<<28, // Babysitting deterrent
-	GTR_RESPAWNDELAY     = 1<<29, // Respawn delay
+	GTR_FRIENDLY         = 1<<6,  // Co-op
+	GTR_RACE             = 1<<7,  // Race and Competition
+	GTR_TAG              = 1<<8,  // Tag and Hide and Seek
+	GTR_POINTLIMIT       = 1<<9,  // Ringslinger point limit
+	GTR_TIMELIMIT        = 1<<10, // Ringslinger time limit
+	GTR_STARTCOUNTDOWN   = 1<<11, // Hide time countdown (Tag and Hide and Seek)
+	GTR_HIDEFROZEN       = 1<<12, // Frozen after hide time (Hide and Seek, but not Tag)
+	GTR_BLINDFOLDED      = 1<<13, // Blindfolded view (Tag and Hide and Seek)
+	GTR_FIRSTPERSON      = 1<<14, // First person camera
+	GTR_POWERSTONES      = 1<<15, // Power stones (Match and CTF)
+	GTR_TEAMFLAGS        = 1<<16, // Gametype has team flags (CTF)
+	GTR_PITYSHIELD       = 1<<17, // Award pity shield
+	GTR_DEATHPENALTY     = 1<<18, // Death score penalty
+	GTR_NOSPECTATORSPAWN = 1<<19, // Use with GTR_SPECTATORS, spawn in the map instead of with the spectators
+	GTR_DEATHMATCHSTARTS = 1<<20, // Use deathmatch starts
+	GTR_SPECIALSTAGES    = 1<<21, // Allow special stages
+	GTR_EMERALDTOKENS    = 1<<22, // Spawn emerald tokens
+	GTR_EMERALDHUNT      = 1<<23, // Emerald Hunt
+	GTR_SPAWNENEMIES     = 1<<24, // Spawn enemies
+	GTR_ALLOWEXIT        = 1<<25, // Allow exit sectors
+	GTR_NOTITLECARD      = 1<<26, // Don't show the title card
+	GTR_OVERTIME         = 1<<27, // Allow overtime
+	GTR_HURTMESSAGES     = 1<<28, // Hit and death messages
+	GTR_SPAWNINVUL       = 1<<29, // Babysitting deterrent
+	GTR_RESPAWNDELAY     = 1<<30, // Respawn delay
 };
 
 // String names for gametypes
diff --git a/src/g_game.c b/src/g_game.c
index c8e185f56..67b6c2098 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -3193,7 +3193,7 @@ const char *Gametype_ConstantNames[NUMGAMETYPES] =
 UINT32 gametypedefaultrules[NUMGAMETYPES] =
 {
 	// Co-op
-	GTR_CAMPAIGN|GTR_LIVES|GTR_SPAWNENEMIES|GTR_ALLOWEXIT|GTR_EMERALDHUNT|GTR_EMERALDTOKENS|GTR_SPECIALSTAGES,
+	GTR_CAMPAIGN|GTR_LIVES|GTR_FRIENDLY|GTR_SPAWNENEMIES|GTR_ALLOWEXIT|GTR_EMERALDHUNT|GTR_EMERALDTOKENS|GTR_SPECIALSTAGES,
 	// Competition
 	GTR_RACE|GTR_LIVES|GTR_SPAWNENEMIES|GTR_EMERALDTOKENS|GTR_SPAWNINVUL|GTR_ALLOWEXIT,
 	// Race
@@ -3447,10 +3447,7 @@ boolean G_GametypeUsesLives(void)
 //
 boolean G_GametypeUsesCoopLives(void)
 {
-	// Preparing for the inevitable
-	// gametype rule that will
-	// handle cooplives...
-	return (gametype == GT_COOP);
+	return (gametyperules & (GTR_LIVES|GTR_FRIENDLY)) == (GTR_LIVES|GTR_FRIENDLY);
 }
 
 //
@@ -3461,10 +3458,7 @@ boolean G_GametypeUsesCoopLives(void)
 //
 boolean G_GametypeUsesCoopStarposts(void)
 {
-	// Preparing for the inevitable
-	// gametype rule that will
-	// handle coopstarposts...
-	return (gametype == GT_COOP);
+	return (gametyperules & GTR_FRIENDLY);
 }
 
 //