]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
remove entity spam from shownames
authorRudolf Polzer <divverent@alientrap.org>
Sun, 15 May 2011 18:12:46 +0000 (20:12 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 15 May 2011 18:12:46 +0000 (20:12 +0200)
qcsrc/client/Main.qc
qcsrc/client/shownames.qc
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/defs.qh
qcsrc/server/ent_cs.qc

index a097f071954555866bf9ef9350bb86cf284618f5..d7cb0ce629a814894cdba4c23ca8278ff9bf5f88 100644 (file)
@@ -679,9 +679,18 @@ void Ent_ReadEntCS()
                self.angles_y = ReadByte() * 360.0 / 256;
                self.angles_x = self.angles_z = 0;
        }
+       if(sf & 8)
+               self.healthvalue = ReadByte() * 10;
+       if(sf & 16)
+               self.armorvalue = ReadByte() * 10;
+       if(sf & 128) // same team
+               self.sameteam = TRUE;
+       else
+               self.sameteam = FALSE;
 
        entcs_receiver[self.sv_entnum] = self;
        self.entremove = Ent_RemoveEntCS;
+       self.draw2d = Draw_ShowNames;
 
        InterpolateOrigin_Note();
 }
@@ -907,36 +916,6 @@ void Ent_ReadAccuracy(void)
        }
 }
 
-void Ent_ShowNames()
-{
-    float sf;
-
-    // entity init, TODO can this be done only once somehow?
-    self.the_entnum = ReadByte(); // TODO: fixme to only send once somehow
-    self.draw2d = Draw_ShowNames;
-
-    //self.movetype = MOVETYPE_FLY; // movetype needed so we can traceline?
-    //self.mins = '-20 -20 -24';
-    //self.maxs = '20 20 45';
-    self.classname = "shownames_tag";
-
-    sf = ReadByte();
-
-    if(sf & 1)
-    {
-        self.healthvalue = ReadByte() * 10;
-    }
-    if(sf & 2)
-    {
-        self.armorvalue = ReadByte() * 10;
-    }
-
-    if(sf & 128) // same team
-        self.sameteam = TRUE;
-    else
-        self.sameteam = FALSE;
-}
-
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
 void Ent_RadarLink();
@@ -1003,7 +982,6 @@ void(float bIsNewEntity) CSQC_Ent_Update =
                case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
                case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
-               case ENT_CLIENT_SHOWNAMES: Ent_ShowNames(); break;
                default:
                        //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
index 82fa05e098308f487ccd8680a9bda2082783d52d..c467ea6873cbdba95687c7a8dcafa66068b8988c 100644 (file)
@@ -10,12 +10,12 @@ void Draw_ShowNames()
     if(!autocvar_hud_shownames)
         return;
 
-    if(self.the_entnum == player_localentnum && !autocvar_chase_active)
+    if(self.sv_entnum == player_localentnum && !autocvar_chase_active)
         return;
 
     if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
     {
-        self.origin = getplayerorigin(self.the_entnum-1);
+        self.origin = getplayerorigin(self.sv_entnum-1);
         self.origin_z += autocvar_hud_shownames_offset;
 
         if(!self.sameteam)
@@ -127,9 +127,9 @@ void Draw_ShowNames()
             }
 
             string s;
-            s = GetPlayerName(self.the_entnum-1);
+            s = GetPlayerName(self.sv_entnum-1);
             if((autocvar_hud_shownames_decolorize == 1 && teamplay) || autocvar_hud_shownames_decolorize == 2)
-                s = playername(s, GetPlayerColor(self.the_entnum-1));
+                s = playername(s, GetPlayerColor(self.sv_entnum-1));
 
             drawfontscale = '1 1 0' * resize;
             s = textShortenToWidth(s, namewidth, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
index 70719e0d7c9f03e09f3c24c16634b251db7074b5..26bd176b634fe5c7b1b47ea2742333c080d64427 100644 (file)
@@ -1127,7 +1127,6 @@ float autocvar_sv_airspeedlimit_nonqw;
 float autocvar_sv_airstopaccelerate;
 float autocvar_sv_airstrafeaccel_qw;
 float autocvar_sv_airstrafeaccelerate;
-float autocvar_sv_allow_shownames;
 float autocvar_sv_autoscreenshot;
 float autocvar_sv_cheats;
 float autocvar_sv_curl_serverpackages_auto;
@@ -1244,4 +1243,3 @@ float autocvar_waypoint_benchmark;
 float autocvar_welcome_message_time;
 float autocvar_sv_gameplayfix_gravityunaffectedbyticrate;
 float autocvar_g_trueaim_minrange;
-float autocvar_sv_shownames_cull_distance;
index 1406e13b8fc528f359611a7b11823c2a6783d94c..f699e6db2f3e1733ebb87e708d60c6fc84b91919 100644 (file)
@@ -735,9 +735,6 @@ void PutObserverInServer (void)
        }
        else
                self.frags = FRAGS_SPECTATOR;
