From: Jan Behrens Date: Sun, 18 Aug 2013 13:55:48 +0000 (+0200) Subject: Make PlayerInfo parser work with current format X-Git-Tag: xonotic-v0.8.0~139^2~1^2~148^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f7b378647f019f7b84461b42b3e44d6317cad814;p=xonotic%2Fxonotic-data.pk3dir.git Make PlayerInfo parser work with current format --- diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index 7d6a713ba..b6654217b 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -503,13 +503,20 @@ void PlayerInfo_AddItem(entity e, string item_id, string val) string PlayerInfo_GetItem(entity e, string item_id) { if(playerinfo_db < 0) - return string_null; + return ""; string key; key = sprintf("#%d:%s", e.playerid, item_id); return db_get(playerinfo_db, key); } +string PlayerInfo_GetItemLocal(string item_id) +{ + entity p = spawn(); + p.playerid = 0; + return PlayerInfo_GetItem(p, item_id); +} + void PlayerInfo_ready(entity fh, entity p, float status) { float n; @@ -521,7 +528,6 @@ void PlayerInfo_ready(entity fh, entity p, float status) { case URL_READY_CANREAD: print("-- Got response from player stats server:\n"); - float in_group = FALSE; string gametype = string_null; while((s = url_fgets(fh))) { @@ -531,10 +537,7 @@ void PlayerInfo_ready(entity fh, entity p, float status) n = tokenizebyseparator(s, " "); // key (value) data if (n == 1) - { - if (argv(0) == "}") - in_group = FALSE; - } + continue; else if (n == 2) { key = argv(0); @@ -542,18 +545,9 @@ void PlayerInfo_ready(entity fh, entity p, float status) } else if (n == 3) { - if (argv(0) == "{") - { - in_group = TRUE; - key = argv(1); - data = argv(2); - } - else - { - key = argv(0); - value = argv(1); - data = argv(2); - } + key = argv(0); + value = argv(1); + data = argv(2); } else if (n == 4) { @@ -591,14 +585,14 @@ void PlayerInfo_ready(entity fh, entity p, float status) else if (key == "i") // xonstats id PlayerInfo_AddItem(p, "_playerid", data); - else if (key == "G" && in_group) + 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); + PlayerInfo_AddItem(p, sprintf("%s/%s", gametype, value), data); } else continue; diff --git a/qcsrc/common/playerstats.qh b/qcsrc/common/playerstats.qh index a29d69607..d7860a03f 100644 --- a/qcsrc/common/playerstats.qh +++ b/qcsrc/common/playerstats.qh @@ -67,6 +67,8 @@ void PlayerStats_EndMatch(float finished); const string playerinfo_uri = "http://localhost:6543"; // FIXME string PlayerInfo_GetItem(entity e, string item_id); +string PlayerInfo_GetItemLocal(string item_id); + void PlayerInfo_Init(); #ifdef SVQC void PlayerInfo_Basic(entity p);