From e76d590dc99030ce2756640954f81da1d354ed76 Mon Sep 17 00:00:00 2001 From: "M. Kristall" Date: Wed, 20 Oct 2010 07:05:34 +0000 Subject: * (Bug 4649) Require reasons for votes (WilliamH, Chris "Lakitu7" Schwarz) --- assets/ui/ingame_game.menu | 33 ++++++++++++++++++++++++++++----- src/game/g_cmds.c | 34 ++++++++++++++++++++++++++++++---- src/ui/ui_main.c | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 86 insertions(+), 17 deletions(-) diff --git a/assets/ui/ingame_game.menu b/assets/ui/ingame_game.menu index 8348859a..d7d7dd6a 100644 --- a/assets/ui/ingame_game.menu +++ b/assets/ui/ingame_game.menu @@ -31,11 +31,11 @@ #define PBUTT_X MAP_X #define PBUTT_Y (H-((2*PBUTT_H)+BORDER)) #define PBUTT_W (W-((2*BORDER)+SIDEBUTT_W)) -#define PBUTT_H 25 +#define PBUTT_H 45 #define PLIST_X PBUTT_X #define PLIST_Y ((2*BORDER)+TOPBUTT_H) #define PLIST_W PBUTT_W -#define PLIST_H (H-((4*BORDER)+(2*PBUTT_H)+TOPBUTT_H)) +#define PLIST_H ((H-((4*BORDER)+(2*PBUTT_H)+TOPBUTT_H))) #define PLAYER_C 0.7 #define IGN_C 0.15 @@ -215,6 +215,7 @@ play "sound/misc/menu1.wav"; hide gameGrp; show playervote; + show reasonfield; show vote; } } @@ -237,10 +238,32 @@ play "sound/misc/menu1.wav"; hide gameGrp; show teamvote; + show reasonfield; show vote; } } + itemDef + { + name reasonfield + group gameGrp + type ITEM_TYPE_EDITFIELD + style WINDOW_STYLE_EMPTY + text "Reason:" + cvar "ui_reason" + maxChars 50 + rect PBUTT_X (PBUTT_Y+PBUTT_H) PBUTT_W PBUTT_H + textalign ALIGN_LEFT + textvalign VALIGN_CENTER + textscale .25 + outlinecolor .2 .2 .2 .5 + backcolor 0 0 0 0 + forecolor 1 1 1 1 + border WINDOW_BORDER_NONE + bordercolor 0 0 0 0 + visible MENU_FALSE + } + ///// Map Vote itemDef { @@ -448,7 +471,7 @@ text "Kick Player" type ITEM_TYPE_BUTTON textscale .25 - rect PBUTT_X (PBUTT_Y+PBUTT_H) PBUTT_W PBUTT_H + rect PBUTT_X (PBUTT_Y+(PBUTT_H/2)) PBUTT_W PBUTT_H textalign ALIGN_CENTER textvalign VALIGN_CENTER forecolor 1 1 1 1 @@ -531,7 +554,7 @@ type ITEM_TYPE_BUTTON textscale .25 rect 110 215 150 20 - rect PBUTT_X (PBUTT_Y+PBUTT_H) (PBUTT_W/2) PBUTT_H + rect PBUTT_X (PBUTT_Y+(PBUTT_H/2)) (PBUTT_W/2) PBUTT_H textalign ALIGN_CENTER textvalign VALIGN_CENTER forecolor 1 1 1 1 @@ -551,7 +574,7 @@ text "Admit Defeat" type ITEM_TYPE_BUTTON textscale .25 - rect (PBUTT_X+(PBUTT_W/2)) (PBUTT_Y+PBUTT_H) (PBUTT_W/2) PBUTT_H + rect (PBUTT_X+(PBUTT_W/2)) (PBUTT_Y+(PBUTT_H/2)) (PBUTT_W/2) PBUTT_H textalign ALIGN_CENTER textvalign VALIGN_CENTER forecolor 1 1 1 1 diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 13d27f4f..cbcc18b7 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1093,12 +1093,14 @@ void Cmd_CallVote_f( gentity_t *ent ) vote[ MAX_TOKEN_CHARS ], arg[ MAX_TOKEN_CHARS ]; char name[ MAX_NAME_LENGTH ] = ""; + char *reason; int clientNum = -1; team_t team; trap_Argv( 0, cmd, sizeof( cmd ) ); trap_Argv( 1, vote, sizeof( vote ) ); trap_Argv( 2, arg, sizeof( arg ) ); + reason = ConcatArgs( 3 ); if( !Q_stricmp( cmd, "callteamvote" ) ) team = ent->client->pers.teamSelection; @@ -1192,6 +1194,13 @@ void Cmd_CallVote_f( gentity_t *ent ) va( "print \"%s: player is not on your team\n\"", cmd ) ); return; } + + if( !reason[ 0 ] && !G_admin_permission( ent, ADMF_UNACCOUNTABLE ) ) + { + trap_SendServerCommand( ent-g_entities, + va( "print \"%s: You must provide a reason\n\"", cmd ) ); + return; + } } } @@ -1205,11 +1214,16 @@ void Cmd_CallVote_f( gentity_t *ent ) } Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "ban %s \"1s%s\" vote kick", level.clients[ clientNum ].pers.ip.str, - g_adminTempBan.string ); + "ban %s \"1s%s\" vote kick (%s)", level.clients[ clientNum ].pers.ip.str, + g_adminTempBan.string, reason ); Com_sprintf( level.voteDisplayString[ team ], - sizeof( level.voteDisplayString[ team ] ), - "Kick player '%s'", name ); + sizeof( level.voteDisplayString[ team ] ), "Kick player '%s'", name ); + if( reason[ 0 ] ) + { + Com_sprintf( level.voteDisplayString[ team ], + sizeof( level.voteDisplayString[ team ] ), "%s for '%s'", + level.voteDisplayString[ team ], reason ); + } } else if( team == TEAM_NONE ) { @@ -1227,6 +1241,12 @@ void Cmd_CallVote_f( gentity_t *ent ) Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Mute player '%s'", name ); + if( reason[ 0 ] ) + { + Com_sprintf( level.voteDisplayString[ team ], + sizeof( level.voteDisplayString[ team ] ), "%s for '%s'", + level.voteDisplayString[ team ], reason ); + } } else if( !Q_stricmp( vote, "unmute" ) ) { @@ -1342,6 +1362,12 @@ void Cmd_CallVote_f( gentity_t *ent ) Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Take away building rights from '%s'", name ); + if( reason[ 0 ] ) + { + Com_sprintf( level.voteDisplayString[ team ], + sizeof( level.voteDisplayString[ team ] ), "%s for '%s'", + level.voteDisplayString[ team ], reason ); + } } else if( !Q_stricmp( vote, "allowbuild" ) ) { diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index d29fe4d5..f581e944 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -3204,16 +3204,26 @@ static void UI_RunMenuScript( char **args ) { if( uiInfo.playerIndex >= 0 && uiInfo.playerIndex < uiInfo.playerCount ) { - trap_Cmd_ExecuteText( EXEC_APPEND, va( "callvote kick %d\n", - uiInfo.clientNums[ uiInfo.playerIndex ] ) ); + char buffer[ MAX_CVAR_VALUE_STRING ]; + trap_Cvar_VariableStringBuffer( "ui_reason", buffer, sizeof( buffer ) ); + + trap_Cmd_ExecuteText( EXEC_APPEND, va( "callvote kick %d %s\n", + uiInfo.clientNums[ uiInfo.playerIndex ], + buffer ) ); + trap_Cvar_Set( "ui_reason", "" ); } } else if( Q_stricmp( name, "voteMute" ) == 0 ) { if( uiInfo.playerIndex >= 0 && uiInfo.playerIndex < uiInfo.playerCount ) { - trap_Cmd_ExecuteText( EXEC_APPEND, va( "callvote mute %d\n", - uiInfo.clientNums[ uiInfo.playerIndex ] ) ); + char buffer[ MAX_CVAR_VALUE_STRING ]; + trap_Cvar_VariableStringBuffer( "ui_reason", buffer, sizeof( buffer ) ); + + trap_Cmd_ExecuteText( EXEC_APPEND, va( "callvote mute %d %s\n", + uiInfo.clientNums[ uiInfo.playerIndex ], + buffer ) ); + trap_Cvar_Set( "ui_reason", "" ); } } else if( Q_stricmp( name, "voteUnMute" ) == 0 ) @@ -3228,16 +3238,26 @@ static void UI_RunMenuScript( char **args ) { if( uiInfo.teamPlayerIndex >= 0 && uiInfo.teamPlayerIndex < uiInfo.myTeamCount ) { - trap_Cmd_ExecuteText( EXEC_APPEND, va( "callteamvote kick %d\n", - uiInfo.teamClientNums[ uiInfo.teamPlayerIndex ] ) ); + char buffer[ MAX_CVAR_VALUE_STRING ]; + trap_Cvar_VariableStringBuffer( "ui_reason", buffer, sizeof( buffer ) ); + + trap_Cmd_ExecuteText( EXEC_APPEND, va( "callteamvote kick %d %s\n", + uiInfo.teamClientNums[ uiInfo.teamPlayerIndex ], + buffer ) ); + trap_Cvar_Set( "ui_reason", "" ); } } else if( Q_stricmp( name, "voteTeamDenyBuild" ) == 0 ) { if( uiInfo.teamPlayerIndex >= 0 && uiInfo.teamPlayerIndex < uiInfo.myTeamCount ) { - trap_Cmd_ExecuteText( EXEC_APPEND, va( "callteamvote denybuild %d\n", - uiInfo.teamClientNums[ uiInfo.teamPlayerIndex ] ) ); + char buffer[ MAX_CVAR_VALUE_STRING ]; + trap_Cvar_VariableStringBuffer( "ui_reason", buffer, sizeof( buffer ) ); + + trap_Cmd_ExecuteText( EXEC_APPEND, va( "callteamvote denybuild %d %s\n", + uiInfo.teamClientNums[ uiInfo.teamPlayerIndex ], + buffer ) ); + trap_Cvar_Set( "ui_reason", "" ); } } else if( Q_stricmp( name, "voteTeamAllowBuild" ) == 0 ) -- cgit