From b1fa74a63a9d0391cd3cb31f10c4f8b7779e1041 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sun, 23 Dec 2018 09:12:12 +0100 Subject: [PATCH] Added fcs_fix_bombtimer for overriding weird/buggy CS 1.5 timer behaviour --- Source/Server/Defs.h | 1 + Source/Server/Timer.c | 96 ++++++++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/Source/Server/Defs.h b/Source/Server/Defs.h index 7e0bb0ea..ec819303 100755 --- a/Source/Server/Defs.h +++ b/Source/Server/Defs.h @@ -49,6 +49,7 @@ var int autocvar_fcs_penalty_pain = -150; var int autocvar_fcs_penalty_kill = -1500; var int autocvar_fcs_maxmoney = 16000; var int autocvar_fcs_fillweapons = FALSE; // This will automatically get ammo for the weapon you buy +var int autocvar_fcs_fix_bombtimer = FALSE; // Mapcycle features var string autocvar_mapcyclefile = "mapcycle.txt"; diff --git a/Source/Server/Timer.c b/Source/Server/Timer.c index e3a25405..71ca6a26 100755 --- a/Source/Server/Timer.c +++ b/Source/Server/Timer.c @@ -31,16 +31,16 @@ Timer_Begin Initiates a new state timer ================= */ -void Timer_Begin( float fTime, float fMode) { - if ( fMode == GAME_FREEZE ) { +void Timer_Begin(float fTime, float fMode) { + if (fMode == GAME_FREEZE) { fGameState = GAME_FREEZE; - } else if ( fMode == GAME_ACTIVE ) { + } else if (fMode == GAME_ACTIVE) { fGameState = GAME_ACTIVE; - } else if ( fMode == GAME_END ) { + } else if (fMode == GAME_END) { fGameState = GAME_END; - } else if ( fMode == GAME_COMMENCING ) { + } else if (fMode == GAME_COMMENCING) { fGameState = GAME_COMMENCING; - } else if ( fMode == GAME_OVER ) { + } else if (fMode == GAME_OVER) { fGameState = GAME_OVER; } @@ -54,86 +54,96 @@ Timer_Update Called once every frame to check the status of things ================= */ -void Timer_Update( void ) { +void Timer_Update(void) { static float fVoxTimer; // This map has been played enough we think - if ( fGameState != GAME_OVER ) { - if ( cvar( "mp_timelimit" ) > 0 ) { - if ( autocvar_sv_voxannounce == TRUE ) { - if ( fVoxTimer > time ) { + if (fGameState != GAME_OVER) { + if (cvar("mp_timelimit") > 0) { + if (autocvar_sv_voxannounce == TRUE) { + if (fVoxTimer > time) { return; } - float fTimeLeft = ( cvar( "mp_timelimit" ) * 60 ) - time; - for ( int i = 0; i <= 10; i++ ) { - if ( rint( fTimeLeft ) == ( i * 60 ) ) { - Vox_Broadcast( sprintf( "%s minutes remaining", Vox_TimeToString( fTimeLeft / 60 ) ) ); + float fTimeLeft = (cvar("mp_timelimit") * 60) - time; + for (int i = 0; i <= 10; i++) { + if (rint(fTimeLeft) == (i * 60)) { + Vox_Broadcast(sprintf("%s minutes remaining", Vox_TimeToString(fTimeLeft / 60))); fVoxTimer = time + 10.0f; } } } - if ( time >= ( cvar( "mp_timelimit" ) * 60 ) ) { - Timer_Begin( 5, GAME_OVER ); + if (time >= (cvar("mp_timelimit") * 60)) { + Timer_Begin(5, GAME_OVER); } } } - if ( ( fGameState == GAME_OVER ) && ( fGameTime < 0 ) ) { - for ( int i = 0; i < iMapCycleCount; i++ ) { - if ( sMapCycle[ i ] == mapname ) { - if ( ( i + 1 ) < iMapCycleCount ) { - localcmd( sprintf( "changelevel %s\n", sMapCycle[ i + 1 ] ) ); + if ((fGameState == GAME_OVER) && (fGameTime < 0)) { + for (int i = 0; i < iMapCycleCount; i++) { + if (sMapCycle[i] == mapname) { + if ((i + 1) < iMapCycleCount) { + localcmd(sprintf("changelevel %s\n", sMapCycle[i + 1])); return; } else { - localcmd( sprintf( "changelevel %s\n", sMapCycle[ 0 ] ) ); + localcmd(sprintf("changelevel %s\n", sMapCycle[0])); } } } } // Okay, this means that timelimit is not the only deciding factor - if ( autocvar_mp_winlimit > 0 && fGameState != GAME_OVER ) { + if (autocvar_mp_winlimit > 0 && fGameState != GAME_OVER) { // It really doesn't matter who won. Do some logging perhaps? - if ( iWon_CT == autocvar_mp_winlimit ) { - Timer_Begin( 5, GAME_OVER ); - } else if ( iWon_T == autocvar_mp_winlimit ) { - Timer_Begin( 5, GAME_OVER ); + if (iWon_CT == autocvar_mp_winlimit) { + Timer_Begin(5, GAME_OVER); + } else if (iWon_T == autocvar_mp_winlimit) { + Timer_Begin(5, GAME_OVER); } } - if ( fGameState == GAME_INACTIVE ) { + if (fGameState == GAME_INACTIVE) { return; } - fGameTime -= frametime; - - if ( fGameState == GAME_COMMENCING || fGameState == GAME_END ) { - if ( fGameTime <= 0 ) { - if ( iWon_T == 0 && iWon_CT == 0 ) { + if (fGameTime > 0) { + fGameTime -= frametime; + } else { + fGameTime = 0; + } + + if (fGameState == GAME_COMMENCING || fGameState == GAME_END) { + if (fGameTime <= 0) { + if (iWon_T == 0 && iWon_CT == 0) { Money_ResetTeamReward(); - Rules_Restart( TRUE ); + Rules_Restart(TRUE); } else { - if ( autocvar_mp_halftime == TRUE && ( autocvar_mp_winlimit / 2 == iRounds ) ) { + if (autocvar_mp_halftime == TRUE && (autocvar_mp_winlimit / 2 == iRounds)) { Money_ResetTeamReward(); Rules_SwitchTeams(); - Rules_Restart( TRUE ); + Rules_Restart(TRUE); } else { - Rules_Restart( FALSE ); + Rules_Restart(FALSE); } } } return; } - if ( ( fGameState == GAME_ACTIVE ) || ( fGameState == GAME_FREEZE ) ) { - if ( fGameTime <= 0 ) { - if ( fGameState == GAME_ACTIVE ) { + if ((fGameState == GAME_ACTIVE) || (fGameState == GAME_FREEZE)) { + if (fGameTime <= 0) { + if (fGameState == GAME_ACTIVE) { + /* 1.5 will make the T's lose if time runs out no matter what */ + if (autocvar_fcs_fix_bombtimer == TRUE) { + if (iBombZones > 0 && iBombPlanted == TRUE) { + return; + } + } Rules_TimeOver(); - Timer_Begin( 5, GAME_END ); // Round is over, 5 seconds til a new round starts + Timer_Begin(5, GAME_END); // Round is over, 5 seconds til a new round starts } else { - Timer_Begin( autocvar_mp_roundtime * 60, GAME_ACTIVE ); // Unfreeze + Timer_Begin(autocvar_mp_roundtime * 60, GAME_ACTIVE); // Unfreeze Radio_StartMessage(); } }