]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port accuracy to ClientState
authorMario <mario@smbclan.net>
Mon, 17 Jul 2017 23:20:39 +0000 (09:20 +1000)
committerMario <mario@smbclan.net>
Mon, 17 Jul 2017 23:20:39 +0000 (09:20 +1000)
qcsrc/common/playerstats.qc
qcsrc/common/state.qc
qcsrc/server/client.qh
qcsrc/server/player.qc
qcsrc/server/weapons/accuracy.qc

index 913e46362352c19ec5d1e05d9012944ae23e1cef..4165115d8d85202c67eb4d78fd1475bd9536fbce 100644 (file)
@@ -108,7 +108,7 @@ float PlayerStats_GameReport_Event(string prefix, string event_id, float value)
 void PlayerStats_GameReport_Accuracy(entity p)
 {
        #define ACCMAC(suffix, field) \
-               PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", it.netname, suffix), p.accuracy.(field[i-1]));
+               PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", it.netname, suffix), CS(p).accuracy.(field[i-1]));
        FOREACH(Weapons, it != WEP_Null, {
                ACCMAC("hit", accuracy_hit)
                ACCMAC("fired", accuracy_fired)
index a47188422ebea5d562e3e090445ee0b216cb0877..9774bd5b9eb1a8a5bc7ba25eaf873e983174e2b4 100644 (file)
@@ -69,6 +69,7 @@ void PlayerScore_Detach(entity this);
 
 void ClientState_detach(entity this)
 {
+    accuracy_free(this); // TODO: needs to be before CS() is deleted!
        delete(CS(this));
        this._cs = NULL;
 
@@ -80,7 +81,6 @@ void ClientState_detach(entity this)
     anticheat_report_to_eventlog(this);
     playerdemo_shutdown(this);
     entcs_detach(this);
-    accuracy_free(this);
     ClientData_Detach(this);
     PlayerScore_Detach(this);
 }
index f0c7a3bef10410430b5892f57d036bf729410f45..752862cad9952f1230b4b49086af45a695c48214 100644 (file)
@@ -101,6 +101,7 @@ CLASS(Client, Object)
     ATTRIB(Client, latency_time, float, this.latency_time);
     ATTRIB(Client, v_angle_old, vector, this.v_angle_old);
     ATTRIB(Client, model_randomizer, float, this.model_randomizer);
+    ATTRIB(Client, accuracy, entity, this.accuracy);
 
     METHOD(Client, m_unwind, bool(Client this));
 
index e34826cabcad0966b03af6d1b58a2a4774a343c2..2d7d99229c18726c5cee3c25a7ddd6f4a063cd0c 100644 (file)
@@ -553,7 +553,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
         // increment frag counter for used weapon type
         Weapon w = DEATH_WEAPONOF(deathtype);
                if(w != WEP_Null && accuracy_isgooddamage(attacker, this))
-                       attacker.accuracy.(accuracy_frags[w.m_id-1]) += 1;
+                       CS(attacker).accuracy.(accuracy_frags[w.m_id-1]) += 1;
 
                MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, this, deathtype, damage);
                damage = M_ARGV(4, float);
index 7cc06da3e6dc05b32595b85556ff43d4ecb11225..bee961bc080d0aecd64ccc284e02a0d49be4517b 100644 (file)
@@ -20,7 +20,7 @@ bool accuracy_send(entity this, entity to, int sf)
 
        entity a = this.owner;
        if (IS_SPEC(a)) a = a.enemy;
-       a = a.accuracy;
+       a = CS(a).accuracy;
 
        if (to != a.owner)
                if (!autocvar_sv_accuracy_data_share && !a.owner.cvar_cl_accuracy_data_share)
@@ -40,7 +40,7 @@ bool accuracy_send(entity this, entity to, int sf)
 // init/free
 void accuracy_init(entity e)
 {
-       entity a = e.accuracy = new_pure(accuracy);
+       entity a = CS(e).accuracy = new_pure(accuracy);
        a.owner = e;
        a.drawonlytoclient = e;
        Net_LinkEntity(a, false, 0, accuracy_send);
@@ -48,13 +48,13 @@ void accuracy_init(entity e)
 
 void accuracy_free(entity e)
 {
-       delete(e.accuracy);
+       delete(CS(e).accuracy);
 }
 
 // force a resend of a player's accuracy stats
 void accuracy_resend(entity e)
 {
-       e.accuracy.SendFlags = 0xFFFFFF;
+       CS(e).accuracy.SendFlags = 0xFFFFFF;
 }
 
 // update accuracy stats
@@ -64,7 +64,7 @@ void accuracy_resend(entity e)
 void accuracy_add(entity this, int w, int fired, int hit)
 {
        if (IS_INDEPENDENT_PLAYER(this)) return;
-       entity a = this.accuracy;
+       entity a = CS(this).accuracy;
        if (!a) return;
        if (!hit && !fired) return;
        w -= WEP_FIRST;
@@ -85,7 +85,7 @@ void accuracy_add(entity this, int w, int fired, int hit)
        if (b == accuracy_byte(a.accuracy_hit[w], a.accuracy_fired[w])) return; // no change
        int sf = 1 << (w % 24);
        a.SendFlags |= sf;
-       FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, LAMBDA(it.accuracy.SendFlags |= sf));
+       FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, LAMBDA(CS(it).accuracy.SendFlags |= sf));
 }
 
 bool accuracy_isgooddamage(entity attacker, entity targ)