From: terencehill Date: Mon, 9 Jan 2023 12:11:07 +0000 (+0100) Subject: Save 3 bytes by sending the force vector slightly compressed. Decals spawn in the... X-Git-Tag: xonotic-v0.8.6~144^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=643db205bfd70fc6d32a0b147db816d1b2b4c7be;p=xonotic%2Fxonotic-data.pk3dir.git Save 3 bytes by sending the force vector slightly compressed. Decals spawn in the same way even with this change. --- diff --git a/qcsrc/common/effects/qc/damageeffects.qc b/qcsrc/common/effects/qc/damageeffects.qc index 847a9d340..b0219e9f0 100644 --- a/qcsrc/common/effects/qc/damageeffects.qc +++ b/qcsrc/common/effects/qc/damageeffects.qc @@ -13,7 +13,12 @@ bool Damage_DamageInfo_SendEntity(entity this, entity to, int sf) WriteByte(MSG_ENTITY, bound(1, this.dmg, 255)); WriteByte(MSG_ENTITY, bound(0, this.dmg_radius, 255)); WriteByte(MSG_ENTITY, bound(1, this.dmg_edge, 255)); - WriteVector(MSG_ENTITY, this.velocity); + // we can't send the force vector compressed with compressShortVector as it's too inaccurate + // it would break decals when hit angle on a surface is small + // (the traceline performed by the client to spawn a decal wouldn't hit the surface at all) + WriteShort(MSG_ENTITY, floor(this.velocity.x / 4)); + WriteShort(MSG_ENTITY, floor(this.velocity.y / 4)); + WriteShort(MSG_ENTITY, floor(this.velocity.z / 4)); WriteByte(MSG_ENTITY, this.species); return true; } @@ -191,7 +196,10 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) thedamage = ReadByte(); rad = ReadByte(); edge = ReadByte(); - force = ReadVector(); + force.x = ReadShort() * 4 + 2; + force.y = ReadShort() * 4 + 2; + force.z = ReadShort() * 4 + 2; + species = ReadByte(); return = true;