]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port ping, ping_packetloss and ping_movementloss to ClientState
authorMario <mario@smbclan.net>
Sat, 15 Jul 2017 18:16:50 +0000 (04:16 +1000)
committerMario <mario@smbclan.net>
Sat, 15 Jul 2017 18:16:50 +0000 (04:16 +1000)
14 files changed:
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/lib/warpzone/server.qc
qcsrc/server/antilag.qh
qcsrc/server/bot/default/aim.qc
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/command/common.qc
qcsrc/server/g_damage.qc
qcsrc/server/g_world.qc
qcsrc/server/mutators/mutator/gamemode_freezetag.qc
qcsrc/server/weapons/tracing.qc

index b69b9663229a75f8de6381c458774845eabc5128..8d627adda68712b24421f83130949cdfa243c70c 100644 (file)
@@ -398,11 +398,9 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
                false
        );
 
-       float lag = ANTILAG_LATENCY(actor);
+       float lag = ((IS_REAL_CLIENT(actor)) ? ANTILAG_LATENCY(actor) : 0);
        if(lag < 0.001)
                lag = 0;
-       if (!IS_REAL_CLIENT(actor))
-               lag = 0;
        if(autocvar_g_antilag == 0 || actor.cvar_cl_noantilag)
                lag = 0; // only do hitscan, but no antilag
        if(lag)
index e597665c5ebee23918afad49a5a47cf2abb48145..87a24d13a3a96a2d3985073f911f70212d13c956 100644 (file)
@@ -125,7 +125,7 @@ void W_Shotgun_Melee_Think(entity this)
                        + (v_up * swing_factor * WEP_CVAR_SEC(shotgun, melee_swing_up))
                        + (v_right * swing_factor * WEP_CVAR_SEC(shotgun, melee_swing_side)));
 
-               WarpZone_traceline_antilag(this, this.realowner.origin + this.realowner.view_ofs, targpos, false, this.realowner, ANTILAG_LATENCY(this.realowner));
+               WarpZone_traceline_antilag(this, this.realowner.origin + this.realowner.view_ofs, targpos, false, this.realowner, ((IS_CLIENT(this.realowner)) ? ANTILAG_LATENCY(this.realowner) : 0));
 
                // draw lightning beams for debugging
                //te_lightning2(NULL, targpos, this.realowner.origin + this.realowner.view_ofs + v_forward * 5 - v_up * 5);
index 116ad00023ae98b1a4321c609698298a2dd46f0b..40c317a6910ec9f994614af7e88ef2db16230946 100644 (file)
@@ -888,7 +888,7 @@ void WarpZone_PlayerPhysics_FixVAngle(entity this)
 #ifndef WARPZONE_DONT_FIX_VANGLE
        if(IS_REAL_CLIENT(this))
        if(this.v_angle.z <= 360) // if not already adjusted
-       if(time - this.ping * 0.001 < this.warpzone_teleport_time)
+       if(time - CS(this).ping * 0.001 < this.warpzone_teleport_time)
        {
                this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle);
                this.v_angle_z += 720; // mark as adjusted
index ee7b5d4e37c0095628517a93ca765173f32bbd14..6cf392eed5ae1e8bd2bc125b3a19aa5b9e70d6dd 100644 (file)
@@ -8,5 +8,5 @@ void antilag_clear(entity e, entity store);
 
 .float antilag_debug;
 
-#define ANTILAG_LATENCY(e) min(0.4, e.ping * 0.001)
+#define ANTILAG_LATENCY(e) min(0.4, CS(e).ping * 0.001)
 // add one ticrate?
index 0b813dae1fd5b3be51a7828a22f5c86efefef404..d0ba63365abfc5fc3b7877e5e45549e4f8fced47 100644 (file)
@@ -157,7 +157,7 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1,
                return;
        }
        this.bot_aimtarg = e1;
-       this.bot_aimlatency = this.ping; // FIXME?  Shouldn't this be in the lag item?
+       this.bot_aimlatency = CS(this).ping; // FIXME?  Shouldn't this be in the lag item?
        //this.bot_aimorigin = v1;
        //this.bot_aimvelocity = v2;
        this.bot_aimtargorigin = v3;
index 7ce4b1ab3787c898c698f49a6a25da45b1233414..6e8e5e46883a11a80f0b36272df6c438dffc90f5 100644 (file)
@@ -94,7 +94,7 @@ void bot_think(entity this)
        // (simulated network latency + naturally delayed reflexes)
        //this.ping = 0.7 - bound(0, 0.05 * skill, 0.5); // moved the reflexes to bot_aimdir (under the name 'think')
        // minimum ping 20+10 random
