From: FruitieX Date: Wed, 13 Apr 2011 07:22:18 +0000 (+0300) Subject: ha! got health/armor networking right finally X-Git-Tag: xonotic-v0.5.0~296 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=01b6854065d89834989052d0a9bcecf5398dc74d;p=xonotic%2Fxonotic-data.pk3dir.git ha! got health/armor networking right finally --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 87b3997e6..1b0c36a64 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -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(); } /* diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 4de460f85..5f0a08ef7 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -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))