]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/effects/qc/rubble.qh
Tidy up classnames
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / qc / rubble.qh
index 1665e4ccef38e8c37db1d984dacea596214ff6b2..83f0ce855eda15d8371d10c1c49376bca57d60bb 100644 (file)
@@ -1,12 +1,14 @@
-#ifndef RUBBLE_H
-#define RUBBLE_H
+#pragma once
 
 #ifdef CSQC
 
 entityclass(Rubble);
-class(Rubble).float creationtime;
+classfield(Rubble).float creationtime;
 
-void RubbleLimit(string cname, float limit, void(entity) deleteproc)
+IntrusiveList g_rubble;
+STATIC_INIT(g_rubble) { g_rubble = IL_NEW(); }
+
+void RubbleLimit(string cname, int limit, void(entity) deleteproc)
 {
        // remove rubble of the same type if it's at the limit
        // remove multiple rubble if the limit has been decreased
@@ -18,7 +20,7 @@ void RubbleLimit(string cname, float limit, void(entity) deleteproc)
                entity oldest = NULL;
                float oldesttime = 0;
                // compare to all other matching entities
-               FOREACH_ENTITY_CLASS(cname, true,
+               IL_EACH(g_rubble, it.classname == cname,
                {
                        ++c;
                        if(!oldest || oldesttime > it.creationtime)
@@ -36,15 +38,11 @@ void RubbleLimit(string cname, float limit, void(entity) deleteproc)
        }
 }
 
-entity RubbleNew(string cname)
+entity RubbleNew(entity e)
 {
-       // spawn a new entity and return it
-       entity e = spawn();
-       e.classname = cname;
        e.creationtime = time;
+       IL_PUSH(g_rubble, e);
        return e;
 }
 
 #endif
-
-#endif