From: TimePath Date: Fri, 4 Dec 2015 06:32:24 +0000 (+1100) Subject: entcs: collect garbage X-Git-Tag: xonotic-v0.8.2~1560 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8632f15617e026160fd46d36d7c848d195379bd0;p=xonotic%2Fxonotic-data.pk3dir.git entcs: collect garbage --- 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;