]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
ha! got health/armor networking right finally
authorFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 07:22:18 +0000 (10:22 +0300)
committerFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 07:22:18 +0000 (10:22 +0300)
qcsrc/client/Main.qc
qcsrc/server/cl_player.qc

index 87b3997e65f1b0e69f2ea1bf6180c8a627da3b15..1b0c36a646448ece99e7c9c142dd80f71620fb10 100644 (file)
@@ -907,27 +907,24 @@ void Ent_ReadAccuracy(void)
        }
 }
 
-.float health, armorvalue;
+.float healthvalue, armorvalue;
 void Ent_ShowNames()
 {
     float sf, the_entnum;
 
     sf = ReadByte();
     the_entnum = ReadByte();
-    print("sendflags: ", ftos(sf), "\n");
 
     if(sf & 1)
     {
-        playerslots[the_entnum].origin_x = ReadShort();
-        playerslots[the_entnum].origin_y = ReadShort();
-        playerslots[the_entnum].origin_z = ReadShort();
-        print("Updated origin = ", vtos(playerslots[the_entnum].origin), " for player ", GetPlayerName(the_entnum-1), "\n");
-        print("Their health/armor = ", playerslots[the_entnum].health, "/", playerslots[the_entnum].armorvalue, "\n");
+        playerslots[the_entnum-1].origin_x = ReadShort();
+        playerslots[the_entnum-1].origin_y = ReadShort();
+        playerslots[the_entnum-1].origin_z = ReadShort();
     }
     if(sf & 2)
     {
-        playerslots[the_entnum].health = ReadByte();
-        playerslots[the_entnum].armorvalue = ReadByte();
+        playerslots[the_entnum-1].healthvalue = ReadByte();
+        playerslots[the_entnum-1].armorvalue = ReadByte();
     }
 
     /*
index 4de460f85a79d0cffdefb9987cc100bb22f99c2d..5f0a08ef78eeddd1d590103222942f86f7b36cbf 100644 (file)
@@ -737,11 +737,11 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
 float SendEntity_ShowNames(entity to, float sendflags)
 {
     if(vlen(to.origin - self.origin) < autocvar_sv_shownames_cull_distance) // distance cull
-        return;
+        return FALSE;
 
     WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES);
-    //sendflags &= 127;
-    if(teams_matter && self.team == to.team)
+    sendflags = sendflags & 127;
+    if(teams_matter && self.owner.team == to.team)
         sendflags |= 128;
     else
         sendflags &~= 2;
@@ -768,10 +768,10 @@ void shownames_think()
         setorigin(self, self.owner.origin);
         self.SendFlags |= 1;
     }
-    if(self.health != self.owner.health || self.armorvalue != self.owner.armorvalue)
+    if(self.health != floor(self.owner.health) || self.armorvalue != floor(self.owner.armorvalue))
     {
-        self.health = self.owner.health;
-        self.armorvalue = self.owner.armorvalue;
+        self.health = floor(self.owner.health);
+        self.armorvalue = floor(self.owner.armorvalue);
         self.SendFlags |= 2;
     }
     if(self.the_entnum != num_for_edict(self.owner))