From 233cd1b315cebe21bb86b728ba3d7037cfdd8beb Mon Sep 17 00:00:00 2001
From: Paweł Redman <pawel.redman@gmail.com>
Date: Sun, 18 Nov 2018 00:10:21 +0100
Subject: Don't reset if the player count drops below the threshold.

---
 src/game/g_local.h |  1 +
 src/game/g_main.c  | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

(limited to 'src/game')

diff --git a/src/game/g_local.h b/src/game/g_local.h
index d7c3860..f4961fd 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -834,6 +834,7 @@ typedef struct
 
   int               antistackNextCheck;
   qboolean          antistackWasHandicapping;
+  qboolean          antistackHadEnoughPlayers;
   float             alienHandicap;
   float             humanHandicap;
 } level_locals_t;
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 8f8a83b..c7ad479 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1026,6 +1026,8 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
   level.antistackNextCheck = g_antistackTimeThreshold.integer * 1000;
   level.alienHandicap = 1.0f;
   level.humanHandicap = 1.0f;
+  level.antistackWasHandicapping = qfalse;
+  level.antistackHadEnoughPlayers = qfalse;
 }
 
 /*
@@ -2758,12 +2760,15 @@ static void CheckAntistack(void)
 		}
 	}
 
-	if (aliens + humans < g_antistackPlayerThreshold.integer) {
+	if (!level.antistackHadEnoughPlayers &&
+	    aliens + humans < g_antistackPlayerThreshold.integer) {
 		log_notice = " (too few players)";
 		bias = 0.0f;
 		goto skip_bias;
 	}
 
+	level.antistackHadEnoughPlayers = qtrue;
+
 	if (alien_score < g_antistackScoreThreshold.integer &&
 	    human_score < g_antistackScoreThreshold.integer) {
 		log_notice = " (too little score)";
@@ -2777,8 +2782,8 @@ static void CheckAntistack(void)
 
 skip_bias:
 	if (fabs(bias) < g_antistackBiasThreshold.value) {
-		log_notice = " (too little bias)";
-		bias = 0.0f;
+		if (!strlen(log_notice))
+			log_notice = " (too little bias)";
 
 		if (level.antistackWasHandicapping) {
 			if (g_antistack.integer > 0)
-- 
cgit