From 8632f15617e026160fd46d36d7c848d195379bd0 Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 4 Dec 2015 17:32:24 +1100 Subject: [PATCH] entcs: collect garbage --- qcsrc/common/ent_cs.qc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index 732a1d455..4aa31ed01 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -130,7 +130,10 @@ void Ent_RemoveEntCS() { SELFPARAM(); - entcs_receiver(this.sv_entnum, NULL); + int n = this.sv_entnum; + entity e = entcs_receiver(n); + entcs_receiver(n, NULL); + if (e != this) remove(e); } void entcs_think() @@ -155,9 +158,8 @@ bool ReadEntcs(entity this) { int n = ReadByte(); - if (this) this.sv_entnum = n; entity e = entcs_receiver(n); - if (!e) + if (e == NULL) { if (this) { @@ -167,10 +169,16 @@ { e = new(entcs_receiver); make_pure(e); - e.think = entcs_think; } + e.sv_entnum = n; + e.think = entcs_think; entcs_receiver(n, e); } + else if (this && e != this) + { + this.classname = "entcs_gc"; + this.sv_entnum = n; + } this = e; InterpolateOrigin_Undo(this); this.sv_entnum = n; -- 2.39.2