diff options
-rw-r--r-- | src/game/g_cmds.c | 17 | ||||
-rw-r--r-- | src/game/g_local.h | 25 | ||||
-rw-r--r-- | src/game/g_main.c | 29 |
3 files changed, 64 insertions, 7 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 3df9adab..16e2ecd1 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1170,6 +1170,7 @@ void Cmd_CallVote_f( gentity_t *ent ) int clientNum = -1; int id = -1; team_t team; + vote_t *v; trap_Argv( 0, cmd, sizeof( cmd ) ); trap_Argv( 1, vote, sizeof( vote ) ); @@ -1181,6 +1182,7 @@ void Cmd_CallVote_f( gentity_t *ent ) team = ent->client->pers.teamSelection; else team = TEAM_NONE; + v = &level.votes[ team ]; if( !g_allowVote.integer ) { @@ -1340,12 +1342,15 @@ void Cmd_CallVote_f( gentity_t *ent ) } else if( !Q_stricmp( vote, "map_restart" ) ) { - strcpy( level.voteString[ team ], vote ); + v->cons = VC_RESTART; + strcpy( level.voteString[ team ], "restart" ); strcpy( level.voteDisplayString[ team ], "Restart current map" ); // map_restart comes with a default delay } else if( !Q_stricmp( vote, "map" ) ) { + mapVotePms_t *p = &v->pms.map; + if( !G_MapExists( arg ) ) { trap_SendServerCommand( ent-g_entities, @@ -1354,8 +1359,10 @@ void Cmd_CallVote_f( gentity_t *ent ) return; } + v->cons = VC_MAP; + p->map = G_CopyString( arg ); Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "%s \"%s\"", vote, arg ); + "map: %s", arg ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Change to map '%s'", arg ); @@ -1363,6 +1370,8 @@ void Cmd_CallVote_f( gentity_t *ent ) } else if( !Q_stricmp( vote, "nextmap" ) ) { + mapVotePms_t *p = &v->pms.map; + if( G_MapExists( g_nextMap.string ) ) { trap_SendServerCommand( ent-g_entities, @@ -1379,8 +1388,10 @@ void Cmd_CallVote_f( gentity_t *ent ) return; } + v->cons = VC_NEXTMAP; + p->map = G_CopyString( arg ); Com_sprintf( level.voteString[ team ], sizeof( level.voteString[ team ] ), - "set g_nextMap \"%s\"", arg ); + "nextmap: %s", arg ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), "Set the next map to '%s'", arg ); diff --git a/src/game/g_local.h b/src/game/g_local.h index 4b47c896..ea12e342 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -434,6 +434,30 @@ struct gclient_s }; +typedef enum +{ + VC_OTHER, + VC_RESTART, + VC_MAP, + VC_NEXTMAP, +} voteCons_t; + +typedef struct +{ + char *map; +} mapVotePms_t; + +typedef union +{ + mapVotePms_t map; +} votePms_t; + +typedef struct +{ + voteCons_t cons; + votePms_t pms; +} vote_t; + typedef struct spawnQueue_s { int clients[ MAX_CLIENTS ]; @@ -562,6 +586,7 @@ typedef struct int warmupModificationCount; // for detecting if g_warmup is changed // voting state + vote_t votes[ NUM_TEAMS ]; int voteThreshold[ NUM_TEAMS ]; // need at least this percent to pass char voteString[ NUM_TEAMS ][ MAX_STRING_CHARS ]; char voteDisplayString[ NUM_TEAMS ][ MAX_STRING_CHARS ]; diff --git a/src/game/g_main.c b/src/game/g_main.c index 5ab04d94..15a4cb69 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -2044,13 +2044,34 @@ FUNCTIONS CALLED EVERY FRAME void G_ExecuteVote( team_t team ) { + vote_t *v = &level.votes[ team ]; + level.voteExecuteTime[ team ] = 0; - trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", - level.voteString[ team ] ) ); + switch( v->cons ) + { + case VC_RESTART: + G_PerformMapRestart(); + break; + case VC_MAP: + case VC_NEXTMAP: + { + mapVotePms_t *p = &v->pms.map; + if( v->cons == VC_NEXTMAP ) + { + trap_Cvar_Set( "g_nextMap", p->map ); + trap_Cvar_Update( &g_nextMap ); + } + else + G_PerformMapChange( p->map ); + BG_Free( p->map ); + break; + } + default: + trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.voteString[ team ] ) ); + } - if( !Q_stricmpn( level.voteString[ team ], "map", 3 ) ) - level.restarted = qtrue; + v->cons = VC_OTHER; } /* |