From: Freddy Date: Wed, 27 Sep 2017 21:26:33 +0000 (+0200) Subject: Kick teamkiller mutator: fix playtime being reset on death X-Git-Tag: xonotic-v0.8.5~2425^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fdfc12c69482332948018097af4a39732ca5e369;p=xonotic%2Fxonotic-data.pk3dir.git Kick teamkiller mutator: fix playtime being reset on death --- diff --git a/qcsrc/common/mutators/mutator/kick_teamkiller/sv_kick_teamkiller.qc b/qcsrc/common/mutators/mutator/kick_teamkiller/sv_kick_teamkiller.qc index 5b5f03833..a3b028f1c 100644 --- a/qcsrc/common/mutators/mutator/kick_teamkiller/sv_kick_teamkiller.qc +++ b/qcsrc/common/mutators/mutator/kick_teamkiller/sv_kick_teamkiller.qc @@ -22,7 +22,7 @@ MUTATOR_HOOKFUNCTION(kick_teamkiller, PlayerDies) int teamkills = PlayerScore_Get(attacker, SP_TEAMKILLS); // use the players actual playtime - float playtime = time - attacker.alivetime; + float playtime = time - CS(attacker).startplaytime; // rate is in teamkills/minutes, playtime in seconds if (teamkills >= autocvar_g_kick_teamkiller_lower_limit && teamkills >= autocvar_g_kick_teamkiller_rate*playtime/60.0) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 0aa16c3ba..d7a190cfc 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -652,9 +652,11 @@ void PutPlayerInServer(entity this) PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false; + // player was spectator if (CS(this).killcount == FRAGS_SPECTATOR) { PlayerScore_Clear(this); CS(this).killcount = 0; + CS(this).startplaytime = time; } for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 2282c09cb..8f171fa7d 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -86,6 +86,7 @@ CLASS(Client, Object) ATTRIB(Client, motd_actived_time, float, this.motd_actived_time); ATTRIB(Client, jointime, float, this.jointime); ATTRIB(Client, spectatortime, float, this.spectatortime); + ATTRIB(Client, startplaytime, float, this.startplaytime); ATTRIB(Client, version_nagtime, float, this.version_nagtime); ATTRIB(Client, netname_previous, string, this.netname_previous); ATTRIB(Client, allowed_timeouts, int, this.allowed_timeouts); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 4c3b1d221..a92e5a9ab 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -139,7 +139,8 @@ void checkSpectatorBlock(entity this); float game_completion_ratio; // 0 at start, 1 near end .float winning; -.float jointime; // time of joining +.float jointime; // time of connecting +.float startplaytime; // time of switching from spectator to player .float alivetime; // time of being alive .float motd_actived_time; // used for both motd and campaign_message