From 643db205bfd70fc6d32a0b147db816d1b2b4c7be Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 9 Jan 2023 13:11:07 +0100 Subject: [PATCH] Save 3 bytes by sending the force vector slightly compressed. Decals spawn in the same way even with this change. --- qcsrc/common/effects/qc/damageeffects.qc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; -- 2.39.2