From 3e5b31af20cb275d777eb2d006b9d525e4f08c7e Mon Sep 17 00:00:00 2001 From: Ben Millwood Date: Wed, 29 Sep 2010 18:04:22 +0000 Subject: * Fix /me in teamsay menu --- src/game/g_cmds.c | 17 ----------------- src/ui/ui_atoms.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 01bb8c71..390c6a5b 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -730,22 +730,6 @@ void G_Say( gentity_t *ent, saymode_t mode, const char *chatText ) } } -/* -================== -Cmd_ActionMessage_f - -This is just a wrapper for convenience when speaking from the console -================== -*/ -static void Cmd_ActionMessage_f( gentity_t *ent ) -{ - char text[ MAX_SAY_TEXT ]; - - Com_sprintf( text, sizeof( text ), "/me %s", ConcatArgs( 1 ) ); - - G_Say( ent, SAY_ALL, text ); -} - /* ================== Cmd_SayArea_f @@ -2871,7 +2855,6 @@ commands_t cmds[ ] = { { "levelshot", CMD_CHEAT, Cmd_LevelShot_f }, { "listmaps", CMD_MESSAGE|CMD_INTERMISSION, Cmd_ListMaps_f }, { "m", CMD_MESSAGE|CMD_INTERMISSION, Cmd_PrivateMessage_f }, - { "me", CMD_MESSAGE|CMD_INTERMISSION, Cmd_ActionMessage_f }, { "mt", CMD_MESSAGE|CMD_INTERMISSION, Cmd_PrivateMessage_f }, { "noclip", CMD_CHEAT_TEAM, Cmd_Noclip_f }, { "notarget", CMD_CHEAT|CMD_TEAM|CMD_LIVING, Cmd_Notarget_f }, diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c index 9c98f867..0d50e286 100644 --- a/src/ui/ui_atoms.c +++ b/src/ui/ui_atoms.c @@ -88,6 +88,34 @@ char *UI_Argv( int arg ) return buffer; } +char *UI_ConcatArgs( int arg, char *buf, int len ) +{ + char *p; + int c; + + if( len <= 0 ) + return buf; + + p = buf; + c = trap_Argc(); + + for( ; arg < c; arg++ ) + { + char *argp = UI_Argv( arg ); + + while( *argp && p < &buf[ len - 1 ] ) + *p++ = *argp++; + + if( p < &buf[ len - 2 ] ) + *p++ = ' '; + else + break; + } + + *p = '\0'; + + return buf; +} char *UI_Cvar_VariableString( const char *var_name ) { @@ -153,12 +181,27 @@ static void UI_MessageMode_f( void ) Menus_ActivateByName( "say" ); } +static void UI_Me_f( void ) +{ + char buf[ MAX_SAY_TEXT - 4 ], *cmd; + + UI_ConcatArgs( 1, buf, sizeof( buf ) ); + + if( uiInfo.chatTeam ) + cmd = "say_team"; + else + cmd = "say"; + + trap_Cmd_ExecuteText( EXEC_APPEND, va( "%s \"/me %s\"", cmd, buf ) ); +} + struct uicmd { char *cmd; void ( *function )( void ); } commands[ ] = { { "closemenus", UI_CloseMenus_f }, + { "me", UI_Me_f }, { "menu", UI_Menu_f }, { "messagemode", UI_MessageMode_f }, { "messagemode2", UI_MessageMode_f }, -- cgit