]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
First working version of PlayerInfo retrieval from Xonstats (called on m_init and...
authorJan Behrens <zykure@web.de>
Sun, 18 Aug 2013 11:36:37 +0000 (13:36 +0200)
committerJan Behrens <zykure@web.de>
Sun, 18 Aug 2013 11:36:37 +0000 (13:36 +0200)
qcsrc/common/playerstats.qc
qcsrc/common/playerstats.qh
qcsrc/menu/command/menu_cmd.qc
qcsrc/menu/menu.qc
qcsrc/server/cl_client.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
index 980a4a406a09da7d225b2ea52c9a89804006c402..a29d6960710b8c58602e174280c7ea5b7b2b0cf8 100644 (file)
@@ -64,13 +64,16 @@ void PlayerStats_EndMatch(float finished);
 //// WIP -zykure /////////////////////////////////////////////////////
 
 
-
+const string playerinfo_uri = "http://localhost:6543"; // FIXME
 
 string PlayerInfo_GetItem(entity e, string item_id);
 void PlayerInfo_Init();
-//#ifdef SVQC
+#ifdef SVQC
 void PlayerInfo_Basic(entity p);
-//#endif
+#endif
 #ifdef MENUQC
 void PlayerInfo_Details();
 #endif
+#ifdef CSQC
+//void PlayerInfo_Details();
+#endif
index a8b569cc35dc61d75f4fe94d2c23c06cb4639196..1041c168fb21bd8a00f764a186cd14927854fa3c 100644 (file)
@@ -110,21 +110,12 @@ void GameCommand(string theCommand)
                return;
        }
 
-       if(argv(0) == "debugstats_details")
+       if(argv(0) == "debugstats")
        {
                PlayerInfo_Init();
                PlayerInfo_Details();
                return;
        }
 
-       if(argv(0) == "debugstats_basic")
-       {
-                entity p = spawn();
-                p.playerid = 0;
-               PlayerInfo_Init();
-               PlayerInfo_Basic(p);
-               return;
-       }
-
        print(_("Invalid command. For a list of supported commands, try menu_cmd help.\n"));
 }
index a76efb8e367840cc3737734a781c104556bbe935..c63980d49954e7cc9e866536ce91d278b452d534 100644 (file)
@@ -89,6 +89,8 @@ void m_init()
                        m_hide();
                cvar_set("_menu_initialized", "1");
        }
+
+        PlayerInfo_Details();
 }
 
 float MENU_ASPECT = 1.25; // 1280x1024
@@ -428,7 +430,7 @@ float m_allocatetooltipbox(vector pos)
        v = pos + avoidplus;
        if(m_testtooltipbox(v))
                return TRUE;
-       
+
        // bottom center
        v_x = pos_x - menuTooltipSize_x * 0.5;
        if(m_testtooltipbox(v))
@@ -448,12 +450,12 @@ float m_allocatetooltipbox(vector pos)
        v_x = pos_x - menuTooltipSize_x * 0.5;
        if(m_testtooltipbox(v))
                return TRUE;
-       
+
        // top right
        v_x = pos_x + avoidplus_x;
        if(m_testtooltipbox(v))
                return TRUE;
-       
+
        return FALSE;
 }
 entity m_findtooltipitem(entity root, vector pos)
index c687c4502c33ae7c7ec9c8c69fc95559f6d2a788..f09163e1fc118504d6b6c08792c061871b2773e2 100644 (file)
@@ -167,7 +167,7 @@ void PutObserverInServer (void)
        MUTATOR_CALLHOOK(MakePlayerObserver);
 
        Portal_ClearAll(self);
-       
+
        if(self.alivetime)
        {
                if(!inWarmupStage)
@@ -176,7 +176,7 @@ void PutObserverInServer (void)
        }
 
        if(self.vehicle)
-               vehicles_exit(VHEF_RELESE);         
+               vehicles_exit(VHEF_RELESE);
 
        WaypointSprite_PlayerDead();
 
@@ -198,7 +198,7 @@ void PutObserverInServer (void)
        accuracy_resend(self);
 
        self.spectatortime = time;
-       
+
        self.classname = "observer";
        self.iscreature = FALSE;
        self.teleportable = TELEPORT_SIMPLE;
@@ -552,7 +552,7 @@ void PutClientInServer (void)
 
                //stuffcmd(self, "chase_active 0");
                //stuffcmd(self, "set viewsize $tmpviewsize \n");
-               
+
                target_voicescript_clear(self);
 
                // reset fields the weapons may use
@@ -760,7 +760,7 @@ void ClientKill_Now()
            if(!self.killindicator_teamchange)
            {
             self.vehicle_health = -1;
-            Damage(self, self, self, 1 , DEATH_KILL, self.origin, '0 0 0');            
+            Damage(self, self, self, 1 , DEATH_KILL, self.origin, '0 0 0');
            }
        }
 
