]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/playerstats.qc
2edda5b64a9bbae8b838469232ca7c9e9d078c57
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / playerstats.qc
1 #ifdef SVQC
2
3 float playerstats_db;
4 string teamstats_last;
5 string playerstats_last;
6 string events_last;
7 .float playerstats_addedglobalinfo;
8 .string playerstats_id;
9
10 void PlayerStats_Init() // initiated before InitGameplayMode so that scores are added properly
11 {
12         string uri;
13         playerstats_db = -1;
14         playerstats_waitforme = TRUE;
15         uri = autocvar_g_playerstats_uri;
16         if(uri == "")
17                 return;
18         playerstats_db = db_create();
19         if(playerstats_db >= 0)
20                 playerstats_waitforme = FALSE; // must wait for it at match end
21
22         serverflags |= SERVERFLAG_PLAYERSTATS;
23
24         PlayerStats_AddEvent(PLAYERSTATS_ALIVETIME);
25         PlayerStats_AddEvent(PLAYERSTATS_AVGLATENCY);
26         PlayerStats_AddEvent(PLAYERSTATS_WINS);
27         PlayerStats_AddEvent(PLAYERSTATS_MATCHES);
28         PlayerStats_AddEvent(PLAYERSTATS_JOINS);
29         PlayerStats_AddEvent(PLAYERSTATS_SCOREBOARD_VALID);
30         PlayerStats_AddEvent(PLAYERSTATS_SCOREBOARD_POS);
31         PlayerStats_AddEvent(PLAYERSTATS_RANK);
32
33     // accuracy stats
34     entity w;
35     float i;
36     for(i = WEP_FIRST; i <= WEP_LAST; ++i)
37     {
38         w = get_weaponinfo(i);
39
40         PlayerStats_AddEvent(strcat("acc-", w.netname, "-hit"));
41         PlayerStats_AddEvent(strcat("acc-", w.netname, "-fired"));
42
43         PlayerStats_AddEvent(strcat("acc-", w.netname, "-cnt-hit"));
44         PlayerStats_AddEvent(strcat("acc-", w.netname, "-cnt-fired"));
45
46         PlayerStats_AddEvent(strcat("acc-", w.netname, "-frags"));
47     }
48
49         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_3);
50         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_5);
51         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_10);
52         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_15);
53         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_20);
54         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_25);
55         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_30);
56         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_BOTLIKE);
57         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_FIRSTBLOOD);
58         PlayerStats_AddEvent(PLAYERSTATS_ACHIEVEMENT_FIRSTVICTIM);
59 }
60
61 void PlayerStats_AddPlayer(entity e)
62 {
63         string s;
64
65         if(playerstats_db < 0)
66                 return;
67         if(e.playerstats_id)
68                 return;
69
70         s = string_null;
71         if(e.crypto_idfp != "" && e.cvar_cl_allow_uidtracking == 1)
72                 s = e.crypto_idfp;
73         else if(IS_BOT_CLIENT(e))
74                 s = sprintf("bot#%g#%s", skill, e.cleanname);
75
76         if((s == "") || find(world, playerstats_id, s)) // already have one of the ID - next one can't be tracked then!
77         {
78                 if(IS_BOT_CLIENT(e))
79                         s = sprintf("bot#%d", e.playerid);
80                 else
81                         s = sprintf("player#%d", e.playerid);
82         }
83
84         e.playerstats_id = strzone(s);
85
86         string key;
87         key = sprintf("%s:*", e.playerstats_id);
88
89         string p;
90         p = db_get(playerstats_db, key);
91         if(p == "")
92         {
93                 if(playerstats_last)
94                 {
95                         db_put(playerstats_db, key, playerstats_last);
96                         strunzone(playerstats_last);
97                 }
98                 else
99                         db_put(playerstats_db, key, "#");
100                 playerstats_last = strzone(e.playerstats_id);
101         }
102 }
103
104 void PlayerStats_AddTeam(float t)
105 {
106         if(playerstats_db < 0)
107                 return;
108
109         string key;
110         key = sprintf("%d", t);
111
112         string p;
113         p = db_get(playerstats_db, key);
114         if(p == "")
115         {
116                 if(teamstats_last)
117                 {
118                         db_put(playerstats_db, key, teamstats_last);
119                         strunzone(teamstats_last);
120                 }
121                 else
122                         db_put(playerstats_db, key, "#");
123                 teamstats_last = strzone(key);
124         }
125 }
126
127 void PlayerStats_AddEvent(string event_id)
128 {
129         if(playerstats_db < 0)
130                 return;
131
132         string key;
133         key = sprintf("*:%s", event_id);
134
135         string p;
136         p = db_get(playerstats_db, key);
137         if(p == "")
138         {
139                 if(events_last)
140                 {
141                         db_put(playerstats_db, key, events_last);
142                         strunzone(events_last);
143                 }
144                 else
145                         db_put(playerstats_db, key, "#");
146                 events_last = strzone(event_id);
147         }
148 }
149
150 float PlayerStats_Event(entity e, string event_id, float value)
151 {
152         if((e.playerstats_id == "") || playerstats_db < 0)
153                 return 0;
154
155         string key;
156         float val;
157         key = sprintf("%s:%s", e.playerstats_id, event_id);
158         val = stof(db_get(playerstats_db, key));
159         val += value;
160         db_put(playerstats_db, key, ftos(val));
161         return val;
162 }
163
164 float PlayerStats_TeamScore(float t, string event_id, float value)
165 {
166         if(playerstats_db < 0)
167                 return 0;
168
169         string key;
170         float val;
171         key = sprintf("team#%d:%s", t, event_id);
172         val = stof(db_get(playerstats_db, key));
173         val += value;
174         db_put(playerstats_db, key, ftos(val));
175         return val;
176 }
177
178 /*
179         format spec:
180
181         A collection of lines of the format <key> SPACE <value> NEWLINE, where
182         <key> is always a single character.
183
184         The following keys are defined:
185
186         V: format version (always a fixed number) - this MUST be the first line!
187         #: comment (MUST be ignored by any parser)
188         R: release information on the server
189         G: game type
190         O: mod name (icon request) as in server browser
191         M: map name
192         I: match ID (see "matchid" in g_world.qc
193         S: "hostname" of the server
194         C: number of "unpure" cvar changes
195         U: UDP port number of the server
196         D: duration of the match
197         P: player ID of an existing player; this also sets the owner for all following "n", "e" and "t" lines (lower case!)
198         Q: team number of an existing team (format: team#NN); this also sets the owner for all following "e" lines (lower case!)
199         n: nickname of the player (optional)
200         t: team ID
201         i: player index
202         e: followed by an event name, a space, and the event count/score
203                 event names can be:
204                         alivetime: total playing time of the player
205                         avglatency: average network latency compounded throughout the match
206                         wins: number of games won (can only be set if matches is set)
207                         matches: number of matches played to the end (not aborted by map switch)
208                         joins: number of matches joined (always 1 unless player never played during the match)
209                         scoreboardvalid: set to 1 if the player was there at the end of the match
210                         total-<scoreboardname>: total score of that scoreboard item
211                         scoreboard-<scoreboardname>: end-of-game score of that scoreboard item (can differ in non-team games)
212                         achievement-<achievementname>: achievement counters (their "count" is usually 1 if nonzero at all)
213                         kills-<index>: number of kills against the indexed player
214                         rank <number>: rank of player
215                         acc-<weapon netname>-hit: total damage dealt
216                         acc-<weapon netname>-fired: total damage that all fired projectiles *could* have dealt
217                         acc-<weapon netname>-cnt-hit: amount of shots that actually hit
218                         acc-<weapon netname>-cnt-fired: amount of fired shots
219                         acc-<weapon netname>-frags: amount of frags dealt by weapon
220
221         Response format (not used yet): see https://gist.github.com/4284222
222 */
223
224 void PlayerStats_ready(entity fh, entity pass, float status)
225 {
226         string t, tn;
227         string p, pn;
228         string e, en;
229         string nn, tt;
230         string s;
231
232         switch(status)
233         {
234                 case URL_READY_CANWRITE:
235                         url_fputs(fh, "V 8\n");
236 #ifdef WATERMARK
237                         url_fputs(fh, sprintf("R %s\n", WATERMARK));
238 #endif
239                         url_fputs(fh, sprintf("G %s\n", GetGametype()));
240                         url_fputs(fh, sprintf("O %s\n", modname));
241                         url_fputs(fh, sprintf("M %s\n", GetMapname()));
242                         url_fputs(fh, sprintf("I %s\n", matchid));
243                         url_fputs(fh, sprintf("S %s\n", cvar_string("hostname")));
244                         url_fputs(fh, sprintf("C %d\n", cvar_purechanges_count));
245                         url_fputs(fh, sprintf("U %d\n", cvar("port")));
246                         url_fputs(fh, sprintf("D %f\n", max(0, time - game_starttime)));
247                         if(teamplay)
248                         {
249                                 for(t = teamstats_last; (tn = db_get(playerstats_db, sprintf("%d", stof(t)))) != ""; t = tn)
250                                 {
251                                         url_fputs(fh, sprintf("Q team#%s\n", t));
252                                         for(e = events_last; (en = db_get(playerstats_db, sprintf("*:%s", e))) != ""; e = en)
253                                         {
254                                                 float v;
255                                                 v = stof(db_get(playerstats_db, sprintf("team#%d:%s", stof(t), e)));
256                                                 if(v != 0)
257                                                         url_fputs(fh, sprintf("e %s %g\n", e, v));
258                                         }
259                                 }
260                         }
261                         for(p = playerstats_last; (pn = db_get(playerstats_db, sprintf("%s:*", p))) != ""; p = pn)
262                         {
263                                 url_fputs(fh, sprintf("P %s\n", p));
264                                 nn = db_get(playerstats_db, sprintf("%s:_playerid", p));
265                                 if(nn != "")
266                                         url_fputs(fh, sprintf("i %s\n", nn));
267                                 nn = db_get(playerstats_db, sprintf("%s:_netname", p));
268                                 if(nn != "")
269                                         url_fputs(fh, sprintf("n %s\n", nn));
270                                 if(teamplay)
271                                 {
272                                         tt = db_get(playerstats_db, sprintf("%s:_team", p));
273                                         url_fputs(fh, sprintf("t %s\n", tt));
274                                 }
275                                 for(e = events_last; (en = db_get(playerstats_db, sprintf("*:%s", e))) != ""; e = en)
276                                 {
277                                         float v;
278                                         v = stof(db_get(playerstats_db, sprintf("%s:%s", p, e)));
279                                         if(v != 0)
280                                                 url_fputs(fh, sprintf("e %s %g\n", e, v));
281                                 }
282                         }
283                         url_fputs(fh, "\n");
284                         url_fclose(fh);
285                         break;
286                 case URL_READY_CANREAD:
287                         // url_fclose is processing, we got a response for writing the data
288                         // this must come from HTTP
289                         print("Got response from player stats server:\n");
290                         while((s = url_fgets(fh)))
291                                 print("  ", s, "\n");
292                         print("End of response.\n");
293                         url_fclose(fh);
294                         break;
295                 case URL_READY_CLOSED:
296                         // url_fclose has finished
297                         print("Player stats written\n");
298                         playerstats_waitforme = TRUE;
299                         db_close(playerstats_db);
300                         playerstats_db = -1;
301                         break;
302                 case URL_READY_ERROR:
303                 default:
304                         print("Player stats writing failed: ", ftos(status), "\n");
305                         playerstats_waitforme = TRUE;
306                         if(playerstats_db >= 0)
307                         {
308                                 db_close(playerstats_db);
309                                 playerstats_db = -1;
310                         }
311                         break;
312         }
313 }
314
315 //#NO AUTOCVARS START
316 void PlayerStats_Shutdown()
317 {
318         string uri;
319
320         if(playerstats_db < 0)
321                 return;
322
323         uri = autocvar_g_playerstats_uri;
324         if(uri != "")
325         {
326                 playerstats_waitforme = FALSE;
327                 url_multi_fopen(uri, FILE_APPEND, PlayerStats_ready, world);
328         }
329         else
330         {
331                 playerstats_waitforme = TRUE;
332                 db_close(playerstats_db);
333                 playerstats_db = -1;
334         }
335 }
336 //#NO AUTOCVARS END
337
338 void PlayerStats_Accuracy(entity p)
339 {
340     entity a, w;
341     a = p.accuracy;
342     float i;
343
344     for(i = WEP_FIRST; i <= WEP_LAST; ++i)
345     {
346         w = get_weaponinfo(i);
347
348         PlayerStats_Event(p, strcat("acc-", w.netname, "-hit"), a.(accuracy_hit[i-1]));
349         PlayerStats_Event(p, strcat("acc-", w.netname, "-fired"), a.(accuracy_fired[i-1]));
350
351         PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-hit"), a.(accuracy_cnt_hit[i-1]));
352         PlayerStats_Event(p, strcat("acc-", w.netname, "-cnt-fired"), a.(accuracy_cnt_fired[i-1]));
353
354         PlayerStats_Event(p, strcat("acc-", w.netname, "-frags"), a.(accuracy_frags[i-1]));
355     }
356     //backtrace(strcat("adding player stat accuracy for ", p.netname, ".\n"));
357 }
358
359 void PlayerStats_AddGlobalInfo(entity p)
360 {
361         if(playerstats_db < 0)
362                 return;
363         if((p.playerstats_id == "") || playerstats_db < 0)
364                 return;
365         p.playerstats_addedglobalinfo = TRUE;
366
367         // add global info!
368         if(p.alivetime)
369         {
370                 PlayerStats_Event(p, PLAYERSTATS_ALIVETIME, time - p.alivetime);
371                 p.alivetime = 0;
372         }
373
374         db_put(playerstats_db, sprintf("%s:_playerid", p.playerstats_id), ftos(p.playerid));
375
376         if(p.cvar_cl_allow_uid2name == 1 || IS_BOT_CLIENT(p))
377                 db_put(playerstats_db, sprintf("%s:_netname", p.playerstats_id), p.netname);
378
379         if(teamplay)
380                 db_put(playerstats_db, sprintf("%s:_team", p.playerstats_id), ftos(p.team));
381
382         if(stof(db_get(playerstats_db, sprintf("%d:%s", p.playerstats_id, PLAYERSTATS_ALIVETIME))) > 0)
383                 PlayerStats_Event(p, PLAYERSTATS_JOINS, 1);
384
385         PlayerStats_Accuracy(p);
386
387         if(IS_REAL_CLIENT(p))
388         {
389                 if(p.latency_cnt)
390                 {
391                         float latency = (p.latency_sum / p.latency_cnt);
392                         if(latency) { PlayerStats_Event(p, PLAYERSTATS_AVGLATENCY, latency); }
393                 }
394         }
395
396         strunzone(p.playerstats_id);
397         p.playerstats_id = string_null;
398 }
399
400 .float scoreboard_pos;
401 void PlayerStats_EndMatch(float finished)
402 {
403         entity p;
404         PlayerScore_Sort(score_dummyfield, 0, 0, 0);
405         PlayerScore_Sort(scoreboard_pos, 1, 1, 1);
406         if(teamplay)
407                 PlayerScore_TeamStats();
408         FOR_EACH_CLIENT(p)
409         {
410                 // add personal score rank
411                 PlayerStats_Event(p, PLAYERSTATS_RANK, p.score_dummyfield);
412
413                 if(!p.scoreboard_pos)
414                         continue;
415
416                 // scoreboard is valid!
417                 PlayerStats_Event(p, PLAYERSTATS_SCOREBOARD_VALID, 1);
418
419                 // add scoreboard position
420                 PlayerStats_Event(p, PLAYERSTATS_SCOREBOARD_POS, p.scoreboard_pos);
421
422                 // add scoreboard data
423                 PlayerScore_PlayerStats(p);
424
425                 // if the match ended normally, add winning info
426                 if(finished)
427                 {
428                         PlayerStats_Event(p, PLAYERSTATS_WINS, p.winning);
429                         PlayerStats_Event(p, PLAYERSTATS_MATCHES, 1);
430                 }
431         }
432 }
433
434 #endif // SVQC
435
436
437
438
439 //// WIP -zykure /////////////////////////////////////////////////////
440
441
442
443
444 float playerinfo_db;
445 string playerinfo_last;
446 string playerinfo_events_last;
447 .float playerid;
448
449 void PlayerInfo_AddPlayer(entity e)
450 {
451         if(playerinfo_db < 0)
452                 return;
453
454         string key;
455         key = sprintf("#%d:*", e.playerid); // TODO: use hashkey instead?
456
457         string p;
458         p = db_get(playerinfo_db, key);
459         if(p == "")
460         {
461                 if(playerinfo_last)
462                 {
463                         db_put(playerinfo_db, key, playerinfo_last);
464                         strunzone(playerinfo_last);
465                 }
466                 else
467                         db_put(playerinfo_db, key, "#");
468                 playerinfo_last = strzone(ftos(e.playerid));
469                 print("  Added player ", ftos(e.playerid), " to playerinfo_db\n");//DEBUG//
470         }
471 }
472
473 void PlayerInfo_AddItem(entity e, string item_id, string val)
474 {
475         if(playerinfo_db < 0)
476                 return;
477
478         string key;
479         key = sprintf("*:%s", item_id);
480
481         string p;
482         p = db_get(playerinfo_db, key);
483         if(p == "")
484         {
485                 if(playerinfo_events_last)
486                 {
487                         db_put(playerinfo_db, key, playerinfo_events_last);
488                         strunzone(playerinfo_events_last);
489                 }
490                 else
491                         db_put(playerinfo_db, key, "#");
492                 playerinfo_events_last = strzone(item_id);
493         }
494
495         key = sprintf("#%d:%s", e.playerid, item_id);
496         db_put(playerinfo_db, key, val);
497         print("  Added item ", key, "=", val, " to playerinfo_db\n");//DEBUG//
498 }
499
500 string PlayerInfo_GetItem(entity e, string item_id)
501 {
502         if(playerinfo_db < 0)
503                 return "";
504
505         string key;
506         key = sprintf("#%d:%s",  e.playerid, item_id);
507         return db_get(playerinfo_db, key);
508 }
509
510 string PlayerInfo_GetItemLocal(string item_id)
511 {
512         entity p = spawn();
513         p.playerid = 0;
514         return PlayerInfo_GetItem(p, item_id);
515 }
516
517 void PlayerInfo_ready(entity fh, entity p, float status)
518 {
519         float n;
520         string s;
521
522         PlayerInfo_AddPlayer(p);
523
524         switch(status)
525         {
526                 case URL_READY_CANWRITE:
527                         print("-- Sending data to player stats server\n");
528                         url_fputs(fh, "V 1\n");
529 #ifdef WATERMARK
530                         url_fputs(fh, sprintf("R %s\n", WATERMARK));
531 #endif
532 #ifdef MENUQC
533                         url_fputs(fh, sprintf("l %s\n", cvar_string("_menu_prvm_language"))); // language
534                         url_fputs(fh, sprintf("c %s\n", cvar_string("_menu_prvm_country"))); // country
535                         url_fputs(fh, sprintf("g %s\n", cvar_string("_menu_prvm_gender"))); // gender
536                         url_fputs(fh, sprintf("n %s\n", cvar_string("_cl_name"))); // name
537                         url_fputs(fh, sprintf("m %s %s\n", cvar_string("_cl_playermodel"), cvar_string("_cl_playerskin"))); // model/skin
538 #endif
539                         url_fputs(fh, "\n");
540                         url_fclose(fh);
541                         break;
542                 case URL_READY_CANREAD:
543                         print("-- Got response from player stats server:\n");
544                         string gametype = string_null;
545                         while((s = url_fgets(fh)))
546                         {
547                                 print("  ", s, "\n");
548
549                                 string key = string_null, value = string_null, data = string_null;
550
551                                 n = tokenizebyseparator(s, " "); // key (value) data
552                                 if (n == 1)
553                                         continue;
554                                 else if (n == 2)
555                                 {
556                                         key = argv(0);
557                                         data = argv(1);
558                                 }
559                                 else if (n == 3)
560                                 {
561                                         key = argv(0);
562                                         value = argv(1);
563                                         data = argv(2);
564                                 }
565                                 else if (n == 4)
566                                 {
567                                         key = argv(0);
568                                         value = argv(1);
569                                         data = argv(2);
570                                 }
571                                 else
572                                         continue;
573
574                                 if (data == "")
575                                         continue;
576
577                                 if (key == "#")
578                                         // comment
579                                         continue;
580                                 else if (key == "V")
581                                         // version
582                                         PlayerInfo_AddItem(p, "_version", data);
583                                 else if (key == "R")
584                                         // watermark
585                                         PlayerInfo_AddItem(p, "_release", data);
586                                 else if (key == "T")
587                                         // timestamp
588                                         PlayerInfo_AddItem(p, "_time", data);
589                                 else if (key == "S")
590                                         // stats page URL
591                                         PlayerInfo_AddItem(p, "_statsurl", data);
592                                 else if (key == "P")
593                                         // player hashkey
594                                         PlayerInfo_AddItem(p, "_hashkey", data);
595                                 else if (key == "n")
596                                         // player nick
597                                         PlayerInfo_AddItem(p, "_playernick", data);
598                                 else if (key == "i")
599                                         // xonstats id
600                                         PlayerInfo_AddItem(p, "_playerid", data);
601                                 else if (key == "G")
602                                         gametype = data;
603                                 else if (key == "e" && value != "")
604                                 {
605                                         if (gametype == "")
606                                                 PlayerInfo_AddItem(p, value, data);
607                                         else
608                                                 PlayerInfo_AddItem(p, sprintf("%s/%s", gametype, value), data);
609                                 }
610                                 else
611                                         continue;
612                         }
613                         print("-- End of response.\n");
614                         url_fclose(fh);
615                         break;
616                 case URL_READY_CLOSED:
617                         // url_fclose has finished
618                         print("Player stats synchronized with server\n");
619                         break;
620                 case URL_READY_ERROR:
621                 default:
622                         print("Receiving player stats failed: ", ftos(status), "\n");
623                         break;
624         }
625 }
626
627 void PlayerInfo_Init()
628 {
629         playerinfo_db = -1;
630         playerinfo_db = db_create();
631 }
632
633 #ifdef SVQC
634 void PlayerInfo_Basic(entity p)
635 {
636         print("-- Getting basic PlayerInfo for player ",ftos(p.playerid)," (SVQC)\n");
637
638         if(playerinfo_db < 0)
639                 return;
640
641         string uri;
642         uri = autocvar_g_playerinfo_uri;
643         if(uri != "" && p.crypto_idfp != "")
644         {
645                 uri = strcat(uri, "/elo/", uri_escape(p.crypto_idfp));
646                 print("Retrieving playerstats from URL: ", uri, "\n");
647                 url_single_fopen(uri, FILE_READ, PlayerInfo_ready, p);
648         }
649 }
650 #endif
651
652 #ifdef MENUQC
653 void PlayerInfo_Details()
654 {
655         print("-- Getting detailed PlayerInfo for local player (MENUQC)\n");
656
657         if(playerinfo_db < 0)
658                 return;
659
660         string uri;
661         uri = autocvar_g_playerinfo_uri; // FIXME
662         if(uri != "" && crypto_getmyidstatus(0) > 0)
663         {
664                 uri = strcat(uri, "/player/", uri_escape(crypto_getmyidfp(0)));
665                 print("Retrieving playerstats from URL: ", uri, "\n");
666                 url_single_fopen(uri, FILE_APPEND, PlayerInfo_ready, world);
667         }
668 }
669 #endif
670
671 #ifdef CSQC
672 /*
673  * FIXME - crypto_* builtin functions missing in CSQC (csprogsdefs.qc:885)
674 void PlayerInfo_Details()
675 {
676         print("-- Getting detailed PlayerInfo for local player (CSQC)\n");
677
678         if(playerinfo_db < 0)
679                 return;
680
681         string uri;
682         uri = autocvar_g_playerinfo_uri; // FIXME
683         if(uri != "" && crypto_getmyidstatus(0) > 0)
684         {
685                 entity p = spawn();
686                 p.playerid = 0; // TODO: okay to use -1 for local player? or does local player already has an entity in MENUQC?
687                 uri = strcat(uri, "/player/", uri_escape(crypto_getmyidfp(0)));
688                 print("Retrieving playerstats from URL: ", uri, "\n");
689                 url_single_fopen(uri, FILE_READ, PlayerInfo_ready, p);
690         }
691 }
692 */
693 #endif