]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add basic and detailed playerinfo retrieve functions (hashkeys won't work in menuqc?)
authorJan Behrens <zykure@web.de>
Sat, 17 Aug 2013 10:44:17 +0000 (12:44 +0200)
committerJan Behrens <zykure@web.de>
Sat, 17 Aug 2013 10:44:17 +0000 (12:44 +0200)
qcsrc/client/Main.qc
qcsrc/common/playerstats.qc
qcsrc/common/playerstats.qh
qcsrc/menu/command/menu_cmd.qc

index f6339ac38fe95cf8c24e4daafc156870b0433802..9eddcb353b32f45cf818c6e175484126955c05e6 100644 (file)
@@ -156,12 +156,6 @@ void CSQC_Init(void)
        hud_configure_prev = -1;
 
        draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
-
-
-       //// WIP - zykure
-
-       PlayerInfo_Init();
-       PlayerInfo_Retrieve(self.owner);
 }
 
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
index 7389a61cab3e4638c40b325aba71c072c21b5f04..d03b51a7b3429d4b93d3df45707b7bb0e5fec0ef 100644 (file)
@@ -436,7 +436,12 @@ void PlayerStats_EndMatch(float finished)
 #endif // SVQC
 
 
-//// WIP -zykure
+
+
+//// WIP -zykure /////////////////////////////////////////////////////
+
+
+
 
 float playerinfo_db;
 string playerinfo_last;
@@ -445,15 +450,11 @@ string playerinfo_events_last;
 
 void PlayerInfo_AddPlayer(entity e)
 {
-       string s;
-
        if(playerinfo_db < 0)
                return;
 
-       s = sprintf("#%d", e.playerid);
-
        string key;
-       key = sprintf("%s:*", s);
+       key = sprintf("#%d:*", e.playerid); // TODO: use hashkey instead?
 
        string p;
        p = db_get(playerinfo_db, key);
@@ -467,7 +468,7 @@ void PlayerInfo_AddPlayer(entity e)
                else
                        db_put(playerinfo_db, key, "#");
                playerinfo_last = strzone(ftos(e.playerid));
-               print("  Added player ", s, " to playerinfo_db\n");
+               print("  Added player ", ftos(e.playerid), " to playerinfo_db\n");//DEBUG//
        }
 }
 
@@ -496,7 +497,7 @@ void PlayerInfo_AddItem(entity e, string item_id, string val)
        key = sprintf("#%d:%s", e.playerid, item_id);
        db_put(playerinfo_db, key, val);
 
-       print("Added event ", key, "=", val, " to playerinfo_db\n");
+       print("  Added item ", key, "=", val, " to playerinfo_db\n");//DEBUG//
 }
 
 string PlayerInfo_GetItem(entity e, string item_id)
@@ -622,34 +623,43 @@ void PlayerInfo_Init()
        playerinfo_db = db_create();
 }
 
-void PlayerInfo_Retrieve(entity p)
+//#ifdef SVQC
+void PlayerInfo_Basic(entity p)
 {
        if(playerinfo_db < 0)
                return;
 
-       string uri = "", hash = "";
-/*
-#ifdef SVQC
-       uri = autocvar_g_playerstats_uri;
-       hash = p.crypto_idfp;
-#endif
-#ifdef CSQC
-       uri = "http://stats.xonotic.org"; // FIXME!
-       hash = "pQBWJrkNzHCMtndkICJacPENGctTNR59rmFS4x91FFo="; // FIXME!
-#endif
-*/
+        string uri, hash;
+       //uri = "http://stats.xonotic.org"; // FIXME!
+        uri = "http://localhost:6543";
+        hash = "pQBWJrkNzHCMtndkICJacPENGctTNR59rmFS4x91FFo=";
+
+       if(uri != "")
+       {
+               uri = strcat(uri, "/elo/", uri_escape(hash));
+               print("Retrieving playerstats from URL: ", uri, "\n");
+               url_single_fopen(uri, FILE_READ, PlayerInfo_ready, p);
+       }
+}
+//#endif
+
 #ifdef MENUQC
-       uri = "http://stats.xonotic.org"; // FIXME!
-       hash = crypto_getmyidfp(0);
-       if (hash == "")
-               print("Error: could not retrive hashkey for player (status: ", ftos(crypto_getmyidstatus(0)), ")\n");
-#endif
-       print("Checking for player hashkey: <", hash, "> (playerid=", ftos(p.playerid), ")\n");
+void PlayerInfo_Details()
+{
+       if(playerinfo_db < 0)
+               return;
 
-       if(uri != "" && hash != "")
+        string uri;
+       //uri = "http://stats.xonotic.org"; // FIXME!
+        uri = "http://localhost:6543";
+
+       if(uri != "")
        {
-               uri = strcat(uri, "/hashkey/", uri_escape(hash));
+                entity p = spawn();
+                p.playerid = -1; // TODO: okay to use -1 for local player? or does local player already has an entity in MENUQC?
+               uri = strcat(uri, "/player/me");
                print("Retrieving playerstats from URL: ", uri, "\n");
                url_single_fopen(uri, FILE_READ, PlayerInfo_ready, p);
        }
 }
+#endif
index dcc916e1e011bb84eaac004edba8a1cb0c95fae3..980a4a406a09da7d225b2ea52c9a89804006c402 100644 (file)
@@ -59,8 +59,18 @@ void PlayerStats_EndMatch(float finished);
 #endif //SVQC
 
 
-//// WIP -zykure
+
+
+//// WIP -zykure /////////////////////////////////////////////////////
+
+
+
 
 string PlayerInfo_GetItem(entity e, string item_id);
 void PlayerInfo_Init();
-void PlayerInfo_Retrieve(entity p);
+//#ifdef SVQC
+void PlayerInfo_Basic(entity p);
+//#endif
+#ifdef MENUQC
+void PlayerInfo_Details();
+#endif
index b7810875664ca1216286090531dafdbd822f7267..a8b569cc35dc61d75f4fe94d2c23c06cb4639196 100644 (file)
@@ -110,12 +110,19 @@ void GameCommand(string theCommand)
                return;
        }
 
-       if(argv(0) == "debugstats")
+       if(argv(0) == "debugstats_details")
        {
-               entity p = spawn();
-               //p.crypto_idfp = "pQBWJrkNzHCMtndkICJacPENGctTNR59rmFS4x91FFo="; // Antibody's hashkey
                PlayerInfo_Init();
-               PlayerInfo_Retrieve(p);
+               PlayerInfo_Details();
+               return;
+       }
+
+       if(argv(0) == "debugstats_basic")
+       {
+                entity p = spawn();
+                p.playerid = 0;
+               PlayerInfo_Init();
+               PlayerInfo_Basic(p);
                return;
        }