@@ -928,7 +928,7 @@ void ClientKill (void)
        if(gameover) return;
        if(self.player_blocked) return;
        if(self.freezetag_frozen) return;
-       
+
        ClientKill_TeamChange(0);
 }
 
@@ -1033,6 +1033,7 @@ void ClientConnect (void)
                player_count = 0;
        }
 
+        PlayerInfo_Basic(self);
        PlayerScore_Attach(self);
        ClientData_Attach();
        accuracy_init(self);
@@ -1271,7 +1272,7 @@ void ClientDisconnect (void)
 
        if(autocvar_sv_eventlog)
                GameLogEcho(strcat(":part:", ftos(self.playerid)));
-               
+
        Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_DISCONNECT, self.netname);
 
        MUTATOR_CALLHOOK(ClientDisconnect);
@@ -1510,7 +1511,7 @@ void player_powerups (void)
                        self.superweapons_finished = 0;
                }
        }
-       
+
        if(autocvar_g_nodepthtestplayers)
                self.effects = self.effects | EF_NODEPTHTEST;
 
@@ -1733,7 +1734,7 @@ void SpectateCopy(entity spectatee) {
        setorigin(self, spectatee.origin);
        setsize(self, spectatee.mins, spectatee.maxs);
        SetZoomState(spectatee.zoomstate);
-    
+
     anticheat_spectatecopy(spectatee);
        self.hud = spectatee.hud;
        if(spectatee.vehicle)
@@ -1749,22 +1750,22 @@ void SpectateCopy(entity spectatee) {
         self.vehicle_reload2 = spectatee.vehicle_reload2;
 
         msg_entity = self;
-        
+
         WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
             WriteAngle(MSG_ONE,  spectatee.v_angle_x);
             WriteAngle(MSG_ONE,  spectatee.v_angle_y);
             WriteAngle(MSG_ONE,  spectatee.v_angle_z);
 
         //WriteByte (MSG_ONE, SVC_SETVIEW);
-        //    WriteEntity(MSG_ONE, self);            
+        //    WriteEntity(MSG_ONE, self);
         //makevectors(spectatee.v_angle);
-        //setorigin(self, spectatee.origin - v_forward * 400 + v_up * 300);*/    
+        //setorigin(self, spectatee.origin - v_forward * 400 + v_up * 300);*/
     }
 }
 
 float SpectateUpdate() {
        if(!self.enemy)
-           return 0;           
+           return 0;
 
        if (self == self.enemy)
                return 0;
@@ -1823,13 +1824,13 @@ entity CA_SpectateNext(entity start) {
        if (start.team == self.team) {
                return start;
        }
-       
+
        other = start;
        // continue from current player
        while(other && other.team != self.team) {
                other = find(other, classname, "player");
        }
-       
+
        if (!other) {
                // restart from begining
                other = find(other, classname, "player");
@@ -1837,7 +1838,7 @@ entity CA_SpectateNext(entity start) {
                        other = find(other, classname, "player");
                }
        }
-       
+
        return other;
 }
 
@@ -1919,7 +1920,7 @@ void ShowRespawnCountdown()
                {
                        self.respawn_countdown = number - 1;
                        if(ceil(self.respawn_time - (time + 0.5)) == number) // only say it if it is the same number even in 0.5s; to prevent overlapping sounds
-                               Send_Notification(NOTIF_ONE, self, MSG_ANNCE, Announcer_PickNumber(number)); 
+                               Send_Notification(NOTIF_ONE, self, MSG_ANNCE, Announcer_PickNumber(number));
                }
        }
 }
@@ -2146,7 +2147,7 @@ void PlayerUseKey()
         vehicles_exit(VHEF_NORMAL);
         return;
        }
-       
+
        // a use key was pressed; call handlers
        MUTATOR_CALLHOOK(PlayerUseKey);
 }
@@ -2308,7 +2309,7 @@ void PlayerPreThink (void)
                                if(frametime)
                                        player_anim();
                                button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USE);
-                               
+
                                if (self.deadflag == DEAD_DYING)
                                {
                                        if(self.respawn_flags & RESPAWN_FORCE)
@@ -2427,10 +2428,10 @@ void PlayerPreThink (void)
 
                if(g_nexball)
                        nexball_setstatus();
-               
+
                // secret status
                secrets_setstatus();
-               
+
                self.dmg_team = max(0, self.dmg_team - autocvar_g_teamdamage_resetspeed * frametime);
 
                //self.angles_y=self.v_angle_y + 90;   // temp
@@ -2590,7 +2591,7 @@ void PlayerPostThink (void)
                        return;         // intermission or finale
                GetPressedKeys();
        }
-       
+
 #ifdef TETRIS
        }
 #endif