X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fplayerstats.qc;h=d74cb0f38bb14edda35a797cc094d041524fc7d8;hb=e45c5ab75a12d3379d7a02be5c4f2c4ec0e4fe8a;hp=a15c2b1341588b896c2beae564c3dcbe0ea4fa10;hpb=4c9bdccc1b775ac87601c56f9eb286d3bee06f5a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/playerstats.qc b/qcsrc/server/playerstats.qc index a15c2b134..d74cb0f38 100644 --- a/qcsrc/server/playerstats.qc +++ b/qcsrc/server/playerstats.qc @@ -3,7 +3,6 @@ string teamstats_last; string playerstats_last; string events_last; .float playerstats_addedglobalinfo; -float playerstats_requested; .string playerstats_id; void PlayerStats_Init() @@ -17,7 +16,9 @@ void PlayerStats_Init() playerstats_db = db_create(); if(playerstats_db >= 0) playerstats_waitforme = FALSE; // must wait for it at match end - + + serverflags |= SERVERFLAG_PLAYERSTATS; + PlayerStats_AddEvent(PLAYERSTATS_ALIVETIME); PlayerStats_AddEvent(PLAYERSTATS_WINS); PlayerStats_AddEvent(PLAYERSTATS_MATCHES); @@ -170,7 +171,6 @@ void PlayerStats_TeamScore(float t, string event_id, float value) // TODO: doesn M: map name S: "hostname" of the server C: number of "unpure" cvar changes - W: winning team ID P: player ID of an existing player; this also sets the owner for all following "n", "e" and "t" lines (lower case!) n: nickname of the player (optional) t: team ID @@ -184,12 +184,12 @@ void PlayerStats_TeamScore(float t, string event_id, float value) // TODO: doesn total-: total score of that scoreboard item scoreboard-: end-of-game score of that scoreboard item (can differ in non-team games) achievement-: achievement counters - rank : rank of player - acc--hit: total damage dealt - acc--fired: total damage that all fired projectiles *could* have dealt - acc--cnt-hit: amount of shots that actually hit - acc--cnt-fired: amount of fired shots - acc--frags: amount of frags dealt by weapon + rank : rank of player + acc--hit: total damage dealt + acc--fired: total damage that all fired projectiles *could* have dealt + acc--cnt-hit: amount of shots that actually hit + acc--cnt-fired: amount of fired shots + acc--frags: amount of frags dealt by weapon */ void PlayerStats_ready(entity fh, entity pass, float status) @@ -235,9 +235,7 @@ void PlayerStats_ready(entity fh, entity pass, float status) } } url_fputs(fh, "\n"); - db_close(playerstats_db); - playerstats_db = -1; - url_fclose(fh, PlayerStats_ready, world); + url_fclose(fh); break; case URL_READY_CANREAD: // url_fclose is processing, we got a response for writing the data @@ -246,12 +244,14 @@ void PlayerStats_ready(entity fh, entity pass, float status) while((s = url_fgets(fh))) print(" ", s, "\n"); print("End of response.\n"); - url_fclose(fh, PlayerStats_ready, world); + url_fclose(fh); break; case URL_READY_CLOSED: // url_fclose has finished print("Player stats written\n"); playerstats_waitforme = TRUE; + db_close(playerstats_db); + playerstats_db = -1; break; case URL_READY_ERROR: default: @@ -278,7 +278,7 @@ void PlayerStats_Shutdown() if(uri != "") { playerstats_waitforme = FALSE; - url_fopen(uri, FILE_APPEND, PlayerStats_ready, world); + url_multi_fopen(uri, FILE_APPEND, PlayerStats_ready, world); } else { @@ -344,11 +344,21 @@ void PlayerStats_AddGlobalInfo(entity p) void PlayerStats_EndMatch(float finished) { entity p, winner; - winner = PlayerScore_Sort(score_dummyfield); - FOR_EACH_PLAYER(p) // spectators intentionally not included + winner = PlayerScore_Sort(score_dummyfield); + FOR_EACH_CLIENT(p) // spectators intentionally not included { - PlayerScore_PlayerStats(p); PlayerStats_Accuracy(p); + if(g_arena || g_lms || g_ca) + { + if(p.alivetime <= 0) + continue; + } + else + { + if(p.classname != "player") + continue; + } + PlayerScore_PlayerStats(p); PlayerStats_Event(p, PLAYERSTATS_SCOREBOARD_VALID, 1); if(finished) {