#include "playerstats.qh"
+
#if defined(CSQC)
#elif defined(MENUQC)
#elif defined(SVQC)
- #include "constants.qh"
- #include "util.qh"
- #include <common/weapons/_all.qh>
- #include <server/client.qh>
- #include "../server/anticheat.qh"
- #include <common/stats.qh>
- #include <server/intermission.qh>
- #include "../server/scores.qh"
+ #include <common/constants.qh>
+ #include <common/stats.qh>
+ #include <common/util.qh>
+ #include <common/weapons/_all.qh>
+ #include <server/anticheat.qh>
+ #include <server/client.qh>
+ #include <server/intermission.qh>
+ #include <server/scores.qh>
+ #include <server/weapons/accuracy.qh>
#include <server/world.qh>
- #include "../server/weapons/accuracy.qh"
+#endif
+
+
+#ifdef GAMEQC
+REPLICATE(cvar_cl_allow_uid2name, int, "cl_allow_uid2name");
+REPLICATE(cvar_cl_allow_uidranking, bool, "cl_allow_uidranking");
+REPLICATE(cvar_cl_allow_uidtracking, int, "cl_allow_uidtracking");
+#endif
+
+#ifdef SVQC
+REPLICATE_APPLYCHANGE("cl_allow_uidtracking", { PlayerStats_GameReport_AddPlayer(this); });
#endif
#ifdef SVQC
//foobar
}
+// Deletes current playerstats DB, creates a new one and fully initializes it
+void PlayerStats_GameReport_Reset_All()
+{
+ strfree(PS_GR_OUT_TL);
+ strfree(PS_GR_OUT_PL);
+ strfree(PS_GR_OUT_EVL);
+
+ if (PS_GR_OUT_DB >= 0)
+ {
+ db_close(PS_GR_OUT_DB);
+ PlayerStats_GameReport_Init();
+ }
+ if(PS_GR_OUT_DB < 0)
+ return;
+
+ for (int i = 0; i < 16; i++)
+ if (teamscorekeepers[i])
+ PlayerStats_GameReport_AddTeam(i + 1);
+ FOREACH_CLIENT(true, {
+ // NOTE Adding back a player we are applying any cl_allow_uidtracking change
+ // usually only possible by reconnecting to the server
+ strfree(it.playerstats_id);
+ PlayerStats_GameReport_AddEvent(sprintf("kills-%d", it.playerid));
+ PlayerStats_GameReport_AddPlayer(it);
+ });
+ FOREACH(Scores, true, {
+ string label = scores_label(it);
+ if (label == "")
+ continue;
+ PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
+ PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
+ });
+ for(int i = 0; i < MAX_TEAMSCORE; ++i)
+ {
+ string label = teamscores_label(i);
+ if (label == "")
+ continue;
+ PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
+ PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
+ }
+}
+
void PlayerStats_GameReport_AddPlayer(entity e)
{
if((PS_GR_OUT_DB < 0) || (e.playerstats_id)) { return; }
// set up player identification
string s = "";
- if((e.crypto_idfp != "") && (CS(e).cvar_cl_allow_uidtracking == 1))
+ if((e.crypto_idfp != "") && (CS_CVAR(e).cvar_cl_allow_uidtracking == 1))
{ s = e.crypto_idfp; }
else if(IS_BOT_CLIENT(e))
{ s = sprintf("bot#%g#%s", skill, e.cleanname); }
db_put(PS_GR_OUT_DB, sprintf("%s:_playerid", p.playerstats_id), ftos(p.playerid));
- if(CS(p).cvar_cl_allow_uid2name == 1 || IS_BOT_CLIENT(p))
+ if(CS_CVAR(p).cvar_cl_allow_uid2name == 1 || IS_BOT_CLIENT(p))
db_put(PS_GR_OUT_DB, sprintf("%s:_netname", p.playerstats_id), playername(p.netname, p.team, false));
if(teamplay)
{
if(CS(p).latency_cnt)
{
- float latency = (CS(p).latency_sum / CS(p).latency_cnt);
+ float latency = max(0, CS(p).latency_sum / CS(p).latency_cnt);
if(latency)
- PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, latency);
+ {
+ // if previous average latency exists (player disconnected and reconnected)
+ // make the average of previous and current average latency
+ float prev_latency = PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, 0);
+ float new_latency = !prev_latency ? latency : (prev_latency + latency) / 2;
+ PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, -prev_latency + new_latency);
+ }
}
- db_put(PS_GR_OUT_DB, sprintf("%s:_ranked", p.playerstats_id), ftos(CS(p).cvar_cl_allow_uidranking));
+ db_put(PS_GR_OUT_DB, sprintf("%s:_ranked", p.playerstats_id), ftos(CS_CVAR(p).cvar_cl_allow_uidranking));
}
strfree(p.playerstats_id);
{
if(PS_GR_OUT_DB < 0) { return; }
- PlayerScore_Sort(score_dummyfield, 0, 0, 0);
- PlayerScore_Sort(scoreboard_pos, 1, 1, 1);
+ PlayerScore_Sort(score_dummyfield, 0, false, false);
+ PlayerScore_Sort(scoreboard_pos, 1, true, true);
if(teamplay) { PlayerScore_TeamStats(); }
FOREACH_CLIENT(true, {
void PlayerStats_GameReport_Init() // initiated before InitGameplayMode so that scores are added properly
{
+ serverflags &= ~SERVERFLAG_PLAYERSTATS;
+ serverflags &= ~SERVERFLAG_PLAYERSTATS_CUSTOM;
+
if(autocvar_g_playerstats_gamereport_uri == "") { return; }
PS_GR_OUT_DB = db_create();
PlayerStats_GameReport_DelayMapVote = true;
serverflags |= SERVERFLAG_PLAYERSTATS;
+ if(autocvar_g_playerstats_gamereport_uri != cvar_defstring("g_playerstats_gamereport_uri"))
+ {
+ serverflags |= SERVERFLAG_PLAYERSTATS_CUSTOM;
+ }
PlayerStats_GameReport_AddEvent(PLAYERSTATS_ALIVETIME);
PlayerStats_GameReport_AddEvent(PLAYERSTATS_AVGLATENCY);
* i: player index
* n: nickname of the player (optional)
* t: team ID
+ * r: player ranking enabled / disabled
* e: followed by an event name, a space, and the event count/score
* event names can be:
* alivetime: total playing time of the player
#endif
url_fputs(fh, sprintf("l %s\n", cvar_string("_menu_prvm_language"))); // language
url_fputs(fh, sprintf("c %s\n", cvar_string("_menu_prvm_country"))); // country
- url_fputs(fh, sprintf("g %s\n", cvar_string("_cl_gender"))); // gender
url_fputs(fh, sprintf("n %s\n", cvar_string("_cl_name"))); // name
url_fputs(fh, sprintf("m %s %s\n", cvar_string("_cl_playermodel"), cvar_string("_cl_playerskin"))); // model/skin
*/url_fputs(fh, "\n");
#endif
url_fputs(fh, sprintf("l %s\n", cvar_string("_menu_prvm_language"))); // language
//url_fputs(fh, sprintf("c %s\n", cvar_string("_cl_country"))); // country
- //url_fputs(fh, sprintf("g %s\n", cvar_string("_cl_gender"))); // gender
url_fputs(fh, sprintf("n %s\n", cvar_string("_cl_name"))); // name
url_fputs(fh, sprintf("m %s %s\n", cvar_string("_cl_playermodel"), cvar_string("_cl_playerskin"))); // model/skin
url_fputs(fh, "\n");
#ifdef MENUQC
url_fputs(fh, sprintf("l %s\n", cvar_string("_menu_prvm_language"))); // language
url_fputs(fh, sprintf("c %s\n", cvar_string("_menu_prvm_country"))); // country
- url_fputs(fh, sprintf("g %s\n", cvar_string("_cl_gender"))); // gender
url_fputs(fh, sprintf("n %s\n", cvar_string("_cl_name"))); // name
url_fputs(fh, sprintf("m %s %s\n", cvar_string("_cl_playermodel"), cvar_string("_cl_playerskin"))); // model/skin
#endif