float uid2name_dialog;
-.bool csqcmodel_isdead; // used by shownames and miscfunctions (float getplayerisdead(float) {}) to know when a player is dead
+.bool csqcmodel_isdead; // used by shownames and miscfunctions (entcs_IsDead) to know when a player is dead
#define player_currententnum (spectatee_status > 0 ? spectatee_status : player_localnum + 1)
}
}
- t = GetPlayerColorForce(self.owner.sv_entnum);
+ t = entcs_GetTeamColor(self.owner.sv_entnum);
switch(self.HookType)
{
case NUM_TEAM_2: tex = "particles/hook_blue"; rgb = '0.3 0.3 1'; break;
case NUM_TEAM_3: tex = "particles/hook_yellow"; rgb = '1 1 0.3'; break;
case NUM_TEAM_4: tex = "particles/hook_pink"; rgb = '1 0.3 1'; break;
- default: tex = "particles/hook_white"; rgb = getcsqcplayercolor(self.sv_entnum - 1); break;
+ default: tex = "particles/hook_white"; rgb = entcs_GetColor(self.sv_entnum - 1); break;
}
break;
case NET_ENT_CLIENT_ARC_BEAM: // todo
if(spectatee_status == -1)
s = _("^1Observing");
else
- s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(current_player));
+ s = sprintf(_("^1Spectating: ^7%s"), entcs_GetName(current_player));
drawInfoMessage(s);
if(spectatee_status == -1)
drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
} else if(race_status == 2) {
- if(race_status_name == GetPlayerName(player_localnum) || !race_myrank || race_myrank < rank)
+ if(race_status_name == entcs_GetName(player_localnum) || !race_myrank || race_myrank < rank)
drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
else
drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
{
if (!tm.m_entcs_private) continue;
if (entcs_is_self(tm)) continue;
- color2 = GetPlayerColor(tm.sv_entnum);
+ color2 = entcs_GetTeam(tm.sv_entnum);
//if(color == NUM_SPECTATOR || color == color2)
draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2));
}
{
rgb = '1 1 0';
drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
- s = GetPlayerName(player_localnum);
+ s = entcs_GetName(player_localnum);
score = 7;
}
else
}
if (team_count)
score_color = Team_ColorRGB(pl.team) * 0.8;
- s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
+ s = textShortenToWidth(entcs_GetName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
pos.y += fontsize.y;
for(i = 0; i < maxclients; ++i)
{
e = playerslots[i];
- if(GetPlayerName(i) == "")
+ if(entcs_GetName(i) == "")
{
if(e.sort_prev)
{
e.ping_packetloss = 0;
e.ping_movementloss = 0;
//e.gotscores = 0; // we might already have the scores...
- SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
+ SetTeam(e, entcs_GetTeam(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
RegisterPlayer(e);
HUD_UpdatePlayerPos(e);
}
if(is_new)
{
- float teamnum = GetPlayerColor(entnum - 1);
+ float teamnum = entcs_GetTeam(entnum - 1);
if(autocvar_cl_spawn_event_particles)
{
strunzone(grecordholder[pos-1]);
grecordholder[pos-1] = strzone(ReadString());
grecordtime[pos-1] = ReadInt24_t();
- if(grecordholder[pos-1] == GetPlayerName(player_localnum))
+ if(grecordholder[pos-1] == entcs_GetName(player_localnum))
race_myrank = pos;
break;
case RACE_NET_SERVER_STATUS:
continue;
if(without_me && pl.sv_entnum == player_localnum)
continue;
- QUICKMENU_ENTRY(GetPlayerName(pl.sv_entnum), sprintf(cmd, GetPlayerName(pl.sv_entnum)))
+ QUICKMENU_ENTRY(entcs_GetName(pl.sv_entnum), sprintf(cmd, entcs_GetName(pl.sv_entnum)))
}
return;
for(pl = players.sort_next; pl; pl = pl.sort_next)
{
num += 1;
- Team = GetPlayerColor(pl.sv_entnum);
+ Team = entcs_GetTeam(pl.sv_entnum);
if(SetTeam(pl, Team))
{
tmp = pl.sort_prev;
float HUD_ComparePlayerScores(entity left, entity right)
{
float vl, vr, r;
- vl = GetPlayerColor(left.sv_entnum);
- vr = GetPlayerColor(right.sv_entnum);
+ vl = entcs_GetTeam(left.sv_entnum);
+ vr = entcs_GetTeam(right.sv_entnum);
if(!left.gotscores)
vl = NUM_SPECTATOR;
hud_field_icon2_rgb = colormapPaletteColor(f % 16, 1);
}
}
- return GetPlayerName(pl.sv_entnum);
+ return entcs_GetName(pl.sv_entnum);
case SP_FRAGS:
f = pl.(scores[SP_KILLS]);
string str;
int field;
float is_spec;
- is_spec = (GetPlayerColor(pl.sv_entnum) == NUM_SPECTATOR);
+ is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR);
if((rgb == '1 1 1') && (!is_spec)) {
rgb.x = autocvar_scoreboard_color_bg_r + 0.5;
return pos;
float is_spec;
- is_spec = (GetPlayerColor(pl.sv_entnum) == NUM_SPECTATOR);
+ is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR);
vector hl_rgb;
hl_rgb.x = autocvar_scoreboard_color_bg_r + 0.5;
hl_rgb.y = autocvar_scoreboard_color_bg_g + 0.5;
continue;
n = grecordholder[i];
p = count_ordinal(i+1);
- if(grecordholder[i] == GetPlayerName(player_localnum))
+ if(grecordholder[i] == entcs_GetName(player_localnum))
drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize.y, hl_rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
else if(!(i % 2) && scoreboard_highlight)
drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize.y, hl_rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
// multiply by player alpha
if (!this.sameteam || (this.sv_entnum == player_localentnum))
{
- float f = getplayeralpha(this.sv_entnum - 1);
+ float f = entcs_GetAlpha(this.sv_entnum - 1);
if (f == 0) f = 1;
if (f < 0) f = 0;
// FIXME: alpha is negative when dead, breaking death fade
DRAWFLAG_NORMAL);
}
}
- string s = GetPlayerName(this.sv_entnum - 1);
+ string s = entcs_GetName(this.sv_entnum - 1);
if ((autocvar_hud_shownames_decolorize == 1 && teamplay)
- || autocvar_hud_shownames_decolorize == 2) s = playername(s, GetPlayerColor(this.sv_entnum - 1));
+ || autocvar_hud_shownames_decolorize == 2) s = playername(s, entcs_GetTeam(this.sv_entnum - 1));
drawfontscale = '1 1 0' * resize;
s = textShortenToWidth(s, namewidth, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
float width = stringwidth(s, true, '1 1 0' * autocvar_hud_shownames_fontsize);
it.armorvalue = 0;
it.sameteam = false;
}
- bool dead = getplayerisdead(i);
+ bool dead = entcs_IsDead(i) || entcs_IsSpectating(i);
if (!it.csqcmodel_isdead && entcs.has_origin) setorigin(it, entcs.origin);
it.csqcmodel_isdead = dead;
Draw_ShowNames(it);
return SHOTTYPE_HITWORLD;
if(n > maxclients)
return SHOTTYPE_HITWORLD;
- t = GetPlayerColor(n - 1);
+ t = entcs_GetTeam(n - 1);
if(teamplay)
if(t == myteam)
return SHOTTYPE_HITTEAM;
current_player = player_localentnum - 1;
else // then player_localentnum is the vehicle I'm driving
current_player = player_localnum;
- myteam = GetPlayerColor(current_player);
+ myteam = entcs_GetTeam(current_player);
if(myteam != prev_myteam)
{
}
else
{
+ LOG_WARNINGF("Missing entcs data for player %d\n", who);
+ // Can this happen?
entity e = new(globalsound);
e.origin = o;
sound8(e, o, chan, sample, vol, atten, 0, 0);
#define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
#define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
+ /**
+ * @param i zero indexed player
+ */
+ bool entcs_IsSpectating(int i)
+ {
+ bool unconnected = !playerslots[i].gotscores;
+ return unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR;
+ }
+
/**
* @param i zero indexed player
* @returns 0 if not teamplay
*/
- int GetPlayerColorForce(int i)
+ int entcs_GetTeamColor(int i)
{
return (!teamplay) ? 0 : stof(getplayerkeyvalue(i, "colors")) & 15;
}
* @param i zero indexed player
* @returns 0 if not teamplay | NUM_TEAM_##N | NUM_SPECTATOR
*/
- int GetPlayerColor(int i)
+ int entcs_GetTeam(int i)
{
- bool unconnected = !playerslots[i].gotscores;
- bool spec = unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR;
- return (spec) ? NUM_SPECTATOR : GetPlayerColorForce(i);
+ return entcs_IsSpectating(i) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
}
/**
* @param i zero indexed player
*/
- string GetPlayerName(int i)
+ string entcs_GetName(int i)
{
return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
}
/**
* @param i zero indexed player
*/
- float getplayeralpha(int i)
+ float entcs_GetAlpha(int i)
{
entity e = CSQCModel_server2csqc(i);
return e ? e.alpha : 1;
/**
* @param i zero indexed player
*/
- vector getcsqcplayercolor(int i)
+ vector entcs_GetColor(int i)
{
entity e = CSQCModel_server2csqc(i);
return (!e || e.colormap <= 0)
/**
* @param i zero indexed player
*/
- bool getplayerisdead(int i)
+ bool entcs_IsDead(int i)
{
entity e = CSQCModel_server2csqc(i);
return e ? e.csqcmodel_isdead : false;
minigame_read_owner();
float ent = ReadLong();
self.minigame_playerslot = ent;
- LOG_DEBUG("Player: ",GetPlayerName(ent-1),"\n");
+ LOG_DEBUG("Player: ",entcs_GetName(ent-1),"\n");
activate = (ent == player_localnum+1 && self.owner && self.owner != active_minigame);
entity prev = self;
for(int i = 0; i < maxclients; ++i)
{
- if ( player_localnum != i && playerslots[i] && GetPlayerName(i) != "" &&
+ if ( player_localnum != i && playerslots[i] && entcs_GetName(i) != "" &&
!findfloat(world,minigame_playerslot,i+1) && playerslots[i].ping )
{
e = HUD_MinigameMenu_SpawnSubEntry(
- strzone(GetPlayerName(i)), HUD_MinigameMenu_ClickInvite_Entry,
+ strzone(entcs_GetName(i)), HUD_MinigameMenu_ClickInvite_Entry,
self );
e.flags |= 1;
e.netname = strzone(ftos(i+1));
{
mypos = pos;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
return false;
}
-#endif
\ No newline at end of file
+#endif
FOREACH_MINIGAME_ENTITY(e)
if ( e.classname == "minigame_player" &&
e.team == (active_minigame.minigame_flags & C4_TURN_TEAM) )
- playername = GetPlayerName(e.minigame_playerslot-1);
+ playername = entcs_GetName(e.minigame_playerslot-1);
vector win_pos = pos+eY*(mySize_y-winfs_y)/2;
vector win_sz;
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
FOREACH_MINIGAME_ENTITY(e)
if ( e.classname == "minigame_player" &&
e.team == (active_minigame.minigame_flags & NMM_TURN_TEAM) )
- playername = GetPlayerName(e.minigame_playerslot-1);
+ playername = entcs_GetName(e.minigame_playerslot-1);
vector win_pos = pos+eY*(mySize_y-winfs_y)/2;
vector win_sz;
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
}
else if ( e.classname == "minigame_board_piece" )
drawfill(mypos, ts, pong_team_to_color(e.team), 0.25, DRAWFLAG_ADDITIVE);
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- (e.minigame_playerslot ? GetPlayerName(e.minigame_playerslot-1) : _("AI")),
+ (e.minigame_playerslot ? entcs_GetName(e.minigame_playerslot-1) : _("AI")),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
drawstring(mypos+eY*player_fontsize_y,ftos(e.pong_score),'48 48 0',
FOREACH_MINIGAME_ENTITY(e)
if ( e.classname == "minigame_player" &&
e.team == (active_minigame.minigame_flags & PP_TURN_TEAM) )
- playername = GetPlayerName(e.minigame_playerslot-1);
+ playername = entcs_GetName(e.minigame_playerslot-1);
vector win_pos = pos+eY*(mySize_y-winfs_y)/2;
vector win_sz;
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
{
mypos = pos;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
if ( e.team > 1 )
mypos_y += player_fontsize_y + (ts_y * (e.team - 1));
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- GetPlayerName(e.minigame_playerslot-1),
+ entcs_GetName(e.minigame_playerslot-1),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
vector tile_color = snake_teamcolor(e.team);
return false;
}
-#endif
\ No newline at end of file
+#endif
if ( e.team == 2 )
mypos_y += player_fontsize_y + ts_y;
minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
- (e.minigame_playerslot ? GetPlayerName(e.minigame_playerslot-1) : _("AI")),
+ (e.minigame_playerslot ? entcs_GetName(e.minigame_playerslot-1) : _("AI")),
player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
mypos_y += player_fontsize_y;
InterpolateOrigin_Do(self);
- float t = GetPlayerColor(player_localnum) + 1;
+ float t = entcs_GetTeam(player_localnum) + 1;
string spriteimage = "";
return;
float dist = vlen(self.origin - view_origin);
- float t = (GetPlayerColor(player_localnum) + 1);
+ float t = (entcs_GetTeam(player_localnum) + 1);
vector o;
string txt;
if(a < ALPHA_MIN_VISIBLE) { remove(self); }
// WEAPONTODO: save this only once when creating the entity
- vector sw_color = getcsqcplayercolor(self.sv_entnum - 1); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
+ vector sw_color = entcs_GetColor(self.sv_entnum - 1); // GetTeamRGB(entcs_GetTeam(self.sv_entnum));
// WEAPONTODO: trace to find what we actually hit
vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));