diff options
-rw-r--r-- | src/cgame/cg_draw.c | 36 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 3 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 21 | ||||
-rw-r--r-- | src/game/bg_public.h | 1 | ||||
-rw-r--r-- | src/game/g_cmds.c | 7 | ||||
-rw-r--r-- | src/game/g_combat.c | 4 | ||||
-rw-r--r-- | src/game/g_main.c | 9 | ||||
-rw-r--r-- | src/game/g_spawn.c | 15 |
8 files changed, 63 insertions, 33 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 2cb4e305..f77e44a3 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -3156,6 +3156,41 @@ static qboolean CG_DrawQueue( void ) return qtrue; } + +/* +================= +CG_DrawWarmup +================= +*/ +static void CG_DrawWarmup( void ) +{ + int sec = 0; + int w; + int h; + float size = 0.5f; + char text[ MAX_STRING_CHARS ] = S_COLOR_RED "Warmup Time:"; + + if( !cg.warmupTime ) + return; + + sec = ( cg.warmupTime - cg.time ) / 1000; + + if( sec < 0 ) + return; + + + w = UI_Text_Width( text, size, 0 ); + h = UI_Text_Height( text, size, 0 ); + UI_Text_Paint( 320 - w / 2, 200, size, colorWhite, text, 0, 0, ITEM_TEXTSTYLE_SHADOWED ); + + Com_sprintf( text, sizeof( text ), + "----- %s" S_COLOR_WHITE " -----", + ( sec ) ? va( "^%d%d", sec % 7, sec ) : S_COLOR_GREEN "FIGHT!" ); + + w = UI_Text_Width( text, size, 0 ); + UI_Text_Paint( 320 - w / 2, 200 + 1.5f * h, size, colorWhite, text, 0, 0, ITEM_TEXTSTYLE_SHADOWED ); +} + //================================================================================== /* @@ -3206,6 +3241,7 @@ static void CG_Draw2D( void ) CG_DrawVote( TEAM_NONE ); CG_DrawVote( cg.predictedPlayerState.stats[ STAT_TEAM ] ); + CG_DrawWarmup( ); CG_DrawQueue( ); // don't draw center string if scoreboard is up diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 22d312d9..90e88648 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1059,8 +1059,7 @@ typedef struct int voiceChatBufferOut; // warmup countdown - int warmup; - int warmupCount; + int warmupTime; //========================== diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index cfb3ad59..920858fc 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -137,13 +137,7 @@ static void CG_ParseWarmup( void ) info = CG_ConfigString( CS_WARMUP ); warmup = atoi( info ); - cg.warmupCount = -1; - - if( warmup == 0 && cg.warmup ) - { - } - - cg.warmup = warmup; + cg.warmupTime = warmup; } /* @@ -176,7 +170,7 @@ void CG_SetConfigValues( void ) cgs.humanStage = cgs.humanCredits = cgs.humanNextStageThreshold = 0; cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) ); - cg.warmup = atoi( CG_ConfigString( CS_WARMUP ) ); + cg.warmupTime = atoi( CG_ConfigString( CS_WARMUP ) ); } @@ -414,10 +408,6 @@ static void CG_MapRestart( void ) // we really should clear more parts of cg here and stop sounds - // play the "fight" sound if this is a restart without warmup - if( cg.warmup == 0 ) - CG_CenterPrint( "FIGHT!", 120, GIANTCHAR_WIDTH * 2 ); - trap_Cvar_Set( "cg_thirdPerson", "0" ); } @@ -519,6 +509,13 @@ void CG_Menu( int menu, int arg ) type = DT_COMMAND; break; + case MN_WARMUP: + longMsg = "You must wait until the warmup time is finished " + "before joining a team. "; + shortMsg = "You cannot join a team during warmup."; + type = DT_COMMAND; + break; + case MN_A_TEAMCHANGEBUILDTIMER: longMsg = "You cannot leave the Alien team until your build timer " "has expired."; diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 8d74c18c..30ac860d 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -547,6 +547,7 @@ typedef enum MN_A_TEAMLOCKED, MN_H_TEAMLOCKED, MN_PLAYERLIMIT, + MN_WARMUP, // cmd stuff MN_CMD_CHEAT, diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 8fc9a424..ac88b825 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -560,6 +560,13 @@ void Cmd_Team_f( gentity_t *ent ) else if( oldteam == TEAM_HUMANS ) humans--; + // disallow joining teams during warmup + if( g_doWarmup.integer && ( ( level.warmupTime - level.time ) / 1000 ) > 0 ) + { + G_TriggerMenu( ent - g_entities, MN_WARMUP ); + return; + } + trap_Argv( 1, s, sizeof( s ) ); if( !s[ 0 ] ) diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 2dca0736..7f71066c 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -41,10 +41,6 @@ void AddScore( gentity_t *ent, int score ) if( !ent->client ) return; - // no scoring during pre-match warmup - if( level.warmupTime ) - return; - // make alien and human scores equivalent if ( ent->client->pers.teamSelection == TEAM_ALIENS ) { diff --git a/src/game/g_main.c b/src/game/g_main.c index 5503b4c4..df13a957 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -173,8 +173,8 @@ static cvarTable_t gameCvarTable[ ] = { &g_teamForceBalance, "g_teamForceBalance", "0", CVAR_ARCHIVE }, - { &g_warmup, "g_warmup", "20", CVAR_ARCHIVE, 0, qtrue }, - { &g_doWarmup, "g_doWarmup", "0", 0, 0, qtrue }, + { &g_warmup, "g_warmup", "10", CVAR_ARCHIVE, 0, qtrue }, + { &g_doWarmup, "g_doWarmup", "0", CVAR_ARCHIVE, 0, qtrue }, { &g_logFile, "g_logFile", "games.log", CVAR_ARCHIVE, 0, qfalse }, { &g_logFileSync, "g_logFileSync", "0", CVAR_ARCHIVE, 0, qfalse }, @@ -448,9 +448,6 @@ void G_RegisterCvars( void ) if( cv->vmCvar ) cv->modificationCount = cv->vmCvar->modificationCount; } - - // check some things - level.warmupModificationCount = g_warmup.modificationCount; } /* @@ -1972,7 +1969,7 @@ void CheckExitRules( void ) return; } - if( g_timelimit.integer && !level.warmupTime ) + if( g_timelimit.integer ) { if( level.time - level.startTime >= g_timelimit.integer * 60000 ) { diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index e505a21b..35c29b4e 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -662,19 +662,16 @@ void SP_worldspawn( void ) g_entities[ ENTITYNUM_WORLD ].s.number = ENTITYNUM_WORLD; g_entities[ ENTITYNUM_WORLD ].classname = "worldspawn"; - // see if we want a warmup time - trap_SetConfigstring( CS_WARMUP, "" ); if( g_restarted.integer ) - { trap_Cvar_Set( "g_restarted", "0" ); - level.warmupTime = 0; - } - else if( g_doWarmup.integer ) + + // see if we want a warmup time + trap_SetConfigstring( CS_WARMUP, "-1" ); + if( g_doWarmup.integer ) { - // Turn it on - level.warmupTime = -1; + level.warmupTime = level.time - level.startTime + ( g_warmup.integer * 1000 ); trap_SetConfigstring( CS_WARMUP, va( "%i", level.warmupTime ) ); - G_LogPrintf( "Warmup:\n" ); + G_LogPrintf( "Warmup: %i\n", g_warmup.integer ); } } |