]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/intrusivelist.qh
Add minor optimizations and comments
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / intrusivelist.qh
index dce561bb5124e1bb4d287e483ec80400988cd2b0..63a21565601085c4e34ce72c8aff021ae5fa70e6 100644 (file)
@@ -3,7 +3,7 @@
 #include "iter.qh"
 
 /**
- * This limitation is only towards maximum amount of creatable lists.
+ * Maximum amount of creatable lists.
  * Lists can be given endless amount of entities, only restricted by engine limitations.
  */
 const int IL_MAX = 128;
@@ -246,13 +246,16 @@ void IL_ENDFRAME()
 #endif
 }
 
-ERASEABLE
+// called when an entity is deleted with delete() / remove()
+// or when a player disconnects
 void ONREMOVE(entity this)
 {
-       if (this.il_lists) {
+       // remove 'this' from any intrusive lists it is on
+       vector lists = this.il_lists;
+       if (lists) {
                for (int i = 0; i < IL_MAX; ++i) {
                        IntrusiveList list = il_links[i];
-                       if ((this.il_lists & list.il_listmask) && IL_CONTAINS(list, this)) {
+                       if ((lists & list.il_listmask) && IL_CONTAINS(list, this)) {
                                IL_REMOVE(list, this);
                        }
                }