Merge branch 'master' into martin-t/globals
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / playerstats.qh
1 #pragma once
2
3 #ifdef SVQC
4 //float PS_PM_IN_DB = -1;   // playerstats_prematch_in_db      // db for info COLLECTED at the beginning of a match
5 int PS_GR_OUT_DB = -1;  // playerstats_gamereport_out_db   // db of info SENT at the end of a match
6 //float PS_GR_IN_DB = -1;   // playerstats_gamereport_in_db    // db for info COLLECTED at the end of a match
7 int PS_B_IN_DB = -1;    // playerstats_playerbasic_in_db   // db for info COLLECTED for basic player info (ELO)
8 #endif
9
10 #ifdef MENUQC
11 int PS_D_IN_DB = -1; // playerstats_playerdetail_in_db  // db for info COLLECTED for detailed player profile display
12 #endif
13
14 #ifdef SVQC
15 //string PS_PM_IN_EVL;   // playerstats_prematch_in_events_last
16 string PS_GR_OUT_TL;   // playerstats_gamereport_out_teams_last
17 string PS_GR_OUT_PL;   // playerstats_gamereport_out_players_last
18 string PS_GR_OUT_EVL;  // playerstats_gamereport_out_events_last
19 //string PS_GR_IN_PL;    // playerstats_gamereport_in_players_last
20 //string PS_GR_IN_EVL;   // playerstats_gamereport_in_events_last
21 //string PS_B_IN_PL;     // playerstats_playerbasic_in_players_last
22 //string PS_B_IN_EVL;    // playerstats_playerbasic_in_events_last
23 #endif
24
25 #ifdef MENUQC
26 string PS_D_IN_EVL; // playerstats_playerdetail_in_events_last
27 #endif
28
29 #ifdef SVQC
30
31 // time the player was alive and kicking
32 const string PLAYERSTATS_ALIVETIME  = "alivetime";
33 const string PLAYERSTATS_AVGLATENCY = "avglatency";
34 const string PLAYERSTATS_WINS = "wins";
35 const string PLAYERSTATS_MATCHES = "matches";
36 const string PLAYERSTATS_JOINS = "joins";
37 const string PLAYERSTATS_SCOREBOARD_VALID = "scoreboardvalid";
38 const string PLAYERSTATS_RANK = "rank";
39 const string PLAYERSTATS_SCOREBOARD_POS = "scoreboardpos";
40
41 const string PLAYERSTATS_TOTAL = "total-";
42 const string PLAYERSTATS_SCOREBOARD = "scoreboard-";
43 const string PLAYERSTATS_ANTICHEAT = "anticheat-";
44
45 const string PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_3 = "achievement-kill-spree-3";
46 const string PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_5 = "achievement-kill-spree-5";
47 const string PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_10 = "achievement-kill-spree-10";
48 const string PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_15 = "achievement-kill-spree-15";
49 const string PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_20 = "achievement-kill-spree-20";
50 const string PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_25 = "achievement-kill-spree-25";
51 const string PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_30 = "achievement-kill-spree-30";
52 const string PLAYERSTATS_ACHIEVEMENT_BOTLIKE = "achievement-botlike";
53 const string PLAYERSTATS_ACHIEVEMENT_FIRSTBLOOD = "achievement-firstblood";
54 const string PLAYERSTATS_ACHIEVEMENT_FIRSTVICTIM = "achievement-firstvictim";
55
56 // delay map switch until this is set
57 bool PlayerStats_GameReport_DelayMapVote;
58
59 // call at initialization
60 void PlayerStats_GameReport_Init();
61
62 // add a new player
63 void PlayerStats_GameReport_AddPlayer(entity e);
64
65 // add a new team
66 void PlayerStats_GameReport_AddTeam(float t);
67
68 // add a new event
69 void PlayerStats_GameReport_AddEvent(string event_id);
70
71 // call on each event to track, or at player disconnect OR match end for "global stuff"
72 #define PlayerStats_GameReport_Event_Player(ent, eventid, val) PlayerStats_GameReport_Event(ent.playerstats_id, eventid, val)
73 #define PlayerStats_GameReport_Event_Team(team, eventid, val) PlayerStats_GameReport_Event(sprintf("team#%d", team), eventid, val)
74 float PlayerStats_GameReport_Event(string prefix, string event_id, float value);
75
76 void PlayerStats_GameReport_Accuracy(entity p);
77
78 // call this whenever a player leaves
79 void PlayerStats_GameReport_FinalizePlayer(entity p);
80
81 // call this at the end of the match
82 void PlayerStats_GameReport(float finished);
83
84 void PlayerStats_GameReport_Handler(entity fh, entity pass, float status);
85
86 .string playerstats_id;
87
88 //string autocvar_g_playerstats_uri;
89
90 string autocvar_g_playerstats_gamereport_ladder;
91 string autocvar_g_playerstats_gamereport_uri = "http://stats.xonotic.org/stats/submit";
92
93 const float PS_B_STATUS_ERROR = -2;
94 const float PS_B_STATUS_IDLE = -1;
95 const float PS_B_STATUS_WAITING = 0;
96 const float PS_B_STATUS_RECEIVED = 1;
97 const float PS_B_STATUS_UPDATING = 2;
98 .float playerstats_basicstatus;
99 string autocvar_g_playerstats_playerbasic_uri = "http://stats.xonotic.org";
100
101 void PlayerStats_PlayerBasic(entity joiningplayer, float newrequest);
102 void PlayerStats_PlayerBasic_CheckUpdate(entity joiningplayer);
103 void PlayerStats_PlayerBasic_Handler(entity fh, entity p, float status);
104 #endif //SVQC
105 #ifdef MENUQC
106 float PS_D_NEXTUPDATETIME;
107 float PS_D_LASTGAMECOUNT;
108 const float PS_D_STATUS_ERROR = -2;
109 const float PS_D_STATUS_IDLE = -1;
110 const float PS_D_STATUS_WAITING = 0;
111 const float PS_D_STATUS_RECEIVED = 1;
112 float PlayerStats_PlayerDetail_Status = PS_D_STATUS_IDLE;
113 string autocvar_g_playerstats_playerdetail_uri = "http://stats.xonotic.org/player/me";
114 float autocvar_g_playerstats_playerdetail_autoupdatetime = 1800; // automatically update every 30 minutes anyway
115 void PlayerStats_PlayerDetail();
116 void PlayerStats_PlayerDetail_CheckUpdate();
117 void PlayerStats_PlayerDetail_Handler(entity fh, entity p, float status);
118 #endif