From: Rudolf Polzer Date: Fri, 6 Jul 2012 09:43:14 +0000 (+0200) Subject: track how far completed the game is (var: game_completion_ratio) X-Git-Tag: xonotic-v0.7.0~312^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f9063c4b68b1d31434153999341958fab315bcb8;p=xonotic%2Fxonotic-data.pk3dir.git track how far completed the game is (var: game_completion_ratio) --- diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 2391f37ae..8564e04e9 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 f2ce29701..7c632c1e5 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)