]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/playerstats.qc
Document r parameter in player stats specs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / playerstats.qc
index e648d29538ce507d0f524b780bc941b5e4e6f09f..f8aa2b514059884b5ed43020a06740ece5a6fc37 100644 (file)
        #include <server/world.qh>
 #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;
 
@@ -42,8 +55,7 @@ void PlayerStats_GameReport_Reset_All()
                // usually only possible by reconnecting to the server
                strfree(it.playerstats_id);
                PlayerStats_GameReport_AddEvent(sprintf("kills-%d", it.playerid));
-               if (IS_BOT_CLIENT(it) || CS_CVAR(it).cvar_cl_allow_uidtracking)
-                       PlayerStats_GameReport_AddPlayer(it);
+               PlayerStats_GameReport_AddPlayer(it);
        });
        FOREACH(Scores, true, {
                string label = scores_label(it);
@@ -193,7 +205,7 @@ 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);
                }
@@ -269,6 +281,10 @@ void PlayerStats_GameReport_Init() // initiated before InitGameplayMode so that
                PlayerStats_GameReport_DelayMapVote = true;
 
                serverflags |= SERVERFLAG_PLAYERSTATS;
+               if(autocvar_g_playerstats_gamereport_uri != cvar_defstring("g_playerstats_gamereport_uri"))
+               {
+                       serverflags |= SERVERFLAG_PLAYERSTATS_CUSTOM;
+               }
 
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_ALIVETIME);
                PlayerStats_GameReport_AddEvent(PLAYERSTATS_AVGLATENCY);
@@ -350,6 +366,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