]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
adapt shownames to use player positions shared from the engine
authorFruitieX <fruitiex@gmail.com>
Sat, 14 May 2011 18:06:19 +0000 (21:06 +0300)
committerFruitieX <fruitiex@gmail.com>
Sat, 14 May 2011 18:06:19 +0000 (21:06 +0300)
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/autocvars.qh
qcsrc/client/shownames.qc
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc

index 100b266b1d454490c67d77f246314a65e365af3c..29b4033562f44775b6e49959dafaf4dea7139595 100644 (file)
@@ -410,9 +410,7 @@ net_connecttimeout 30
 sv_jumpstep 1 // step up stairs while jumping, makes it easier to reach ledges
 set ekg 0      "Throw huge amounts of gibs"
 
-seta sv_shownames 1 "enable sending name tag information to clients (WARNING: possible bandwidth hog until we have CSQC players)"
 seta sv_shownames_cull_distance 2500 "distance after which to not send origin/health/armor of another player"
-seta sv_shownames_delay 0.2 "delay between shownames updates"
 
 cl_movement 1
 cl_movement_track_canjump 0
@@ -1510,6 +1508,7 @@ seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance"
 seta hud_shownames_maxdistance 2500 "alpha/size is 0 at this distance"
 seta hud_shownames_antioverlap 1 "if two tags get too close to each other, fade out the one further away from you"
 seta hud_shownames_antioverlap_distance 125 "2d distance to other tag after which to fade out"
+seta hud_shownames_offset 48 "offset (along z-axis) tag from player origin by this many units"
 
 // scoreboard
 seta scoreboard_columns default
index a89b4f45ad36277fe538c1e3fff47c871a6a0302..c0d979420afd41d6903ecc2990eb2bf1e0f48ddb 100644 (file)
@@ -897,26 +897,19 @@ void Ent_ShowNames()
     // 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;
-       InterpolateOrigin_Undo();
 
     //self.movetype = MOVETYPE_FLY; // movetype needed so we can traceline?
-    self.mins = '-20 -20 -24';
-    self.maxs = '20 20 45';
+    //self.mins = '-20 -20 -24';
+    //self.maxs = '20 20 45';
     self.classname = "shownames_tag";
 
     sf = ReadByte();
 
     if(sf & 1)
-    {
-        self.origin_x = ReadShort();
-        self.origin_y = ReadShort();
-        self.origin_z = ReadShort();
-    }
-    if(sf & 2)
     {
         self.healthvalue = ReadByte();
     }
-    if(sf & 4)
+    if(sf & 2)
     {
         self.armorvalue = ReadByte();
     }
@@ -925,7 +918,6 @@ void Ent_ShowNames()
         self.sameteam = TRUE;
     else
         self.sameteam = FALSE;
-       InterpolateOrigin_Note();
 }
 
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
index 1e48eed9de3e68e53a636a1fcbeb3a1c277d9ec9..5324d56ab84c3e471c3d5e85746172f07eaef9bd 100644 (file)
@@ -291,6 +291,7 @@ float autocvar_hud_shownames_mindistance;
 float autocvar_hud_shownames_maxdistance;
 float autocvar_hud_shownames_antioverlap;
 float autocvar_hud_shownames_antioverlap_distance;
+float autocvar_hud_shownames_offset;
 string autocvar_hud_skin;
 float autocvar_loddebug;
 float autocvar_menu_mouse_speed;
