From: Cloudwalk Date: Thu, 14 Dec 2023 04:26:53 +0000 (-0500) Subject: cmd: Move cprint command to cl_screen X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4dcdfb3370a11f338014164eec075b7fd7bb57b5;p=xonotic%2Fdarkplaces.git cmd: Move cprint command to cl_screen Client code doesn't belong in a common subsystem Signed-off-by: Cloudwalk --- 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)");