]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Xonstat: parse current gamemode elo
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 4 Apr 2016 05:14:43 +0000 (15:14 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 4 Apr 2016 05:14:43 +0000 (15:14 +1000)
qcsrc/client/main.qh
qcsrc/common/constants.qh
qcsrc/common/playerstats.qc
qcsrc/dpdefs/doc.md
qcsrc/server/scores_rules.qc

index 033bfdcf0d9b80d838050822f78673bffd593f1e..09036d12a22b65b8ce5c340b027c0a1272f7fbb1 100644 (file)
@@ -42,7 +42,7 @@ void LoadMenuSkinValues();
 // --------------------------------------------------------------------------
 // Scoreboard stuff
 
-const int MAX_HUD_FIELDS = 64;
+const int MAX_HUD_FIELDS = MAX_SCORE;
 
 PlayerScoreField hud_field[MAX_HUD_FIELDS + 1];
 float hud_size[MAX_HUD_FIELDS + 1];
index 3011cd256c8253e585f8f926601dfa9281827bf5..e6e5596939dc38b5f7269af128c87fe4d0820ace 100644 (file)
@@ -173,6 +173,10 @@ REGISTER_SP(DEATHS);
 REGISTER_SP(SUICIDES);
 REGISTER_SP(FRAGS);
 
+REGISTER_SP(ELO);
+
+// TODO: move to common mutators
+
 REGISTER_SP(RACE_TIME);
 REGISTER_SP(RACE_LAPS);
 REGISTER_SP(RACE_FASTEST);
index ec2f7cad3ddf3d4fc9ca8ae568824b37d216854c..c5e13baf4c59caef5e7c90ad6399ff43cd1e6289 100644 (file)
@@ -508,63 +508,60 @@ void PlayerStats_PlayerBasic_Handler(entity fh, entity p, float status)
 
                case URL_READY_CANREAD:
                {
-                       string s = "";
-                       LOG_TRACE("-- Got response from player stats server:\n");
-                       //string gametype = string_null;
-                       while((s = url_fgets(fh)))
-                       {
-                               LOG_TRACE("  ", s, "\n");
-                               /*
+                       string gt = string_null;
+                       for (string s = ""; (s = url_fgets(fh)); ) {
+                               int n = tokenizebyseparator(s, " "); // key value? data
+                               if (n == 1) continue;
                                string key = "", value = "", data = "";
-
-                               n = tokenizebyseparator(s, " "); // key (value) data
-                               if (n == 1)
-                                       continue;
-                               else if (n == 2)
-                               {
-                               key = argv(0);
-                               data = argv(1);
+                               if (n == 2) {
+                    key = argv(0);
+                    data = argv(1);
+                               } else if (n >= 3) {
+                    key = argv(0);
+                    value = argv(1);
+                    data = argv(2);
                                }
-                               else if (n >= 3)
-                               {
-                                                               key = argv(0);
-                                                               value = argv(1);
-                                                               data = argv(2);
-                               }
-
-                               if (data == "")
-                               continue;
-
-                               if (key == "#")
-                               continue;
-                               else if (key == "V")
-                               PlayerInfo_AddItem(p, "_version", data);
-                               else if (key == "R")
-                               PlayerInfo_AddItem(p, "_release", data);
-                               else if (key == "T")
-                               PlayerInfo_AddItem(p, "_time", data);
-                               else if (key == "S")
-                               PlayerInfo_AddItem(p, "_statsurl", data);
-                               else if (key == "P")
-                               PlayerInfo_AddItem(p, "_hashkey", data);
-                               else if (key == "n")
-                               PlayerInfo_AddItem(p, "_playernick", data);
-                               else if (key == "i")
-                               PlayerInfo_AddItem(p, "_playerid", data);
-                               else if (key == "G")
-                               gametype = data;
-                               else if (key == "e" && value != "")
-                               {
-                               if (gametype == "")
-                               PlayerInfo_AddItem(p, value, data);
-                               else
-                               PlayerInfo_AddItem(p, sprintf("%s/%s", gametype, value), data);
-                               }
-                               else
-                               continue;
-                               */
+                switch (key) {
+                    case "V":
+                        // PlayerInfo_AddItem(p, "_version", data);
+                        break;
+                    case "R":
+                        // PlayerInfo_AddItem(p, "_release", data);
+                        break;
+                    case "T":
+                        // PlayerInfo_AddItem(p, "_time", data);
+                        break;
+                    case "S":
+                        // PlayerInfo_AddItem(p, "_statsurl", data);
+                        break;
+                    case "P":
+                        // PlayerInfo_AddItem(p, "_hashkey", data);
+                        break;
+                    case "n":
+                        // PlayerInfo_AddItem(p, "_playernick", data);
+                        break;
+                    case "i":
+                        // PlayerInfo_AddItem(p, "_playerid", data);
+                        // p.xonstat_id = stof(data);
+                        break;
+                    case "G":
+                        gt = data;
+                        break;
+                    case "e":
+                        LOG_TRACE("G: ", gt);
+                        LOG_TRACE("e: ", data);
+                        if (gt == GetGametype()) {
+                            float e = stof(data);
+                            PlayerScore_Add(p, SP_ELO, e);
+                        }
+                        if (gt == "") {
+                            // PlayerInfo_AddItem(p, value, data);
+                        } else {
+                            // PlayerInfo_AddItem(p, sprintf("%s/%s", gt, value), data);
+                        }
+                        break;
+                }
                        }
-                       LOG_TRACE("-- End of response.\n");
                        url_fclose(fh);
                        break;
                }
index d279ced478d0c48df33ffc0cc8e43837687c73ee..3d96358fdbdbe42118ea126b131eb736f50a88b6 100644 (file)
@@ -198,6 +198,10 @@ void SV_PlayerPhysics();
 //   self
 void SV_ParseClientCommand(string cmd);
 
+// qcstatus server field
+string worldstatus;
+.string clientstatus;
+
 ```
 
 # MENUQC
index 48958b158f7ee9c251c0f9e4607c9766e5680fda..370d2c1ac842145636ddeca50e1b8974319894a6 100644 (file)
@@ -34,6 +34,7 @@ void ScoreRules_basics(float teams, float sprio, float stprio, float score_enabl
 
        ScoreInfo_SetLabel_PlayerScore(SP_DMG, "damage", 0);
        ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "damagetaken", SFL_LOWER_IS_BETTER);
+       ScoreInfo_SetLabel_PlayerScore(SP_ELO, "elo", 0);
 }
 void ScoreRules_basics_end()
 {