]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kick teamkiller mutator: fix playtime being reset on death
authorFreddy <schro.sb@gmail.com>
Wed, 27 Sep 2017 21:26:33 +0000 (23:26 +0200)
committerFreddy <schro.sb@gmail.com>
Wed, 27 Sep 2017 21:26:33 +0000 (23:26 +0200)
qcsrc/common/mutators/mutator/kick_teamkiller/sv_kick_teamkiller.qc
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/defs.qh

index 5b5f03833b4f847efcd60c5e020dea56d040a219..a3b028f1c6c0c9573b8eb7b10765a34a4db9b71c 100644 (file)
@@ -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)
index 0aa16c3baf299f3d30f8f5af0e1e4a649d1d21a7..d7a190cfca3ab8c17014aa1957fbb2602022a46a 100644 (file)
@@ -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)
index 2282c09cbb1cafd54e3a667886430b98b554c342..8f171fa7da4b8172df1c04c249300e0f9738721b 100644 (file)
@@ -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);
index 4c3b1d221ea4ae73be7f0ff7cc7b7ed5d7b9000f..a92e5a9ab9f00a3ff1a69a78833ec457c070c8f9 100644 (file)
@@ -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