From 970b6f16bcf7df4234e5c085d0944ef31215ef25 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 28 Aug 2016 18:12:10 +1000 Subject: [PATCH] entcs: upgrade to linked entity, don't throw away --- qcsrc/common/ent_cs.qc | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index 5b48ef668..24440b61e 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -169,32 +169,38 @@ { int n = ReadByte(); entity e = entcs_receiver(n); + #define X(e) { \ + setthink(e, entcs_think); \ + entcs_receiver(n, e); \ + } if (e == NULL) { - if (this) + if (!this) { - e = this; + // initial = temp + e = new_pure(entcs_receiver); + X(e); } else { - e = new(entcs_receiver); - make_pure(e); + // initial = linked + e = this; + X(e); } - e.sv_entnum = n; - setthink(e, entcs_think); - entcs_receiver(n, e); } - else if (this && e != this) + else if (e != this && this) { - this.classname = "entcs_gc"; - this.sv_entnum = n; + // upgrade to linked + delete(e); + e = this; + X(e); } - this = e; - InterpolateOrigin_Undo(this); - this.sv_entnum = n; + #undef X + InterpolateOrigin_Undo(e); + e.sv_entnum = n; int sf = ReadShort(); - this.has_sv_origin = false; - this.m_entcs_private = boolean(sf & BIT(0)); + e.has_sv_origin = false; + e.m_entcs_private = boolean(sf & BIT(0)); int i = 0; #define X(public, fld, sv, cl) { \ if (sf & BIT(i)) { \ @@ -204,9 +210,9 @@ } ENTCS_NETPROPS(X); #undef X - this.iflags |= IFLAG_ORIGIN; - InterpolateOrigin_Note(this); - getthink(this)(this); + e.iflags |= IFLAG_ORIGIN; + InterpolateOrigin_Note(e); + getthink(e)(e); return true; } -- 2.39.2