X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fent_cs.qc;h=768eae30b2eb1a16493ae9bc74eaf51d0f8d0e58;hp=98ec277683c5477912cc1415f234c284a80754b5;hb=ceb30359c438be5c6c6257d65e92191431465e1a;hpb=4dd3c23aa51dd6fe855d8c5d97126a12a372eb3b diff --git a/qcsrc/server/ent_cs.qc b/qcsrc/server/ent_cs.qc index 98ec277683..768eae30b2 100644 --- a/qcsrc/server/ent_cs.qc +++ b/qcsrc/server/ent_cs.qc @@ -1,40 +1,10 @@ -#if defined(CSQC) -#elif defined(MENUQC) -#elif defined(SVQC) - #include "../dpdefs/progsdefs.qh" - #include "../dpdefs/dpextensions.qh" - #include "../common/constants.qh" - #include "constants.qh" - #include "defs.qh" - #include "mutators/mutators_include.qh" -#endif - -/** - * The point of these entities is to avoid the problems - * with clientprediction. - * If you add SendEntity to players, the engine will not - * do any prediction anymore, and you'd have to write the whole - * prediction code in CSQC, you want that? :P - * Data can depend on gamemode. For now, it serves as GPS entities - * in onslaught... YAY ;) - */ - -// Beware: do not redefine those in other files -// and NO, you cannot use ".version", which already exists (at least -// it did when I added this) But you have to use .Version -// Capital V - -.entity entcs; - -void entcs_init() -{ - print("Initializing ClientSide information entities\n"); -} +#include "ent_cs.qh" +#include "_all.qh" float entcs_customize() { - entity o; - o = self.owner; + SELFPARAM(); + entity o = self.owner; if(o.deadflag != DEAD_NO) return false; if (!IS_PLAYER(o)) @@ -48,76 +18,70 @@ float entcs_customize() return true; } -float entcs_send(entity to, int sf) +bool entcs_send(entity this, entity to, int sf) { WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS); WriteByte(MSG_ENTITY, sf); - if(sf & 1) - WriteByte(MSG_ENTITY, num_for_edict(self.owner)-1); - if(sf & 2) + if(sf & BIT(0)) + WriteByte(MSG_ENTITY, num_for_edict(self.owner) - 1); + if(sf & BIT(1)) { WriteShort(MSG_ENTITY, self.origin.x); WriteShort(MSG_ENTITY, self.origin.y); WriteShort(MSG_ENTITY, self.origin.z); } - if(sf & 4) + if(sf & BIT(2)) WriteByte(MSG_ENTITY, self.angles.y * 256.0 / 360); - if(sf & 8) + if(sf & BIT(3)) WriteByte(MSG_ENTITY, self.health / 10); // FIXME use a better scale? - if(sf & 16) + if(sf & BIT(4)) WriteByte(MSG_ENTITY, self.armorvalue / 10); // FIXME use a better scale? return true; } void entcs_think() { + SELFPARAM(); self.nextthink = time + 0.033333333333; // increase this to like 0.15 once the client can do smoothing - - entity o; - o = self.owner; - - if(o.origin != self.origin) + entity o = self.owner; + if (o.origin != self.origin) { setorigin(self, o.origin); - self.SendFlags |= 2; + self.SendFlags |= BIT(1); } - if(o.angles.y != self.angles.y) + if (o.angles.y != self.angles.y) { self.angles = o.angles; - self.SendFlags |= 4; + self.SendFlags |= BIT(2); } - if(o.health != self.health) + if (o.health != self.health) { self.health = o.health; - self.SendFlags |= 8; + self.SendFlags |= BIT(3); } - if(o.armorvalue != self.armorvalue) + if (o.armorvalue != self.armorvalue) { self.armorvalue = o.armorvalue; - self.SendFlags |= 16; + self.SendFlags |= BIT(4); } } -entity attach_entcs() +entity attach_entcs(entity e) { - entity ent; - - ent = spawn(); - ent.classname = "entcs_sender_v2"; - ent.owner = self; + entity ent = e.entcs = new(entcs_sender); + ent.owner = e; ent.think = entcs_think; ent.nextthink = time; Net_LinkEntity(ent, false, 0, entcs_send); ent.customizeentityforclient = entcs_customize; - self.entcs = ent; - return ent; } -void detach_entcs() +void detach_entcs(entity e) { - remove(self.entcs); - self.entcs = world; + if (!e.entcs) return; + remove(e.entcs); + e.entcs = NULL; }