From dede7e8c6ddba7d3db78763495cd7fb436e66a2d Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 4 Apr 2016 15:14:43 +1000 Subject: [PATCH] Xonstat: parse current gamemode elo --- qcsrc/client/main.qh | 2 +- qcsrc/common/constants.qh | 4 ++ qcsrc/common/playerstats.qc | 105 +++++++++++++++++------------------ qcsrc/dpdefs/doc.md | 4 ++ qcsrc/server/scores_rules.qc | 1 + 5 files changed, 61 insertions(+), 55 deletions(-) diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 033bfdcf0..09036d12a 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -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]; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 3011cd256..e6e559693 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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); diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index ec2f7cad3..c5e13baf4 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -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; } diff --git a/qcsrc/dpdefs/doc.md b/qcsrc/dpdefs/doc.md index d279ced47..3d96358fd 100644 --- a/qcsrc/dpdefs/doc.md +++ b/qcsrc/dpdefs/doc.md @@ -198,6 +198,10 @@ void SV_PlayerPhysics(); // self void SV_ParseClientCommand(string cmd); +// qcstatus server field +string worldstatus; +.string clientstatus; + ``` # MENUQC diff --git a/qcsrc/server/scores_rules.qc b/qcsrc/server/scores_rules.qc index 48958b158..370d2c1ac 100644 --- a/qcsrc/server/scores_rules.qc +++ b/qcsrc/server/scores_rules.qc @@ -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() { -- 2.39.2