]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/ent_cs.qc
Unify boolean constants
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / ent_cs.qc
index bee79d682e9e2d5d4ad31cd84a8c0231b788187c..b6db8dd3c358eb260eccec10b49cf0e316559227 100644 (file)
 void entcs_init()
 {
        print("Initializing ClientSide information entities\n");
-};
+}
 
 float entcs_customize()
 {
        entity o;
        o = self.owner;
        if(o.deadflag != DEAD_NO)
-               return FALSE;
-       if(o.classname != "player")
-               return FALSE;
+               return false;
+       if (!IS_PLAYER(o))
+               return false;
        if(other == o)
-               return FALSE;
-       if(other.classname == "player")
-               if(o.team != other.team)
-                       if not (radar_showennemies)
-                               return FALSE;
-       return TRUE;
+               return false;
+       if((IS_PLAYER(other)) || other.caplayer)
+               if(!teamplay || o.team != other.team)
+                       if (!radar_showennemies)
+                               return false;
+       return true;
 }
 
 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);
-       return TRUE;
-};
+       WriteByte(MSG_ENTITY, sf);
+       if(sf & 1)
+               WriteByte(MSG_ENTITY, num_for_edict(self.owner)-1);
+       if(sf & 2)
+       {
+               WriteShort(MSG_ENTITY, self.origin.x);
+               WriteShort(MSG_ENTITY, self.origin.y);
+               WriteShort(MSG_ENTITY, self.origin.z);
+       }
+       if(sf & 4)
+               WriteByte(MSG_ENTITY, self.angles.y * 256.0 / 360);
+       if(sf & 8)
+               WriteByte(MSG_ENTITY, self.health / 10); // FIXME use a better scale?
+       if(sf & 16)
+               WriteByte(MSG_ENTITY, self.armorvalue / 10); // FIXME use a better scale?
+       return true;
+}
 
 void entcs_think()
 {
-       self.nextthink = time;
+       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 || 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;
        }
-};
+       if(o.health != self.health)
+       {
+               self.health = o.health;
+               self.SendFlags |= 8;
+       }
+       if(o.armorvalue != self.armorvalue)
+       {
+               self.armorvalue = o.armorvalue;
+               self.SendFlags |= 16;
+       }
+}
 
 entity attach_entcs()
 {
-       local entity ent;
+       entity ent;
 
        ent = spawn();
        ent.classname = "entcs_sender_v2";
@@ -75,16 +97,16 @@ entity attach_entcs()
        ent.think = entcs_think;
        ent.nextthink = time;
 
-       Net_LinkEntity(ent, FALSE, 0, entcs_send);
+       Net_LinkEntity(ent, false, 0, entcs_send);
        ent.customizeentityforclient = entcs_customize;
 
        self.entcs = ent;
 
        return ent;
-};
+}
 
 void detach_entcs()
 {
        remove(self.entcs);
        self.entcs = world;
-};
+}