]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
ent_cs: cleanup
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 8 Oct 2015 01:54:02 +0000 (12:54 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 8 Oct 2015 01:54:02 +0000 (12:54 +1100)
qcsrc/client/main.qc
qcsrc/server/cl_client.qc
qcsrc/server/ent_cs.qc
qcsrc/server/ent_cs.qh
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh
qcsrc/warpzonelib/common.qc

index bc3fb43d6820af3bee49ddf3aa1b9c2e029b3874..bb60a917d5f19a216d4f550bccdee78ca6b92b9a 100644 (file)
@@ -389,33 +389,31 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
 void Ent_RemoveEntCS()
 {SELFPARAM();
-       entcs_receiver[self.sv_entnum] = world;
+       entcs_receiver[self.sv_entnum] = NULL;
 }
 void Ent_ReadEntCS()
 {SELFPARAM();
-    int sf;
        InterpolateOrigin_Undo();
-
        self.classname = "entcs_receiver";
-       sf = ReadByte();
+       int sf = ReadByte();
 
-       if(sf & 1)
+       if(sf & BIT(0))
                self.sv_entnum = ReadByte();
-       if(sf & 2)
+       if (sf & BIT(1))
        {
                self.origin_x = ReadShort();
                self.origin_y = ReadShort();
                self.origin_z = ReadShort();
                setorigin(self, self.origin);
        }
-       if(sf & 4)
+       if (sf & BIT(2))
        {
                self.angles_y = ReadByte() * 360.0 / 256;
                self.angles_x = self.angles_z = 0;
        }
-       if(sf & 8)
+       if (sf & BIT(3))
                self.healthvalue = ReadByte() * 10;
-       if(sf & 16)
+       if (sf & BIT(4))
                self.armorvalue = ReadByte() * 10;
 
        entcs_receiver[self.sv_entnum] = self;
index 0d0d356a9da379ad579963386d814a4608c7bae3..71efa5f9d931233f32899305692f023ceaea5d96 100644 (file)
@@ -1216,7 +1216,7 @@ void ClientConnect (void)
        else
                stuffcmd(self, "set _teams_available 0\n");
 
-       attach_entcs();
+       attach_entcs(self);
 
        bot_relinkplayerlist();
 
@@ -1302,8 +1302,7 @@ void ClientDisconnect (void)
 
        bot_clientdisconnect();
 
-       if(self.entcs)
-               detach_entcs();
+       detach_entcs(self);
 
        if(autocvar_sv_eventlog)
                GameLogEcho(strcat(":part:", ftos(self.playerid)));
index 904f4c9cc28a59e6eac04730cc143ca466e26a2f..768eae30b2eb1a16493ae9bc74eaf51d0f8d0e58 100644 (file)
@@ -1,34 +1,10 @@
+#include "ent_cs.qh"
 #include "_all.qh"
 
-#include "defs.qh"
-#include "mutators/mutators_include.qh"
-
-/**
- * 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()
-{
-       LOG_INFO("Initializing ClientSide information entities\n");
-}
-
 float entcs_customize()
-{SELFPARAM();
-       entity o;
-       o = self.owner;
+{
+       SELFPARAM();
+       entity o = self.owner;
        if(o.deadflag != DEAD_NO)
                return false;
        if (!IS_PLAYER(o))
@@ -46,72 +22,66 @@ 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();
+{
+       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()
-{SELFPARAM();
-       entity ent;
-
-       ent = spawn();
-       ent.classname = "entcs_sender_v2";
-       ent.owner = self;
+entity attach_entcs(entity e)
+{
+       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()
-{SELFPARAM();
-       remove(self.entcs);
-       self.entcs = world;
+void detach_entcs(entity e)
+{
+       if (!e.entcs) return;
+       remove(e.entcs);
+       e.entcs = NULL;
 }
index 1e875b58e54480adbbb8fc4558d9611132bb0ebf..1cfc854c0964184ddb5f37cc10413171212911b8 100644 (file)
  * 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();
-
 float entcs_customize();
 
 bool entcs_send(entity this, entity to, int sf);
 
 void entcs_think();
 
-entity attach_entcs();
+entity attach_entcs(entity e);
+
+void detach_entcs(entity e);
 
-void detach_entcs();
 #endif
index 6defa736f63cdd09327cedb34e35033ff427d714..2fbbd50b32e3c9dc78b214ae0dcda2c6a9f817e3 100644 (file)
@@ -247,9 +247,6 @@ void InitGameplayMode()
                MUTATOR_ADD(gamemode_invasion);
        }
 
-       if(teamplay)
-               entcs_init();
-
        cache_mutatormsg = strzone("");
        cache_lastmutatormsg = strzone("");
 
index 8ce6eae61b79e4377bfe3da50122c707e0e68527..3ce05ac2a66c2d24ab50dc74b91a94c61d6d156a 100644 (file)
@@ -13,8 +13,6 @@ float cb1, cb2, cb3, cb4;
 
 void TeamchangeFrags(entity e);
 
-void entcs_init();
-
 void LogTeamchange(float player_id, float team_number, float type);
 
 void default_delayedinit();
index c10658f0b3f5e66cfb866381d2a423dad318f6a1..0eaaac980c69a3e70cf0ba8974994741776f8507 100644 (file)
@@ -587,8 +587,8 @@ bool WarpZoneLib_BadEntity(entity e)
                case "ent_client_scoreinfo":
                case "saved_cvar_value":
                case "accuracy":
-               case "entcs_sender_v2":
-               case "entcs_receiver_v2":
+               case "entcs_sender":
+               case "entcs_receiver":
                case "clientinit":
                case "sprite_waypoint":
                case "waypoint":