]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/ent_cs.qc
Weapons: store switchingweapon as direct weapon reference
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / ent_cs.qc
index bb716ca3b8970af0f4ffbf3b758e07e5042f829e..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;
        #undef X
                this.iflags |= IFLAG_ORIGIN;
                InterpolateOrigin_Note(this);
-               this.think();
+               WITH(entity, self, this, this.think());
                return true;
        }