X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fplayerstats.qc;h=17c76461fd3516a72b5355a39f906846cfe9f205;hb=38c4018ae88cc2ee4ace2ee2832ba2421c2079be;hp=e3b1e8461c77e796ff70ddf98f5f8903ea3406cb;hpb=9f436e8cf30c61ab2efffb0cd7285c5b3d1c1462;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index e3b1e8461..17c76461f 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -15,6 +15,17 @@ #include #endif + +#ifdef GAMEQC +REPLICATE(cvar_cl_allow_uid2name, int, "cl_allow_uid2name"); +REPLICATE(cvar_cl_allow_uidranking, bool, "cl_allow_uidranking"); +REPLICATE(cvar_cl_allow_uidtracking, int, "cl_allow_uidtracking"); +#endif + +#ifdef SVQC +REPLICATE_APPLYCHANGE("cl_allow_uidtracking", { PlayerStats_GameReport_AddPlayer(this); }); +#endif + #ifdef SVQC void PlayerStats_Prematch() { @@ -29,8 +40,10 @@ void PlayerStats_GameReport_Reset_All() strfree(PS_GR_OUT_EVL); if (PS_GR_OUT_DB >= 0) + { db_close(PS_GR_OUT_DB); - PlayerStats_GameReport_Init(); + PlayerStats_GameReport_Init(); + } if(PS_GR_OUT_DB < 0) return; @@ -192,9 +205,15 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) { if(CS(p).latency_cnt) { - float latency = (CS(p).latency_sum / CS(p).latency_cnt); + float latency = max(0, CS(p).latency_sum / CS(p).latency_cnt); if(latency) - PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, latency); + { + // if previous average latency exists (player disconnected and reconnected) + // make the average of previous and current average latency + float prev_latency = PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, 0); + float new_latency = !prev_latency ? latency : (prev_latency + latency) / 2; + PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, -prev_latency + new_latency); + } } db_put(PS_GR_OUT_DB, sprintf("%s:_ranked", p.playerstats_id), ftos(CS_CVAR(p).cvar_cl_allow_uidranking)); @@ -259,6 +278,9 @@ void PlayerStats_GameReport(bool finished) void PlayerStats_GameReport_Init() // initiated before InitGameplayMode so that scores are added properly { + serverflags &= ~SERVERFLAG_PLAYERSTATS; + serverflags &= ~SERVERFLAG_PLAYERSTATS_CUSTOM; + if(autocvar_g_playerstats_gamereport_uri == "") { return; } PS_GR_OUT_DB = db_create(); @@ -353,6 +375,7 @@ void PlayerStats_GameReport_Handler(entity fh, entity pass, float status) * i: player index * n: nickname of the player (optional) * t: team ID + * r: player ranking enabled / disabled * e: followed by an event name, a space, and the event count/score * event names can be: * alivetime: total playing time of the player