-
-    if(self.shownames)
-        remove(self.shownames);
 }
 
 void FixPlayermodel()
@@ -1103,15 +1100,6 @@ void PutClientInServer (void)
                PutObserverInServer ();
        }
 
-    if(!self.shownames)
-    {
-        self.shownames = spawn();
-        self.shownames.owner = self;
-        self.shownames.think = shownames_think;
-        self.shownames.nextthink = time;
-        Net_LinkEntity(self.shownames, FALSE, 0, SendEntity_ShowNames);
-    }
-
        //if(g_ctf)
        //      ctf_playerchanged();
 }
@@ -1880,8 +1868,6 @@ void ClientDisconnect (void)
        self.playerid = 0;
        ReadyCount();
 
-    remove(self.shownames);
-
        // free cvars
        GetCvars(-1);
 }
index 13953f13ac9178c1fffacac276d5fa2b26c6a6ed..c4bcded2805f99d4546ff023ddb27dee68b29eec 100644 (file)
@@ -735,49 +735,6 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        }
 }
 
-// sendflags use: 1 = health (value is 0 or 1 for dead/alive on enemies), 2 = armor, 0x80 = same team (includes health)
-float SendEntity_ShowNames(entity to, float sendflags)
-{
-    float the_health;
-    the_health = self.health;
-
-    WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES);
-    WriteByte(MSG_ENTITY, num_for_edict(self.owner));
-
-    sendflags = sendflags & 127;
-    if(teams_matter && self.owner.team == to.team)
-        sendflags |= 128;
-    else if(self.owner.health >= 1)
-        the_health = 1;
-
-    WriteByte(MSG_ENTITY, sendflags);
-    if(sendflags & 1)
-    {
-        WriteByte(MSG_ENTITY, the_health);
-    }
-    if(sendflags & 2)
-    {
-        WriteByte(MSG_ENTITY, self.armorvalue);
-    }
-    return TRUE;
-}
-
-void shownames_think()
-{
-    self.origin = self.owner.origin + '0 0 1' * 48;
-    if(self.health != max(0, ceil(self.owner.health/10)))
-    {
-        self.health = max(0, ceil(self.owner.health/10));
-        self.SendFlags |= 1;
-    }
-    if(self.armorvalue != max(0, ceil(self.owner.armorvalue/10)))
-    {
-        self.armorvalue = max(0, ceil(self.owner.armorvalue/10));
-        self.SendFlags |= 2;
-    }
-    self.nextthink = time;
-}
-
 .float muted; // to be used by prvm_edictset server playernumber muted 1
 float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol)
 // message "": do not say, just test flood control
index 19f0c24a5981c6d2c4001623c99188b17fc5abf7..f3c754151e87ac719a10ff11bdc9758160b92e66 100644 (file)
@@ -664,6 +664,3 @@ float serverflags;
 
 .entity muzzle_flash;
 .float misc_bulletcounter;     // replaces uzi & hlac bullet counter.
-
-.entity shownames;
-void shownames_think();
index 970f20a9205a1bdc3200fae83f477ed38dcc8226..0a477b1b4d5298738f52c5c778cc7cdf3d8aa839 100644 (file)
@@ -39,20 +39,27 @@ float entcs_customize()
 
 float entcs_send(entity to, float sf)
 {
-       entity o;
-       o = self.owner;
+       sf |= 128;
+       if(teams_matter && !radar_showennemies)
+               if(to.team != self.team)
+                       sf &~= (8 | 16 | 128); // don't send h/a for enemies
+
        WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS);
        WriteByte(MSG_ENTITY, sf);
        if(sf & 1)
-               WriteByte(MSG_ENTITY, num_for_edict(o));
+               WriteByte(MSG_ENTITY, num_for_edict(self.owner));
        if(sf & 2)
        {
-               WriteShort(MSG_ENTITY, o.origin_x);
-               WriteShort(MSG_ENTITY, o.origin_y);
-               WriteShort(MSG_ENTITY, o.origin_z);
+               WriteShort(MSG_ENTITY, self.origin_x);
+               WriteShort(MSG_ENTITY, self.origin_y);
+               WriteShort(MSG_ENTITY, self.origin_z);
        }
        if(sf & 4)
-               WriteByte(MSG_ENTITY, o.angles_y * 256.0 / 360);
+               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;
 };
 
@@ -73,6 +80,16 @@ void entcs_think()
                self.angles = o.angles;
                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()