-       this.ping = bound(0,0.07 - bound(0, (skill + this.bot_pingskill) * 0.005,0.05)+random()*0.01,0.65); // Now holds real lag to server, and higer skill players take a less laggy server
+       CS(this).ping = bound(0,0.07 - bound(0, (skill + this.bot_pingskill) * 0.005,0.05)+random()*0.01,0.65); // Now holds real lag to server, and higer skill players take a less laggy server
        // skill 10 = ping 0.2 (adrenaline)
        // skill 0 = ping 0.7 (slightly drunk)
 
index 712157f558b0f3617848eb2ec94b87edbf83691e..695fabb579b65538ec533cfb88047578ed901659 100644 (file)
@@ -1202,10 +1202,10 @@ void havocbot_aim(entity this)
                vector enemyvel = this.enemy.velocity;
                if (!this.enemy.waterlevel)
                        enemyvel.z = 0;
-               lag_additem(this, time + this.ping, 0, 0, this.enemy, this.origin, myvel, (this.enemy.absmin + this.enemy.absmax) * 0.5, enemyvel);
+               lag_additem(this, time + CS(this).ping, 0, 0, this.enemy, this.origin, myvel, (this.enemy.absmin + this.enemy.absmax) * 0.5, enemyvel);
        }
        else
-               lag_additem(this, time + this.ping, 0, 0, NULL, this.origin, myvel, ( this.goalcurrent.absmin + this.goalcurrent.absmax ) * 0.5, '0 0 0');
+               lag_additem(this, time + CS(this).ping, 0, 0, NULL, this.origin, myvel, ( this.goalcurrent.absmin + this.goalcurrent.absmax ) * 0.5, '0 0 0');
 }
 
 bool havocbot_moveto_refresh_route(entity this)
index b091105e685498169ec896a714a1113c5935b165..68f8d6a44a9a8e08c94207c93c08199d37071fec 100644 (file)
@@ -2778,7 +2778,9 @@ void PM_UpdateButtons(entity this, entity store)
        store.cursor_trace_endpos = this.cursor_trace_endpos;
        store.cursor_trace_ent = this.cursor_trace_ent;
 
-       // TODO: ping?
+       store.ping = this.ping;
+       store.ping_packetloss = this.ping_packetloss;
+       store.ping_movementloss = this.ping_movementloss;
 
        store.v_angle = this.v_angle;
        store.movement = this.movement;
index e444f71293cb9ad3798a2badd6f0c51f468e489e..201cfff1a7f929b930a7a6d9be302895385b7b36 100644 (file)
@@ -57,6 +57,10 @@ CLASS(Client, Object)
     ATTRIB(Client, cursor_trace_endpos, vector, this.cursor_trace_endpos);
     ATTRIB(Client, cursor_trace_ent, entity, this.cursor_trace_ent);
 
+    ATTRIB(Client, ping, float, this.ping);
+    ATTRIB(Client, ping_packetloss, float, this.ping_packetloss);
+    ATTRIB(Client, ping_movementloss, float, this.ping_movementloss);
+
     ATTRIB(Client, v_angle, vector, this.v_angle);
     ATTRIB(Client, movement, vector, this.movement);
 
index 9f3a200dac51a17e0e8af00956644b5d5fdd42fd..984505ec1c56d54d880d1c580f0df68fde9b313b 100644 (file)
@@ -806,8 +806,8 @@ void CommonCommand_who(float request, entity caller, float argc)
                                print_to(caller, sprintf(strreplace(" ", separator, " #%-3d %-20.20s %-5d %-3d %-9s %-16s %s "),
                                        etof(it),
                                        it.netname,
-                                       it.ping,
-                                       it.ping_packetloss,
+                                       CS(it).ping,
+                                       CS(it).ping_packetloss,
                                        process_time(1, time - it.jointime),
                                        tmp_netaddress,
                                        tmp_crypto_idfp));
index 4f428ab1b84defe579d00ae8f5afe84f36f91fa7..e0e6bb62d2fd12fbbfb76eabfc734e7af8769d36 100644 (file)
@@ -273,8 +273,8 @@ bool frag_centermessage_override(entity attacker, entity targ, int deathtype, in
 {
        if(deathtype == DEATH_FIRE.m_id)
        {
-               Send_Notification(NOTIF_ONE, attacker, MSG_CHOICE, CHOICE_FRAG_FIRE, targ.netname, kill_count_to_attacker, (IS_BOT_CLIENT(targ) ? -1 : targ.ping));
-               Send_Notification(NOTIF_ONE, targ, MSG_CHOICE, CHOICE_FRAGGED_FIRE, attacker.netname, kill_count_to_target, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? -1 : attacker.ping));
+               Send_Notification(NOTIF_ONE, attacker, MSG_CHOICE, CHOICE_FRAG_FIRE, targ.netname, kill_count_to_attacker, (IS_BOT_CLIENT(targ) ? -1 : CS(targ).ping));
+               Send_Notification(NOTIF_ONE, targ, MSG_CHOICE, CHOICE_FRAGGED_FIRE, attacker.netname, kill_count_to_target, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping));
                return true;
        }
 
