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); break;
+ default: tex = "particles/hook_white"; rgb = getcsqcplayercolor(self.sv_entnum - 1); break;
}
break;
case NET_ENT_CLIENT_ARC_BEAM: // todo
float stringwidth_colors(string s, vector theSize);
float stringwidth_nocolors(string s, vector theSize);
-float GetPlayerColorForce(int i);
-int GetPlayerColor(int i);
-string GetPlayerName(int i);
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag);
.int panel_showflags;
}
}
-// TODO: entcs
-float getplayeralpha(int pl)
-{
- entity e = CSQCModel_server2csqc(pl + 1);
- return (e) ? e.alpha : 1;
-}
-
-// TODO: entcs
-vector getcsqcplayercolor(int pl)
-{
- entity e = CSQCModel_server2csqc(pl);
- return (e && e.colormap > 0) ? colormapPaletteColor(((e.colormap >= 1024) ? e.colormap : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 0x0F, true) : '1 1 1';
-}
-
-// TODO: entcs
-bool getplayerisdead(int pl)
-{
- entity e = CSQCModel_server2csqc(pl + 1);
- return e ? e.csqcmodel_isdead : false;
-}
-
/** engine callback */
void URI_Get_Callback(int id, float status, string data)
{
vector rotate(vector v, float a);
-string ColorTranslateRGB(string s);
-
// decolorizes and team colors the player name when needed
string playername(string thename, float teamid);
void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
-float getplayeralpha(float pl);
-
-vector getcsqcplayercolor(float pl);
-
-float getplayerisdead(float pl);
-
const int MAX_ACCURACY_LEVELS = 10;
float acc_lev[MAX_ACCURACY_LEVELS];
vector acc_col[MAX_ACCURACY_LEVELS];
if (autocvar_hud_shownames_antioverlap)
{
// fade tag out if another tag that is closer to you overlaps
- LL_EACH(shownames_ent, true, LAMBDA(
- entity entcs = entcs_receiver(i);
- if (!entcs || it == this) continue;
+ LL_EACH(shownames_ent, it != this && entcs_receiver(i), LAMBDA(
vector eo = project_3d_to_2d(it.origin);
if (eo.z < 0 || eo.x < 0 || eo.y < 0 || eo.x > vid_conwidth || eo.y > vid_conheight) continue;
eo.z = 0;
bool entcs_send(entity this, entity to, int sf)
{
entity player = this.owner;
- sf |= 1;
+ sf |= BIT(0) | BIT(1);
if (IS_PLAYER(to) || to.caplayer) // unless spectating,
{
bool same_team = (to == player) || (teamplay && player.team == to.team);
{
SELFPARAM();
this.nextthink = time;
- entity e = CSQCModel_server2csqc(this.sv_entnum + 1);
+ entity e = CSQCModel_server2csqc(this.sv_entnum);
bool exists = e != NULL;
if (exists)
{
InterpolateOrigin_Undo(this);
int sf = ReadShort();
this.has_sv_origin = false;
- this.m_entcs_private = boolean(sf & 1);
+ this.m_entcs_private = boolean(sf & BIT(0));
int i = 1;
#define X(public, fld, sv, cl) { if (sf & BIT(i)) cl; } i += 1;
ENTCS_NETPROPS(X);
.bool has_sv_origin;
#ifdef SVQC
-/**
+/*
* The point of these entities is to avoid the problems
* with clientprediction.
* If you add SendEntity to players, the engine will not
* in onslaught... YAY ;)
*/
-.entity entcs;
+ .entity entcs;
-bool entcs_send(entity this, entity to, int sf);
+ bool entcs_send(entity this, entity to, int sf);
-void entcs_think();
+ void entcs_think();
-void entcs_attach(entity e);
+ void entcs_attach(entity e);
-void entcs_detach(entity e);
+ void entcs_detach(entity e);
-.int m_forceupdate;
+ .int m_forceupdate;
/** Force an origin update, for player sounds */
-#define entcs_force_origin(e) ((e).entcs.m_forceupdate = BIT(2))
+ #define entcs_force_origin(e) ((e).entcs.m_forceupdate = BIT(2))
#endif
#ifdef CSQC
-AL_declare(_entcs);
-STATIC_INIT(_entcs)
-{
- AL_init(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
-}
-SHUTDOWN(_entcs)
-{
- AL_delete(_entcs);
-}
-#define entcs_receiver(...) EVAL(OVERLOAD(entcs_receiver, __VA_ARGS__))
-#define entcs_receiver_1(i) AL_gete(_entcs, i)
-#define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
-#define entcs_is_self(e) ((e).sv_entnum + 1 == player_localentnum)
+ AL_declare(_entcs);
+ STATIC_INIT(_entcs)
+ {
+ AL_init(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
+ }
+ SHUTDOWN(_entcs)
+ {
+ AL_delete(_entcs);
+ }
+ #define entcs_receiver(...) EVAL(OVERLOAD(entcs_receiver, __VA_ARGS__))
+ #define entcs_receiver_1(i) AL_gete(_entcs, i)
+ #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
+ * @returns 0 if not teamplay
+ */
+ int GetPlayerColorForce(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)
+ {
+ bool unconnected = !playerslots[i].gotscores;
+ bool spec = unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR;
+ return (spec) ? NUM_SPECTATOR : GetPlayerColorForce(i);
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ string GetPlayerName(int i)
+ {
+ return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ entity CSQCModel_server2csqc(int i);
+
+ .float alpha;
+
+ /**
+ * @param i zero indexed player
+ */
+ float getplayeralpha(int i)
+ {
+ entity e = CSQCModel_server2csqc(i);
+ return e ? e.alpha : 1;
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ vector getcsqcplayercolor(int i)
+ {
+ entity e = CSQCModel_server2csqc(i);
+ return (!e || e.colormap <= 0)
+ ? '1 1 1'
+ : colormapPaletteColor(((e.colormap >= 1024)
+ ? e.colormap
+ : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 15, true)
+ ;
+ }
+
+ /**
+ * @param i zero indexed player
+ */
+ bool getplayerisdead(int i)
+ {
+ entity e = CSQCModel_server2csqc(i);
+ return e ? e.csqcmodel_isdead : false;
+ }
#endif
vector old_camera_angle = '0 0 0';
void viewloc_SetViewLocation()
{
- entity view = CSQCModel_server2csqc(player_localentnum);
+ entity view = CSQCModel_server2csqc(player_localentnum - 1);
if (!view) return;
//NOTE: the "cam_" cvars sould probably be changed out with a spawnflag or an entity key. I have it like this for my testing -- Player_2
if(view.viewloc && !wasfreed(view.viewloc) && view.viewloc.enemy && view.viewloc.goalentity)
if(a < ALPHA_MIN_VISIBLE) { remove(self); }
// WEAPONTODO: save this only once when creating the entity
- vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
+ vector sw_color = getcsqcplayercolor(self.sv_entnum - 1); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
// WEAPONTODO: trace to find what we actually hit
vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
string tex = "particles/lgbeam";
if(this.cnt)
tex = "particles/gauntletbeam";
- vector rgb = getcsqcplayercolor(this.sv_entnum);
+ vector rgb = getcsqcplayercolor(this.sv_entnum - 1);
rgb *= (1 + autocvar_cl_vaporizerbeam_colorboost);
float fail = (self.nextthink - time);
#include "noise.qc"
#include "oo.qh"
#include "p2mathlib.qc"
-#include "player.qh"
#include "progname.qh"
#include "random.qc"
#include "registry.qh"
return true;
}
-entity CSQCModel_server2csqc(int pl)
+/**
+ * @param i zero indexed player
+ */
+entity CSQCModel_server2csqc(int i)
{
- if (pl <= maxclients) return CSQCModel_players[pl - 1];
- LOG_WARNINGF("player out of bounds: %d\n", pl);
- return findfloat(NULL, entnum, pl);
+ if (i < maxclients) return CSQCModel_players[i];
+ ++i;
+ LOG_WARNINGF("player out of bounds: %d\n", i);
+ return findfloat(NULL, entnum, i);
}
#undef CSQCMODEL_ENDIF
#undef CSQCMODEL_IF
-entity CSQCModel_server2csqc(float pl);
+entity CSQCModel_server2csqc(int i);
.float csqcmodel_teleported;
// this is exported for custom frame animation code. Use with care.
setorigin(e, e.origin);
}
- const entity view = CSQCModel_server2csqc(player_localentnum);
+ const entity view = CSQCModel_server2csqc(player_localentnum - 1);
if (view)
{
if (view != csqcplayer)
+++ /dev/null
-#ifdef CSQC
-#ifndef PLAYER_H
- #define PLAYER_H
-
- #include "string.qh"
-
- #include "../client/main.qh"
- #include "../common/teams.qh"
-
- int GetPlayerColorForce(int i)
- {
- if (!teamplay) return 0;
- else return stof(getplayerkeyvalue(i, "colors")) & 15;
- }
-
- int GetPlayerColor(int i)
- {
- if (!playerslots[i].gotscores) // unconnected
- return NUM_SPECTATOR;
- else if (stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR) return NUM_SPECTATOR;
- else return GetPlayerColorForce(i);
- }
-
- string GetPlayerName(int i)
- {
- return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
- }
-
-#endif
-#endif