From 5b5193a852a609113ddce0cd60cbc31c157ea0c4 Mon Sep 17 00:00:00 2001
From: terencehill <piuntn@gmail.com>
Date: Fri, 16 Apr 2021 18:15:11 +0200
Subject: [PATCH] Get rid of a couple backtraces printed in the console when a
 player is kicked for not playing (added a missing return;)

---
 qcsrc/server/client.qc | 28 ++++++++--------------------
 qcsrc/server/client.qh |  2 --
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc
index 0f4a46bf90..08a0b68da2 100644
--- a/qcsrc/server/client.qc
+++ b/qcsrc/server/client.qc
@@ -2095,23 +2095,6 @@ int nJoinAllowed(entity this, entity ignore)
 	return free_slots;
 }
 
-/**
- * Checks whether the client is an observer or spectator, if so, he will get kicked after
- * g_maxplayers_spectator_blocktime seconds
- */
-void checkSpectatorBlock(entity this)
-{
-	if(IS_SPEC(this) || IS_OBSERVER(this))
-	if(!this.caplayer)
-	if(IS_REAL_CLIENT(this))
-	{
-		if( time > (CS(this).spectatortime + autocvar_g_maxplayers_spectator_blocktime) ) {
-			Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_QUIT_KICK_SPECTATING);
-			dropclient(this);
-		}
-	}
-}
-
 void PrintWelcomeMessage(entity this)
 {
 	if(CS(this).motd_actived_time == 0)
@@ -2475,12 +2458,17 @@ void PlayerPreThink (entity this)
 	if (frametime) {
 		// physics frames: update anticheat stuff
 		anticheat_prethink(this);
-	}
 
-	if (blockSpectators && frametime) {
 		// WORKAROUND: only use dropclient in server frames (frametime set).
 		// Never use it in cl_movement frames (frametime zero).
-		checkSpectatorBlock(this);
+		if (blockSpectators && IS_REAL_CLIENT(this)
+			&& (IS_SPEC(this) || IS_OBSERVER(this)) && !this.caplayer
+			&& time > (CS(this).spectatortime + autocvar_g_maxplayers_spectator_blocktime))
+		{
+			Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_QUIT_KICK_SPECTATING);
+			dropclient(this);
+			return;
+		}
 	}
 
 	zoomstate_set = false;
diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh
index 4dd93563e4..ed3273be84 100644
--- a/qcsrc/server/client.qh
+++ b/qcsrc/server/client.qh
@@ -365,8 +365,6 @@ void ClientData_Touch(entity e);
 
 int nJoinAllowed(entity this, entity ignore);
 
-void checkSpectatorBlock(entity this);
-
 void PlayerUseKey(entity this);
 
 void FixClientCvars(entity e);
-- 
2.39.5