diff --git a/Source/Server/Defs.h b/Source/Server/Defs.h index 37d48e96..7137e34d 100755 --- a/Source/Server/Defs.h +++ b/Source/Server/Defs.h @@ -87,6 +87,7 @@ enum { .float fProgressBar; // Match specific fields +int iRounds; int iWon_T; int iWon_CT; int iAlivePlayers_T; diff --git a/Source/Server/Main.c b/Source/Server/Main.c index f8f93625..cd2bb716 100755 --- a/Source/Server/Main.c +++ b/Source/Server/Main.c @@ -130,6 +130,9 @@ void StartFrame( void ) { } else if ( iInGamePlayers == 0 ) { fGameState = GAME_INACTIVE; fGameTime = 0; + iWon_T = 0; + iWon_CT = 0; + iRounds = 0; } else { Timer_Update(); // Timer that happens once players have started joining } diff --git a/Source/Server/Rules.c b/Source/Server/Rules.c index ef9f62ab..0ed4bb50 100755 --- a/Source/Server/Rules.c +++ b/Source/Server/Rules.c @@ -95,7 +95,7 @@ Rules_Restart Loop through all ents and handle them ================= */ -void Rules_Restart( void ) { +void Rules_Restart( int iWipe ) { iHostagesRescued = 0; entity eOld = self; @@ -104,13 +104,18 @@ void Rules_Restart( void ) { for ( entity eFind = world; ( eFind = find( eFind, classname, "player" ) ); ) { self = eFind; - if ( self.health > 0 ) { + if ( self.health > 0 && iWipe == FALSE ) { Spawn_RespawnClient( self.team ); } else { + Spawn_MakeSpectator(); Spawn_CreateClient( self.fCharModel ); } - Money_GiveTeamReward(); + if ( iWipe == FALSE ) { + Money_GiveTeamReward(); + } else { + self.fMoney = autocvar_mp_startmoney; + } } // Clear the corpses/items @@ -202,10 +207,12 @@ void Rules_RoundOver( int iTeamWon, int iMoneyReward, float fSilent ) { Radio_BroadcastMessage( RADIO_ROUNDDRAW ); } } + Money_QueTeamReward( iTeamWon, iMoneyReward ); Timer_Begin( 5, GAME_END); // Round is over, 5 seconds til a new round starts iBombPlanted = 0; + iRounds++; } /* @@ -228,6 +235,40 @@ void Rules_TimeOver( void ) { } } +/* +================= +Rules_SwitchTeams + +Happens rarely +================= +*/ +void Rules_SwitchTeams( void ) { + int iCTW, iTW; + + for ( entity eFind = world; ( eFind = find( eFind, classname, "player" ) ); ) { + if ( eFind.team == TEAM_CT ) { + eFind.team = TEAM_T; + eFind.fCharModel -= 4; + } else if ( eFind.team == TEAM_T ) { + eFind.team = TEAM_CT; + eFind.fCharModel += 4; + } + forceinfokey( eFind, "*team", ftos( eFind.team ) ); + } + + iCTW = iWon_CT; + iTW = iWon_T; + + iWon_T = iCTW; + iWon_CT = iTW; + + iCTW = iAlivePlayers_CT; + iTW = iAlivePlayers_T; + + iAlivePlayers_CT = iTW; + iAlivePlayers_T = iCTW; +} + /* ================= SPAWN: info_map_parameters diff --git a/Source/Server/Timer.c b/Source/Server/Timer.c index 73ccd453..de3bfa12 100755 --- a/Source/Server/Timer.c +++ b/Source/Server/Timer.c @@ -87,6 +87,7 @@ void Timer_Update( void ) { // Okay, this means that timelimit is not the only deciding factor 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 ) { @@ -102,7 +103,18 @@ void Timer_Update( void ) { if ( fGameState == GAME_COMMENCING || fGameState == GAME_END ) { if ( fGameTime <= 0 ) { - Rules_Restart(); + if ( iWon_T == 0 && iWon_CT == 0 ) { + Money_ResetTeamReward(); + Rules_Restart( TRUE ); + } else { + if ( autocvar_mp_halftime == TRUE && ( autocvar_mp_winlimit / 2 == iRounds ) ) { + Money_ResetTeamReward(); + Rules_SwitchTeams(); + Rules_Restart( TRUE ); + } else { + Rules_Restart( FALSE ); + } + } } return; } diff --git a/freecs/progs.dat b/freecs/progs.dat index 9c6ce37b..57193b15 100755 Binary files a/freecs/progs.dat and b/freecs/progs.dat differ