index f69c495fb0fa493b87867469b47f4c5f826e59ba..92b071ea18cb7444a94e5a6b63edcc6ec9069865 100644 (file)
@@ -12,12 +12,15 @@ void Draw_ShowNames()
 
     if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
     {
-        InterpolateOrigin_Do();
+        string temporigin;
+        temporigin = getplayerkey(self.the_entnum-1, "TEMPHACK_origin");
+        if(temporigin == "")
+            return;
+        self.origin = stov(temporigin);
+        self.origin_z += autocvar_hud_shownames_offset;
 
         if(!self.sameteam)
         {
-            traceline(self.origin, view_origin, 1, self);
-
             /* WIP, why does trace_ent != self not work as intended here?
             if(autocvar_hud_shownames_enemies != 2) // player has to point at enemy if so
             {
@@ -26,6 +29,8 @@ void Draw_ShowNames()
                 if(trace_ent != self)
                     return;
             }*/
+
+            traceline(self.origin, view_origin, 1, self);
         }
 
         vector o, eo;
index 49f37ed30885874d87e0d3c686e51d015510ee1c..70719e0d7c9f03e09f3c24c16634b251db7074b5 100644 (file)
@@ -1244,6 +1244,4 @@ float autocvar_waypoint_benchmark;
 float autocvar_welcome_message_time;
 float autocvar_sv_gameplayfix_gravityunaffectedbyticrate;
 float autocvar_g_trueaim_minrange;
-float autocvar_sv_shownames;
 float autocvar_sv_shownames_cull_distance;
-float autocvar_sv_shownames_delay;
index 494004198512a2faf805f0cf5ca715fc261a8ad1..329a0f9b822f2ae342491351abcc238fd2c53217 100644 (file)
@@ -1774,15 +1774,12 @@ void ClientConnect (void)
 
        PlayerStats_AddPlayer(self);
 
-    if(autocvar_sv_shownames)
-    {
-        self.shownames = spawn();
-        self.shownames.owner = self;
-        self.shownames.think = shownames_think;
-        self.shownames.nextthink = time;
-        self.shownames.customizeentityforclient = shownames_customize;
-        Net_LinkEntity(self.shownames, FALSE, 0, SendEntity_ShowNames);
-    }
+    self.shownames = spawn();
+    self.shownames.owner = self;
+    self.shownames.think = shownames_think;
+    self.shownames.nextthink = time;
+    self.shownames.customizeentityforclient = shownames_customize;
+    Net_LinkEntity(self.shownames, FALSE, 0, SendEntity_ShowNames);
 }
 
 /*
index 74639426a5a21fadf167449339a77f67d11c74aa..7bb1d6851d4ad637ee64fef59b2a4d54df186c0a 100644 (file)
@@ -735,7 +735,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        }
 }
 
-// sendflags use: 1 = origin, 2 = health (0 or 1 for dead/alive on enemies), 4 = armor, 0x80 = same team (includes health)
+// 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;
@@ -752,50 +752,39 @@ float SendEntity_ShowNames(entity to, float sendflags)
 
     WriteByte(MSG_ENTITY, sendflags);
     if(sendflags & 1)
-    {
-        WriteShort(MSG_ENTITY, rint(self.origin_x));
-        WriteShort(MSG_ENTITY, rint(self.origin_y));
-        WriteShort(MSG_ENTITY, rint(self.origin_z));
-    }
-    if(sendflags & 2)
     {
         WriteByte(MSG_ENTITY, the_health);
     }
-    if(sendflags & 4)
+    if(sendflags & 2)
     {
         WriteByte(MSG_ENTITY, self.armorvalue);
     }
     return TRUE;
 }
 
-const vector SHOWNAMES_ORIGIN_OFFSET = '0 0 48';
 void shownames_think()
 {
-    if(self.origin - SHOWNAMES_ORIGIN_OFFSET != self.owner.origin)
-    {
-        setorigin(self, self.owner.origin + SHOWNAMES_ORIGIN_OFFSET);
-        self.SendFlags |= 1;
-    }
+    self.origin = self.owner.origin + '0 0 1' * 48;
     if(self.health != max(0, floor(self.owner.health)) || self.armorvalue != max(0, floor(self.owner.armorvalue)))
     {
         self.health = max(0, floor(self.owner.health));
         self.armorvalue = max(0, floor(self.owner.armorvalue));
-        self.SendFlags |= 2;
+        self.SendFlags |= 1;
     }
     if(self.armorvalue != max(0, floor(self.owner.armorvalue)))
     {
         self.armorvalue = max(0, floor(self.owner.armorvalue));
-        self.SendFlags |= 4;
+        self.SendFlags |= 2;
     }
-    self.nextthink = time + autocvar_sv_shownames_delay;
+    self.nextthink = time;
 }
 
 float shownames_customize()
 {
     if(self.owner.classname == "player") // only send players, no spectators!
-    if(self.owner != other) // no need to spam own coordinates
+    if(self.owner != other) // no need to spam own info
     if(vlen(other.origin - self.origin) < autocvar_sv_shownames_cull_distance) // distance cull
-    if(self.owner.team == other.team || (self.owner.team != other.team && checkpvs(self.origin, other)))
+    if((teams_matter && self.owner.team == other.team) || checkpvs(self.origin, other))
         return TRUE;
 
     return FALSE;