]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/playerstats.qc
First working version of PlayerInfo retrieval from Xonstats (called on m_init and...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / playerstats.qc
index d03b51a7b3429d4b93d3df45707b7bb0e5fec0ef..7d6a713bad477dca33278e559eb9ba197d199b91 100644 (file)
@@ -623,43 +623,66 @@ void PlayerInfo_Init()
        playerinfo_db = db_create();
 }
 
-//#ifdef SVQC
+#ifdef SVQC
 void PlayerInfo_Basic(entity p)
 {
+        print("-- Getting basic PlayerInfo for player ",ftos(p.playerid)," (SVQC)\n");
+
        if(playerinfo_db < 0)
                return;
 
-        string uri, hash;
-       //uri = "http://stats.xonotic.org"; // FIXME!
-        uri = "http://localhost:6543";
-        hash = "pQBWJrkNzHCMtndkICJacPENGctTNR59rmFS4x91FFo=";
-
-       if(uri != "")
+        string uri;
+        uri = playerinfo_uri; // FIXME
+       if(uri != "" && p.crypto_idfp != "")
        {
-               uri = strcat(uri, "/elo/", uri_escape(hash));
+               uri = strcat(uri, "/elo/", uri_escape(p.crypto_idfp));
                print("Retrieving playerstats from URL: ", uri, "\n");
                url_single_fopen(uri, FILE_READ, PlayerInfo_ready, p);
        }
 }
-//#endif
+#endif
 
 #ifdef MENUQC
 void PlayerInfo_Details()
 {
+        print("-- Getting detailed PlayerInfo for local player (MENUQC)\n");
+
        if(playerinfo_db < 0)
                return;
 
         string uri;
-       //uri = "http://stats.xonotic.org"; // FIXME!
-        uri = "http://localhost:6543";
+        uri = playerinfo_uri; // FIXME
+       if(uri != "" && crypto_getmyidstatus(0) > 0)
+       {
+                entity p = spawn();
+                p.playerid = 0; // TODO: okay to use 0 for local player? or does local player already has an entity in MENUQC?
+               uri = strcat(uri, "/player/", uri_escape(crypto_getmyidfp(0)));
+               print("Retrieving playerstats from URL: ", uri, "\n");
+               url_single_fopen(uri, FILE_READ, PlayerInfo_ready, p);
+       }
+}
+#endif
 
-       if(uri != "")
+#ifdef CSQC
+/*
+ * FIXME - crypto_* builtin functions missing in CSQC (csprogsdefs.qc:885)
+void PlayerInfo_Details()
+{
+        print("-- Getting detailed PlayerInfo for local player (CSQC)\n");
+
+       if(playerinfo_db < 0)
+               return;
+
+        string uri;
+        uri = playerinfo_uri; // FIXME
+       if(uri != "" && crypto_getmyidstatus(0) > 0)
        {
                 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");
+                p.playerid = 0; // TODO: okay to use -1 for local player? or does local player already has an entity in MENUQC?
+               uri = strcat(uri, "/player/", uri_escape(crypto_getmyidfp(0)));
                print("Retrieving playerstats from URL: ", uri, "\n");
                url_single_fopen(uri, FILE_READ, PlayerInfo_ready, p);
        }
 }
+*/
 #endif