]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/playerstats.qc
Merge remote branch 'origin/master' into fruitiex/animations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / playerstats.qc
index 467c0d862cfd9ee914ab3c09cc8875425f033260..7f20b92454db5084718d1ca79df4a4cef219fb76 100644 (file)
@@ -57,6 +57,8 @@ void PlayerStats_AddPlayer(entity e)
 {
        if(playerstats_db < 0)
                return;
+       if(e.playerstats_id)
+               return;
 
        if(e.crypto_idfp != "" && e.cvar_cl_allow_uidtracking == 1)
                e.playerstats_id = strzone(e.crypto_idfp);
@@ -175,7 +177,7 @@ void PlayerStats_Sent_URI_Get_Callback(float id, float status, string data)
        S: "hostname" of the server
        C: number of "unpure" cvar changes
     W: winning team ID
-       P: player ID of an existing player; this also sets the owner for all following "n" and "e" lines (lower case!)
+       P: player ID of an existing player; this also sets the owner for all following "n", "e" and "t" lines (lower case!)
        n: nickname of the player (optional)
     t: team ID
        e: followed by an event name, a space, and the event count/score
@@ -224,15 +226,19 @@ void PlayerStats_Shutdown()
                bufstr_set(b, i++, sprintf("T %s.%06d", strftime(FALSE, "%s"), floor(random() * 1000000)));
                bufstr_set(b, i++, sprintf("G %s", GetGametype()));
                bufstr_set(b, i++, sprintf("M %s", GetMapname()));
+               bufstr_set(b, i++, sprintf("I %s", matchid));
                bufstr_set(b, i++, sprintf("S %s", cvar_string("hostname")));
                bufstr_set(b, i++, sprintf("C %d", cvar_purechanges_count));
         for(p = playerstats_last; (pn = db_get(playerstats_db, sprintf("%s:*", p))) != ""; p = pn)
         {
             bufstr_set(b, i++, sprintf("P %s", p));
+            nn = db_get(playerstats_db, sprintf("%s:_playerid", p));
+            if(nn != "")
+                bufstr_set(b, i++, sprintf("i %s", nn));
             nn = db_get(playerstats_db, sprintf("%s:_netname", p));
             if(nn != "")
                 bufstr_set(b, i++, sprintf("n %s", nn));
-            if(teams_matter)
+            if(teamplay)
             {
                 tt = db_get(playerstats_db, sprintf("%s:_team", p));
                 bufstr_set(b, i++, sprintf("t %s", tt));
@@ -278,18 +284,20 @@ void PlayerStats_AddGlobalInfo(entity p)
 
        // add global info!
        if(p.alivetime)
+       {
                PlayerStats_Event(p, PLAYERSTATS_ALIVETIME, time - p.alivetime);
+               p.alivetime = 0;
+       }
 
-       if(p.alivetime)
-               PlayerStats_Event(p, PLAYERSTATS_ALIVETIME, time - p.alivetime);
+       db_put(playerstats_db, sprintf("%s:_netname", p.playerstats_id), ftos(p.playerid));
        
        if(p.cvar_cl_allow_uid2name == 1 || clienttype(p) == CLIENTTYPE_BOT)
                db_put(playerstats_db, sprintf("%s:_netname", p.playerstats_id), p.netname);
 
-    if(teams_matter)
+    if(teamplay)
                db_put(playerstats_db, sprintf("%s:_team", p.playerstats_id), ftos(p.team));
 
-       if(p.alivetime > 0)
+       if(stof(db_get(playerstats_db, sprintf("%d:%s", p.playerstats_id, PLAYERSTATS_ALIVETIME))) > 0)
                PlayerStats_Event(p, PLAYERSTATS_JOINS, 1);
 
        strunzone(p.playerstats_id);
@@ -306,13 +314,13 @@ void PlayerStats_Accuracy(entity p)
     {
         w = get_weaponinfo(i);
 
-        PlayerStats_Event(p, strcat("acc-", w.netname, "-hit"), a.accuracy_hit[i]);
-        PlayerStats_Event(p, strcat("acc-", w.netname, "-fired"), a.accuracy_fired[i]);
+        PlayerStats_Event(p, strcat("acc-", w.netname, "-hit"), a.accuracy_hit[i-1]);
+        PlayerStats_Event(p, strcat("acc-", w.netname, "-fired"), a.accuracy_fired[i-1]);
 
-        PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-hit"), a.accuracy_cnt_hit[i]);
-        PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-fired"), a.accuracy_cnt_fired[i]);
+        PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-hit"), a.accuracy_cnt_hit[i-1]);
+        PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-fired"), a.accuracy_cnt_fired[i-1]);
 
-        PlayerStats_Event(p, strcat("acc-", w.netname, "-frags"), a.accuracy_frags[i]);
+        PlayerStats_Event(p, strcat("acc-", w.netname, "-frags"), a.accuracy_frags[i-1]);
     }
 }
 
@@ -320,7 +328,7 @@ void PlayerStats_EndMatch(float finished)
 {
        entity p, winner;
     winner = PlayerScore_Sort(score_dummyfield);
-       FOR_EACH_PLAYER(p)
+       FOR_EACH_PLAYER(p) // spectators intentionally not included
        {
                PlayerScore_PlayerStats(p);
                PlayerStats_Accuracy(p);