]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
entcs: cleanup
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 25 Nov 2015 23:13:23 +0000 (10:13 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 25 Nov 2015 23:59:17 +0000 (10:59 +1100)
15 files changed:
qcsrc/client/hook.qc
qcsrc/client/hud/hud.qh
qcsrc/client/miscfunctions.qc
qcsrc/client/miscfunctions.qh
qcsrc/client/shownames.qc
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/common/viewloc.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/lib/_all.inc
qcsrc/lib/csqcmodel/cl_model.qc
qcsrc/lib/csqcmodel/cl_model.qh
qcsrc/lib/csqcmodel/cl_player.qc
qcsrc/lib/player.qh [deleted file]

index f39e8eaa45d60944cd141001484ad97452931d58..e8bd4432162f947c541b737d80c732cec61e2f37 100644 (file)
@@ -106,7 +106,7 @@ void Draw_GrapplingHook(entity this)
                                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
index 7762d16c03706cfb6791238a11867674fbe92214..764a526b9b950e91c8ca847ad27a0862f4f22828 100644 (file)
@@ -150,9 +150,6 @@ float current_player;
 
 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;
index bbe0722fd7dad9464b9a8df5a3d1ceb7537d3059..673cf00f1bf8bb1666636b34477bd60cef16bc5e 100644 (file)
@@ -482,27 +482,6 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector
        }
 }
 
-// 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)
 {
index 520b5e47de7196597d7bae4a198d7b7b741de665..ddac22e8dab42c07f560372bd795ee0e4cf564cf 100644 (file)
@@ -35,8 +35,6 @@ float PreviewExists(string name);
 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);
 
@@ -143,12 +141,6 @@ void PolyDrawModel(entity e);
 
 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];
index f345f05106edd8f5f500123941cd0c20a540bc52..f13efdde050df357b3f98e3f14d74b56e1624bf4 100644 (file)
@@ -53,9 +53,7 @@ void Draw_ShowNames(entity this)
        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;
index 0098dbc5ea2cf26eb63109298443850c8b2cff15..c07fad0d5242fc08dc7a9e1c26b1d79d98c6bee3 100644 (file)
@@ -52,7 +52,7 @@
        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);
index c853ac1a19a8bf2bb320546580da43c916ea098f..7f773527b073f34b85907ee481e4442bd38f28fd 100644 (file)
@@ -11,7 +11,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
 .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
@@ -21,38 +21,105 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
  * 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
 
index 9e3e2489128cc60e2fe7db31e2ed6982e642d244..6371afc4d2c21e51ad17d1b0d6961b24ffdefbd0 100644 (file)
@@ -76,7 +76,7 @@ void viewloc_SetTags()
 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)
index b795cb7e9f393559e6d2d02a9226bafecebc4c18..dd1b1b1b9ca0cc93bda906d93bad71aa6486ff95 100644 (file)
@@ -744,7 +744,7 @@ void Draw_Shockwave(entity this)
        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));
index 8059f3272bcfddc8112579e22bc8ccd32f7de7fc..6e7e386e5de48ef6b89101280ea01b3e2c5e79e7 100644 (file)
@@ -103,7 +103,7 @@ void VaporizerBeam_Draw(entity this)
        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);
index 97483b518f459c7d96752d7c0b73868def0285db..24d2df747cf1c3dd649189e8b4a77382532b9b7b 100644 (file)
@@ -52,7 +52,6 @@
 #include "noise.qc"
 #include "oo.qh"
 #include "p2mathlib.qc"
-#include "player.qh"
 #include "progname.qh"
 #include "random.qc"
 #include "registry.qh"
index f9c23485e5d8e0206735b9310e965e00f535c68a..e84294522280bbe2a88061abc62991df71dcf027 100644 (file)
@@ -294,9 +294,13 @@ NET_HANDLE(ENT_CLIENT_MODEL, bool isnew)
        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);
 }
index 179350f9500bfa9b3ce5c10bcec0dac1342044dd..1f9d23b4dbec0d60141838685cf5d11b30f1f305 100644 (file)
@@ -35,7 +35,7 @@
 #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.
index f8ccee53365c80699d1d3d6eb77e704dfc7f7d99..17f6b4ce921ca3d90baec9c2c02791298b6ab07c 100644 (file)
@@ -272,7 +272,7 @@ void CSQCPlayer_SetCamera()
                setorigin(e, e.origin);
        }
 
-       const entity view = CSQCModel_server2csqc(player_localentnum);
+       const entity view = CSQCModel_server2csqc(player_localentnum - 1);
        if (view)
        {
                if (view != csqcplayer)
diff --git a/qcsrc/lib/player.qh b/qcsrc/lib/player.qh
deleted file mode 100644 (file)
index 6a8ce03..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#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