}
}
+.float health, armorvalue;
+void Ent_ShowNames()
+{
+ float sf, the_entnum;
+
+ sf = ReadByte();
+ the_entnum = ReadByte();
+
+ 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 # ", ftos(the_entnum), "\n");
+ }
+ if(sf & 2)
+ {
+ playerslots[the_entnum].health = ReadByte();
+ playerslots[the_entnum].armorvalue = ReadByte();
+ print("Updated health/armor = ", ftos(playerslots[the_entnum].health), "/", ftos(playerslots[the_entnum].health), " for player # ", ftos(the_entnum), "\n");
+ }
+ if(sf & 4)
+ playerslots[the_entnum].netname = ReadString();
+
+ /*
+ string thename;
+ float thehealth, thearmor;
+
+ if(shownames_netname)
+ strunzone(shownames_netname);
+ thename = strzone(ReadString());
+ thehealth = ReadByte();
+ thearmor = ReadByte();
+
+ if(autocvar_hud_panel_shownames == 1 && thehealth > 0) // teammates only
+ {
+ shownames_netname = thename;
+ shownames_health = thehealth;
+ shownames_armor = thearmor;
+
+ shownames_time = time + autocvar_hud_panel_shownames_sustain;
+ }
+ else if(autocvar_hud_panel_shownames == 2)
+ {
+ shownames_netname = thename;
+ shownames_health = thehealth;
+ shownames_armor = thearmor;
+
+ shownames_time = time + autocvar_hud_panel_shownames_sustain;
+ }
+ */
+}
+
// 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();
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));
break;
weapontime = time; // ping the weapon panel
}
-void Net_ShowNames()
-{
- string thename;
- float thehealth, thearmor;
-
- if(shownames_netname)
- strunzone(shownames_netname);
- thename = strzone(ReadString());
- thehealth = ReadByte();
- thearmor = ReadByte();
-
- if(autocvar_hud_panel_shownames == 1 && thehealth > 0) // teammates only
- {
- shownames_netname = thename;
- shownames_health = thehealth;
- shownames_armor = thearmor;
-
- shownames_time = time + autocvar_hud_panel_shownames_sustain;
- }
- else if(autocvar_hud_panel_shownames == 2)
- {
- shownames_netname = thename;
- shownames_health = thehealth;
- shownames_armor = thearmor;
-
- shownames_time = time + autocvar_hud_panel_shownames_sustain;
- }
-}
-
// CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
// You must ALWAYS first acquire the temporary ID, which is sent as a byte.
// Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
Net_WeaponComplain();
bHandled = true;
break;
- case TE_CSQC_SHOWNAMES:
- Net_ShowNames();
- bHandled = true;
- break;
default:
// No special logic for this temporary entity; return 0 so the engine can handle it
bHandled = false;
const float TE_CSQC_WEAPONCOMPLAIN = 113;
const float TE_CSQC_NEX_SCOPE = 116;
const float TE_CSQC_MINELAYER_MAXMINES = 117;
-const float TE_CSQC_SHOWNAMES = 118;
const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
const float RACE_NET_CHECKPOINT_CLEAR = 1;
const float ENT_CLIENT_LGBEAM = 28;
const float ENT_CLIENT_GAUNTLET = 29;
const float ENT_CLIENT_ACCURACY = 30;
+const float ENT_CLIENT_SHOWNAMES = 31;
const float ENT_CLIENT_TURRET = 40;
CheatInitClient();
PlayerStats_AddPlayer(self);
+
+ self.shownames = spawn();
+ self.shownames.owner = self;
+ self.shownames.think = shownames_think;
+ Net_LinkEntity(self.shownames, FALSE, 0, SendEntity_ShowNames);
}
/*
self.playerid = 0;
ReadyCount();
+ remove(self.shownames);
+
// free cvars
GetCvars(-1);
}
self.effects = self.effects - (self.effects & EF_NODRAW);
}
- if(frametime > 0) // don't do this in cl_movement frames, just in server ticks
- UpdateSelectedPlayer();
-
//don't allow the player to turn around while game is paused!
if(timeoutStatus == 2) {
self.v_angle = self.lastV_angle;
}
}
-void net_shownames(entity selected, float teammate)
+.float the_entnum;
+// sendflags use: 1 = origin, 2 = health/armor, 0x80 = same team (includes health)
+float SendEntity_ShowNames(entity to, float sendflags)
{
- float teammate_health, teammate_armor;
- if(teammate)
+ WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES);
+ //sendflags &= 127;
+ if(teams_matter && self.team == to.team)
+ sendflags |= 128;
+ else
+ sendflags &~= 2;
+ WriteByte(MSG_ENTITY, sendflags);
+ WriteByte(MSG_ENTITY, self.the_entnum);
+ if(sendflags & 1)
{
- teammate_health = selected.health;
- teammate_armor = selected.armorvalue;
+ WriteShort(MSG_ENTITY, rint(self.origin_x));
+ WriteShort(MSG_ENTITY, rint(self.origin_y));
+ WriteShort(MSG_ENTITY, rint(self.origin_z));
}
-
- msg_entity = self;
- WRITESPECTATABLE_MSG_ONE({
- WriteByte(MSG_ONE, SVC_TEMPENTITY);
- WriteByte(MSG_ONE, TE_CSQC_SHOWNAMES);
- WriteString(MSG_ONE, playername(selected));
- WriteByte(MSG_ONE, teammate_health);
- WriteByte(MSG_ONE, teammate_armor);
- });
+ if(sendflags & 2)
+ {
+ WriteByte(MSG_ENTITY, self.health);
+ WriteByte(MSG_ENTITY, self.armorvalue);
+ }
+ return TRUE;
}
-void UpdateSelectedPlayer()
+void shownames_think()
{
- entity selected;
- selected = world;
-
- if(!autocvar_sv_allow_shownames)
- return;
-
- if(clienttype(self) != CLIENTTYPE_REAL)
- return;
-
- if(self.cvar_cl_shownames == 0)
- return;
-
- makevectors(self.v_angle); // sets v_forward
-
- // cursor trace
- if(self.selected_player_display_timeout < time)
+ if(self.origin != self.owner.origin)
{
- WarpZone_crosshair_trace(self);
- if(trace_ent && trace_ent.classname == "player" && !trace_ent.deadflag)
- {
- selected = trace_ent;
- self.last_selected_player = selected;
- self.selected_player_display_timeout = time + 0.1; // update at 0.1s intervals
- }
+ setorigin(self, self.owner.origin);
+ self.SendFlags |= 1;
}
-
- if(selected)
- {
- if(teams_matter && self.team == selected.team)
- net_shownames(selected, 1);
- else
- net_shownames(selected, 0);
+ if(self.health != self.owner.health || self.armorvalue != self.owner.armorvalue)
+ {
+ self.health = self.owner.health;
+ self.armorvalue = self.owner.armorvalue;
+ self.SendFlags |= 2;
+ }
+ if(self.the_entnum != num_for_edict(self.owner))
+ {
+ self.the_entnum = num_for_edict(self);
}
}
.float cvar_cl_handicap;
.float cvar_cl_playerdetailreduction;
.float cvar_scr_centertime;
-.float cvar_cl_shownames;
.string cvar_g_xonoticversion;
.string cvar_cl_weaponpriority;
.string cvar_cl_weaponpriorities[10];
float W_WeaponBit(float wpn);
string W_Name(float weaponid);
-void UpdateSelectedPlayer();
-.entity last_selected_player;
-.float selected_player_display_timeout; // when the selection will time out
-
void FixIntermissionClient(entity e);
void FixClientCvars(entity e);
.entity muzzle_flash;
.float misc_bulletcounter; // replaces uzi & hlac bullet counter.
+
+.entity shownames;
+void shownames_think();
replacement = cursor_ent.netname;
if (!replacement || !cursor_ent)
replacement = "nothing";
- } else if (escape == "p") {
- if (self.last_selected_player)
- replacement = self.last_selected_player.netname;
- else
- replacement = "(nobody)";
} else if (escape == "s")
replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1'));
else if (escape == "S")
GetCvars_handleFloat(s, f, autoswitch, "cl_autoswitch");
GetCvars_handleFloat(s, f, cvar_cl_playerdetailreduction, "cl_playerdetailreduction");
GetCvars_handleFloat(s, f, cvar_scr_centertime, "scr_centertime");
- GetCvars_handleFloat(s, f, cvar_cl_shownames, "cl_shownames");
GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion");
GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap");
GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);