From: terencehill Date: Sat, 2 Feb 2019 18:20:00 +0000 (+0100) Subject: Save some bandwidth by sending statusbar value to waypoints only when there is a... X-Git-Tag: xonotic-v0.8.5~1616 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5df49bb174887a416ddedd01c7e7202d1ffed964;p=xonotic%2Fxonotic-data.pk3dir.git Save some bandwidth by sending statusbar value to waypoints only when there is a difference of at least 1/40th of the statusbar --- diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index a70b73172..5b8a213bf 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -82,11 +82,7 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags) if (WaypointSprite_isteammate(this.owner, WaypointSprite_getviewentity(to))) { - float dt = (this.waypointsprite_helpmetime - time) / 0.1; - if (dt < 0) - dt = 0; - if (dt > 255) - dt = 255; + float dt = bound(0, (this.waypointsprite_helpmetime - time) / 0.1, 255); WriteByte(MSG_ENTITY, dt); } else @@ -833,7 +829,8 @@ void WaypointSprite_UpdateSprites(entity e, entity _m1, entity _m2, entity _m3) void WaypointSprite_UpdateHealth(entity e, float f) { f = bound(0, f, e.max_health); - if (f != GetResourceAmount(e, RESOURCE_HEALTH) || e.pain_finished) + float step = e.max_health / 40; + if ((floor(f / step) != floor(GetResourceAmount(e, RESOURCE_HEALTH)) / step) || e.pain_finished) { SetResourceAmountExplicit(e, RESOURCE_HEALTH, f); e.pain_finished = 0;