From f9063c4b68b1d31434153999341958fab315bcb8 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 6 Jul 2012 11:43:14 +0200 Subject: [PATCH] track how far completed the game is (var: game_completion_ratio) --- qcsrc/server/defs.qh | 3 ++- qcsrc/server/g_world.qc | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 2391f37ae3..8564e04e9d 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -277,6 +277,7 @@ float blockSpectators; //if set, new or existing spectators or observers will be .float spectatortime; //point in time since the client is spectating or observing void checkSpectatorBlock(); +float game_completion_ratio; // 0 at start, 1 near end .float winning; .float jointime; // time of joining .float alivetime; // time of being alive @@ -673,4 +674,4 @@ string modname; #define MISSILE_IS_CONFUSABLE(m) ((m.missile_flags & MIF_GUIDED_CONFUSABLE) ? TRUE : FALSE) #define MISSILE_IS_GUIDED(m) ((m.missile_flags & MIF_GUIDED_ALL) ? TRUE : FALSE) -#define MISSILE_IS_TRACKING(m) ((m.missile_flags & MIF_GUIDED_TRACKING) ? TRUE : FALSE) \ No newline at end of file +#define MISSILE_IS_TRACKING(m) ((m.missile_flags & MIF_GUIDED_TRACKING) ? TRUE : FALSE) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index f2ce297010..7c632c1e50 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1979,6 +1979,8 @@ float WinningCondition_Scores(float limit, float leadlimit) limitreached = (limitreached || leadlimitreached); } + game_completion_ratio = max(game_completion_ratio, bound(0, WinningConditionHelper_topscore / max(1, limit), 1)); + return GetWinningCode( WinningConditionHelper_topscore && limitreached, WinningConditionHelper_equality @@ -2167,6 +2169,11 @@ void CheckRules_World() float wantovertime; wantovertime = 0; + if(timelimit > game_starttime) + game_completion_ratio = (time - game_starttime) / (timelimit - game_starttime); + else + game_completion_ratio = 0; + if(checkrules_suddendeathend) { if(!checkrules_suddendeathwarning) -- 2.39.2