From: havoc Date: Thu, 20 Mar 2008 19:57:23 +0000 (+0000) Subject: patch from Blub adding cprint (centerprint) console command, similar to X-Git-Tag: xonotic-v0.1.0preview~2307 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c4a5702fffcf98f0693e360570e5c03889401f07;p=xonotic%2Fdarkplaces.git patch from Blub adding cprint (centerprint) console command, similar to echo git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8220 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cmd.c b/cmd.c index b515dbb9..e7fe4a81 100644 --- a/cmd.c +++ b/cmd.c @@ -63,6 +63,49 @@ static void Cmd_Wait_f (void) cmd_wait = true; } +/* +============ +Cmd_Centerprint_f + +Print something to the center of the screen using SCR_Centerprint +============ +*/ +static void Cmd_Centerprint_f (void) +{ + char msg[MAX_INPUTLINE]; + unsigned int i, c, p; + c = Cmd_Argc(); + if(c >= 2) + { + strlcpy(msg, Cmd_Argv(1), sizeof(msg)); + for(i = 2; i < c; ++i) + { + strlcat(msg, " ", sizeof(msg)); + strlcat(msg, Cmd_Argv(i), sizeof(msg)); + } + c = 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); + } +} + /* ============================================================================= @@ -927,6 +970,8 @@ void Cmd_Init_Commands (void) Cmd_AddCommand ("cvar_resettodefaults_nosaveonly", Cvar_ResetToDefaults_NoSaveOnly_f, "sets all non-saved cvars to their locked default values (variables that will not be saved to config.cfg)"); Cmd_AddCommand ("cvar_resettodefaults_saveonly", Cvar_ResetToDefaults_SaveOnly_f, "sets all saved cvars to their locked default values (variables that will be saved to config.cfg)"); + Cmd_AddCommand ("cprint", Cmd_Centerprint_f, "print something at the screen center"); + // DRESK - 5/14/06 // Support Doom3-style Toggle Command Cmd_AddCommand( "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)");