From: Rudolf Polzer Date: Sun, 15 May 2011 17:18:03 +0000 (+0200) Subject: make entcs entities use sendflags (preparation for including h/a info) X-Git-Tag: xonotic-v0.5.0~247 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1340e6da759fec548e48263e364c90a86614a2ec;p=xonotic%2Fxonotic-data.pk3dir.git make entcs entities use sendflags (preparation for including h/a info) --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 4fca767df..a097f0719 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -660,15 +660,26 @@ void Ent_RemoveEntCS() } void Ent_ReadEntCS() { + float sf; InterpolateOrigin_Undo(); self.classname = "entcs_receiver"; - self.sv_entnum = ReadByte() - 1; - self.origin_x = ReadShort(); - self.origin_y = ReadShort(); - self.origin_z = ReadShort(); - self.angles_y = ReadByte() * 360.0 / 256; - self.angles_x = self.angles_z = 0; + sf = ReadByte(); + + if(sf & 1) + self.sv_entnum = ReadByte() - 1; + if(sf & 2) + { + self.origin_x = ReadShort(); + self.origin_y = ReadShort(); + self.origin_z = ReadShort(); + } + if(sf & 4) + { + self.angles_y = ReadByte() * 360.0 / 256; + self.angles_x = self.angles_z = 0; + } + entcs_receiver[self.sv_entnum] = self; self.entremove = Ent_RemoveEntCS; diff --git a/qcsrc/server/ent_cs.qc b/qcsrc/server/ent_cs.qc index bee79d682..970f20a92 100644 --- a/qcsrc/server/ent_cs.qc +++ b/qcsrc/server/ent_cs.qc @@ -42,11 +42,17 @@ float entcs_send(entity to, float sf) entity o; o = self.owner; WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS); - WriteByte(MSG_ENTITY, num_for_edict(o)); - WriteShort(MSG_ENTITY, o.origin_x); - WriteShort(MSG_ENTITY, o.origin_y); - WriteShort(MSG_ENTITY, o.origin_z); - WriteByte(MSG_ENTITY, o.angles_y * 256.0 / 360); + WriteByte(MSG_ENTITY, sf); + if(sf & 1) + WriteByte(MSG_ENTITY, num_for_edict(o)); + if(sf & 2) + { + WriteShort(MSG_ENTITY, o.origin_x); + WriteShort(MSG_ENTITY, o.origin_y); + WriteShort(MSG_ENTITY, o.origin_z); + } + if(sf & 4) + WriteByte(MSG_ENTITY, o.angles_y * 256.0 / 360); return TRUE; }; @@ -57,11 +63,15 @@ void entcs_think() entity o; o = self.owner; - if(o.origin != self.origin || o.angles != self.angles) + if(o.origin != self.origin) { setorigin(self, o.origin); + self.SendFlags |= 2; + } + if(o.angles_y != self.angles_y) + { self.angles = o.angles; - self.SendFlags |= 1; + self.SendFlags |= 4; } };