From bc3474c3db6073a2454471fd805012a28ade8a5f Mon Sep 17 00:00:00 2001 From: div0 Date: Tue, 12 Aug 2008 05:31:43 +0000 Subject: [PATCH] if at the end of the qualifying time, 2/3 of the players (3 or more) had completed a lap - start the race instead of ending the match git-svn-id: svn://svn.icculus.org/nexuiz/trunk@4114 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/g_world.qc | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index e192a8945..bdf09a080 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -1513,6 +1513,43 @@ float WinningCondition_Race(float fraglimit) return wc; } +void ReadyRestart(); +float WinningCondition_QualifyingThenRace() +{ + float wc; + wc = WinningCondition_Scores(0); + + // NEVER initiate overtime + if(wc == WINNING_YES || wc == WINNING_STARTOVERTIME) + // do NOT support equality when the laps are all raced! + { + float totalplayers; + float playerswithlaps; + entity head; + totalplayers = playerswithlaps = 0; + FOR_EACH_PLAYER(head) + { + ++totalplayers; + if(PlayerScore_Add(head, SP_RACE_FASTEST, 0)) + ++playerswithlaps; + } + + // at least 2/3 of the players have completed a lap: start the RACE + // otherwise, the players should end the qualifying on their own + if(totalplayers >= 3) + if(playerswithlaps >= totalplayers * 2 / 3) + { + checkrules_overtimeend = 0; + ReadyRestart(); + return WINNING_NEVER; + } + + return WINNING_YES; + } + + return wc; +} + float WinningCondition_RanOutOfSpawns() { entity head; @@ -1658,6 +1695,10 @@ void CheckRules_World() { status = WinningCondition_Race(fraglimit); } + else if(g_race && g_race_qualifying == 2 && timelimit > 0) + { + status = WinningCondition_QualifyingThenRace(); + } else if(g_assault) { status = WinningCondition_Assault(); // TODO remove this? -- 2.39.2