]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make PlayerInfo parser work with current format
authorJan Behrens <zykure@web.de>
Sun, 18 Aug 2013 13:55:48 +0000 (15:55 +0200)
committerJan Behrens <zykure@web.de>
Sun, 18 Aug 2013 13:55:48 +0000 (15:55 +0200)
qcsrc/common/playerstats.qc
qcsrc/common/playerstats.qh

index 7d6a713bad477dca33278e559eb9ba197d199b91..b6654217b5e2aedd25fec02c828ccbb9724e1410 100644 (file)
@@ -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;
index a29d6960710b8c58602e174280c7ea5b7b2b0cf8..d7860a03f52bde5ceef404b45b5336fc8d340731 100644 (file)
@@ -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);