@@ -417,7 +417,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
                                        CHOICE_TYPEFRAG,
                                        targ.netname,
                                        kill_count_to_attacker,
-                                       (IS_BOT_CLIENT(targ) ? -1 : targ.ping)
+                                       (IS_BOT_CLIENT(targ) ? -1 : CS(targ).ping)
                                );
                                Send_Notification(
                                        NOTIF_ONE,
@@ -428,7 +428,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
                                        kill_count_to_target,
                                        attacker.health,
                                        attacker.armorvalue,
-                                       (IS_BOT_CLIENT(attacker) ? -1 : attacker.ping)
+                                       (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping)
                                );
                        }
                        else if(!frag_centermessage_override(attacker, targ, deathtype, kill_count_to_attacker, kill_count_to_target))
@@ -440,7 +440,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
                                        CHOICE_FRAG,
                                        targ.netname,
                                        kill_count_to_attacker,
-                                       (IS_BOT_CLIENT(targ) ? -1 : targ.ping)
+                                       (IS_BOT_CLIENT(targ) ? -1 : CS(targ).ping)
                                );
                                Send_Notification(
                                        NOTIF_ONE,
@@ -451,7 +451,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
                                        kill_count_to_target,
                                        attacker.health,
                                        attacker.armorvalue,
-                                       (IS_BOT_CLIENT(attacker) ? -1 : attacker.ping)
+                                       (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping)
                                );
                        }
 
index 5ad783bbf0f2e157307dfdd1933cf520937374a4..a58a3de109a95f77053df51070792963c5060d1b 100644 (file)
@@ -57,14 +57,14 @@ void PingPLReport_Think(entity this)
        {
                WriteHeader(MSG_BROADCAST, TE_CSQC_PINGPLREPORT);
                WriteByte(MSG_BROADCAST, this.cnt);
-               WriteShort(MSG_BROADCAST, bound(1, e.ping, 65535));
-               WriteByte(MSG_BROADCAST, min(ceil(e.ping_packetloss * 255), 255));
-               WriteByte(MSG_BROADCAST, min(ceil(e.ping_movementloss * 255), 255));
+               WriteShort(MSG_BROADCAST, bound(1, CS(e).ping, 65535));
+               WriteByte(MSG_BROADCAST, min(ceil(CS(e).ping_packetloss * 255), 255));
+               WriteByte(MSG_BROADCAST, min(ceil(CS(e).ping_movementloss * 255), 255));
 
                // record latency times for clients throughout the match so we can report it to playerstats
                if(time > (e.latency_time + LATENCY_THINKRATE))
                {
-                       e.latency_sum += e.ping;
+                       e.latency_sum += CS(e).ping;
                        e.latency_cnt += 1;
                        e.latency_time = time;
                        //print("sum: ", ftos(e.latency_sum), ", cnt: ", ftos(e.latency_cnt), ", avg: ", ftos(e.latency_sum / e.latency_cnt), ".\n");
index 1d6e1c1ff63129fdad35064ea91021e2b4534af0..64539f46bb7895fd84c022d23988f2bfc9d5e4bd 100644 (file)
@@ -568,8 +568,8 @@ MUTATOR_HOOKFUNCTION(ft, FragCenterMessage)
        if(STAT(FROZEN, frag_target))
                return; // target was already frozen, so this is just pushing them off the cliff
 
-       Send_Notification(NOTIF_ONE, frag_attacker, MSG_CHOICE, CHOICE_FRAG_FREEZE, frag_target.netname, kill_count_to_attacker, (IS_BOT_CLIENT(frag_target) ? -1 : frag_target.ping));
-       Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target, frag_attacker.health, frag_attacker.armorvalue, (IS_BOT_CLIENT(frag_attacker) ? -1 : frag_attacker.ping));
+       Send_Notification(NOTIF_ONE, frag_attacker, MSG_CHOICE, CHOICE_FRAG_FREEZE, frag_target.netname, kill_count_to_attacker, (IS_BOT_CLIENT(frag_target) ? -1 : CS(frag_target).ping));
+       Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target, frag_attacker.health, frag_attacker.armorvalue, (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
 
        return true;
 }
index 2173f0bfa6e5542db1d300282b3594a63e633278..4c6304a1b1b50439070afa5c43a78a71d26d5846 100644 (file)
@@ -348,11 +348,9 @@ void fireBullet(entity this, .entity weaponentity, vector start, vector dir, flo
        else
                fireBullet_trace_callback_eff = EFFECT_BULLET;
 
-       float lag = ANTILAG_LATENCY(this);
+       float lag = ((IS_REAL_CLIENT(this)) ? ANTILAG_LATENCY(this) : 0);
        if(lag < 0.001)
                lag = 0;
-       if (!IS_REAL_CLIENT(this))
-               lag = 0;
        if(autocvar_g_antilag == 0 || this.cvar_cl_noantilag)
                lag = 0; // only do hitscan, but no antilag
        if(lag)