From 5506123271187bcad52ac2ee9981342a48ea5953 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Sun, 10 Apr 2011 20:19:45 +0300 Subject: [PATCH] Use a trick to indicate dead bodies to the client. Read code comments for more info on how it works. This requires that Xonotic will never have more than 99 species (although afaik, they currently range from 0 to 15, so it will likely never happen). --- qcsrc/client/gibs.qc | 10 ++++++++++ qcsrc/server/g_violence.qc | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/qcsrc/client/gibs.qc b/qcsrc/client/gibs.qc index 7239fffe2..f3fe88bf8 100644 --- a/qcsrc/client/gibs.qc +++ b/qcsrc/client/gibs.qc @@ -281,6 +281,7 @@ void GibSplash_Precache() void Ent_DamageEffect() { float type, specnum1, specnum2, entnumber; + float is_body; vector org; string specstr, effectnum; entity e; @@ -299,6 +300,15 @@ void Ent_DamageEffect() e = get_weaponinfo(type); + if(specnum1 >= 100) + { + // The server sends the specnum increased by 100 when the target is a dead body (a trick used to save bandwidth) + // Species range from 0 to 15, and could never reach 100, so this should never risk causing a conflict. + // Revert the species back and mark that this is a dead body. + specnum1 -= 100; + is_body = TRUE; + } + specnum2 = (specnum1 & 0x78) / 8; // blood type: using four bits (0..7, bit indexes 3,4,5) specstr = species_prefix(specnum2); diff --git a/qcsrc/server/g_violence.qc b/qcsrc/server/g_violence.qc index 947791835..353723377 100644 --- a/qcsrc/server/g_violence.qc +++ b/qcsrc/server/g_violence.qc @@ -81,7 +81,14 @@ void Violence_DamageEffect(entity pl, float type) // if this is a copied dead body, send the num of its player instead if(pl.classname == "body") + { e.team = num_for_edict(pl.owner); + + // Use a trick to indicate this is a copied dead body and not an alive player to the client (saves an extra WriteByte). + // Do this by increasing species with 100 (species range from 0 to 15, and there could never be 100 of them). + // The client will notice this and turn them back, while also noting what the server is trying to say. + e.state += 100; + } else e.team = num_for_edict(pl); -- 2.39.2