From: TimePath Date: Mon, 23 Nov 2015 05:44:43 +0000 (+1100) Subject: entcs: use ArrayList X-Git-Tag: xonotic-v0.8.2~1638 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8595e467f23b92a423e80896fa943cfa23896f54;p=xonotic%2Fxonotic-data.pk3dir.git entcs: use ArrayList --- diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index 38c94ae9f..6bcd343b9 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -168,7 +168,7 @@ void Draw_ShowNames_All() { if (!autocvar_hud_shownames) return; LL_EACH(shownames_ent, true, LAMBDA( - entity entcs = entcs_receiver[i]; + entity entcs = entcs_receiver(i); if (!entcs) continue; if (entcs.m_entcs_private) { diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index d2f8714ad..f7474de58 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -360,7 +360,7 @@ float TrueAimCheck() break; } - vector traceorigin = entcs_receiver[player_localentnum - 1].origin + (eZ * getstati(STAT_VIEWHEIGHT)); + vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * getstati(STAT_VIEWHEIGHT)); vecs = decompressShotOrigin(getstati(STAT_SHOTORG)); diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index 44f20b2b9..d920bd139 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -68,7 +68,7 @@ float r = ReadByte() / 255; string sample = GlobalSound_sample(gs.m_globalsoundstr, r); int who = ReadByte(); - entity e = entcs_receiver[who - 1]; + entity e = entcs_receiver(who - 1); int chan = ReadByte(); float vol = ReadByte() / 255; float atten = ReadByte() / 64; @@ -98,7 +98,7 @@ entity ps = PlayerSounds_from(ReadByte()); float r = ReadByte() / 255; int who = ReadByte(); - entity e = entcs_receiver[who - 1]; + entity e = entcs_receiver(who - 1); UpdatePlayerSounds(e); string s = e.(ps.m_playersoundfld); string sample = GlobalSound_sample(s, r); diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index c30e52af6..0098dbc5e 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -116,7 +116,7 @@ void Ent_RemoveEntCS() { SELFPARAM(); - entcs_receiver[this.sv_entnum] = NULL; + entcs_receiver(this.sv_entnum, NULL); } void entcs_think() @@ -160,7 +160,7 @@ #define X(public, fld, sv, cl) { if (sf & BIT(i)) cl; } i += 1; ENTCS_NETPROPS(X); #undef X - entcs_receiver[this.sv_entnum] = this; + entcs_receiver(this.sv_entnum, this); this.iflags |= IFLAG_ORIGIN; InterpolateOrigin_Note(this); return true; diff --git a/qcsrc/common/ent_cs.qh b/qcsrc/common/ent_cs.qh index 1e82e1563..6d9685c4b 100644 --- a/qcsrc/common/ent_cs.qh +++ b/qcsrc/common/ent_cs.qh @@ -40,7 +40,14 @@ void entcs_detach(entity e); #ifdef CSQC -entity entcs_receiver[255]; // 255 is the engine limit on maxclients +AL_declare(_entcs); +STATIC_INIT(_entcs) +{ + AL_init(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients +} +#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) #endif diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 78aaa9425..83d7e3fcb 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -1227,7 +1227,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew) else { // use player origin so that third person display still works - self.origin = entcs_receiver[player_localnum].origin + ('0 0 1' * getstati(STAT_VIEWHEIGHT)); + self.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * getstati(STAT_VIEWHEIGHT)); } }