From 4dcdfb3370a11f338014164eec075b7fd7bb57b5 Mon Sep 17 00:00:00 2001
From: Cloudwalk <cloudwalk@icculus.org>
Date: Wed, 13 Dec 2023 23:26:53 -0500
Subject: [PATCH] cmd: Move cprint command to cl_screen

Client code doesn't belong in a common subsystem

Signed-off-by: Cloudwalk <cloudwalk@icculus.org>
---
 cl_screen.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 cmd.c       | 44 --------------------------------------------
 2 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/cl_screen.c b/cl_screen.c
index a313e1e3..8540f243 100644
--- a/cl_screen.c
+++ b/cl_screen.c
@@ -156,6 +156,48 @@ void SCR_CenterPrint(const char *str)
 	}
 }
 
+/*
+============
+SCR_Centerprint_f
+
+Print something to the center of the screen using SCR_Centerprint
+============
+*/
+static void SCR_Centerprint_f (cmd_state_t *cmd)
+{
+	char msg[MAX_INPUTLINE];
+	unsigned int i, c, p;
+	c = Cmd_Argc(cmd);
+	if(c >= 2)
+	{
+		strlcpy(msg, Cmd_Argv(cmd,1), sizeof(msg));
+		for(i = 2; i < c; ++i)
+		{
+			strlcat(msg, " ", sizeof(msg));
+			strlcat(msg, Cmd_Argv(cmd, i), sizeof(msg));
+		}
+		c = (unsigned int)strlen(msg);
+		for(p = 0, i = 0; i < c; ++i)
+		{
+			if(msg[i] == '\\')
+			{
+				if(msg[i+1] == 'n')
+					msg[p++] = '\n';
+				else if(msg[i+1] == '\\')
+					msg[p++] = '\\';
+				else {
+					msg[p++] = '\\';
+					msg[p++] = msg[i+1];
+				}
+				++i;
+			} else {
+				msg[p++] = msg[i];
+			}
+		}
+		msg[p] = '\0';
+		SCR_CenterPrint(msg);
+	}
+}
 
 static void SCR_DrawCenterString (void)
 {
@@ -840,6 +882,7 @@ void CL_Screen_Init(void)
 	if (Sys_CheckParm ("-noconsole"))
 		Cvar_SetQuick(&scr_conforcewhiledisconnected, "0");
 
+	Cmd_AddCommand(CF_CLIENT, "cprint", SCR_Centerprint_f, "print something at the screen center");
 	Cmd_AddCommand(CF_CLIENT, "sizeup",SCR_SizeUp_f, "increase view size (increases viewsize cvar)");
 	Cmd_AddCommand(CF_CLIENT, "sizedown",SCR_SizeDown_f, "decrease view size (decreases viewsize cvar)");
 	Cmd_AddCommand(CF_CLIENT, "screenshot",SCR_ScreenShot_f, "takes a screenshot of the next rendered frame");
diff --git a/cmd.c b/cmd.c
index b1294c3c..125488bf 100644
--- a/cmd.c
+++ b/cmd.c
@@ -117,49 +117,6 @@ static void Cmd_Defer_f (cmd_state_t *cmd)
 	}
 }
 
-/*
-============
-Cmd_Centerprint_f
-
-Print something to the center of the screen using SCR_Centerprint
-============
-*/
-static void Cmd_Centerprint_f (cmd_state_t *cmd)
-{
-	char msg[MAX_INPUTLINE];
-	unsigned int i, c, p;
-	c = Cmd_Argc(cmd);
-	if(c >= 2)
-	{
-		strlcpy(msg, Cmd_Argv(cmd,1), sizeof(msg));
-		for(i = 2; i < c; ++i)
-		{
-			strlcat(msg, " ", sizeof(msg));
-			strlcat(msg, Cmd_Argv(cmd, i), sizeof(msg));
-		}
-		c = (unsigned int)strlen(msg);
-		for(p = 0, i = 0; i < c; ++i)
-		{
-			if(msg[i] == '\\')
-			{
-				if(msg[i+1] == 'n')
-					msg[p++] = '\n';
-				else if(msg[i+1] == '\\')
-					msg[p++] = '\\';
-				else {
-					msg[p++] = '\\';
-					msg[p++] = msg[i+1];
-				}
-				++i;
-			} else {
-				msg[p++] = msg[i];
-			}
-		}
-		msg[p] = '\0';
-		SCR_CenterPrint(msg);
-	}
-}
-
 /*
 =============================================================================
 
@@ -1658,7 +1615,6 @@ void Cmd_Init(void)
 //
 	// client-only commands
 	Cmd_AddCommand(CF_SHARED, "wait", Cmd_Wait_f, "make script execution wait for next rendered frame");
-	Cmd_AddCommand(CF_CLIENT, "cprint", Cmd_Centerprint_f, "print something at the screen center");
 
 	// maintenance commands used for upkeep of cvars and saved configs
 	Cmd_AddCommand(CF_SHARED, "stuffcmds", Cmd_StuffCmds_f, "execute commandline parameters (must be present in quake.rc script)");
-- 
2.39.5