From: FruitieX Date: Sat, 14 May 2011 18:06:19 +0000 (+0300) Subject: adapt shownames to use player positions shared from the engine X-Git-Tag: xonotic-v0.5.0~258 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=650b75b9a9e48d782653ed7f33bab05df8d7e00c;p=xonotic%2Fxonotic-data.pk3dir.git adapt shownames to use player positions shared from the engine --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 100b266b1..29b403356 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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 diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index a89b4f45a..c0d979420 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -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. diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 1e48eed9d..5324d56ab 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -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; diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index f69c495fb..92b071ea1 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -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; diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 49f37ed30..70719e0d7 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 494004198..329a0f9b8 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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); } /* diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 74639426a..7bb1d6851 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -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;