]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
entcs: collect garbage
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 4 Dec 2015 06:32:24 +0000 (17:32 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Fri, 4 Dec 2015 06:33:19 +0000 (17:33 +1100)
qcsrc/common/ent_cs.qc

index 732a1d455c8cb8046eee6013266c14d466db6486..4aa31ed01e8d02d119331b6cc2245ec998ba5df6 100644 (file)
        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()
        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)
                        {
                        {
                                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;