From: Mario Date: Sat, 15 Jul 2017 18:16:50 +0000 (+1000) Subject: Port ping, ping_packetloss and ping_movementloss to ClientState X-Git-Tag: xonotic-v0.8.5~2625 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=115fc9395b8567833fcff0478a6259d24ffddf13;p=xonotic%2Fxonotic-data.pk3dir.git Port ping, ping_packetloss and ping_movementloss to ClientState --- diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index b69b96632..8d627adda 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -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) diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index e597665c5..87a24d13a 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -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); diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 116ad0002..40c317a69 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -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 diff --git a/qcsrc/server/antilag.qh b/qcsrc/server/antilag.qh index ee7b5d4e3..6cf392eed 100644 --- a/qcsrc/server/antilag.qh +++ b/qcsrc/server/antilag.qh @@ -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? diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index 0b813dae1..d0ba63365 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -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; diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 7ce4b1ab3..6e8e5e468 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -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) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 712157f55..695fabb57 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index b091105e6..68f8d6a44 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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; diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index e444f7129..201cfff1a 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -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); diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index 9f3a200da..984505ec1 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -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)); diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 4f428ab1b..e0e6bb62d 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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) ); } diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 5ad783bbf..a58a3de10 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -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"); diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index 1d6e1c1ff..64539f46b 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -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; } diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 2173f0bfa..4c6304a1b 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -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)