-#ifndef RUBBLE_H
-#define RUBBLE_H
-
-#ifdef CSQC
+#pragma once
+#ifdef GAMEQC
entityclass(Rubble);
-class(Rubble).float creationtime;
-
-void RubbleLimit(string cname, float limit, void(entity) deleteproc)
-{
- entity e;
- entity oldest;
- float c;
- float oldesttime;
-
- // remove rubble of the same type if it's at the limit
- // remove multiple rubble if the limit has been decreased
- while (1)
- {
- e = findchain(classname, cname);
- if (e == NULL) break;
- // walk the list and count the entities, find the oldest
- // initialize our search with the first entity
- c = 1;
- oldest = e;
- oldesttime = e.creationtime;
- e = e.chain;
- // compare to all other matching entities
- while (e)
- {
- c = c + 1;
- if (oldesttime > e.creationtime)
- {
- oldesttime = e.creationtime;
- oldest = e;
- }
- e = e.chain;
- }
+classfield(Rubble).float creationtime;
- // stop if there are less than the limit already
- if (c <= limit) break;
+#ifdef CSQC
+IntrusiveList CasingsNGibs;
+STATIC_INIT(CasingsNGibs) { CasingsNGibs = IL_NEW(); }
+#endif
- // delete this oldest one and search again
- deleteproc(oldest);
- }
-}
+void LimitedChildrenRubble(IntrusiveList list, string cname, int limit, void(entity) deleteproc, entity parent);
-entity RubbleNew(string cname)
-{
- // spawn a new entity and return it
- entity e = spawn();
- e.classname = cname;
- e.creationtime = time;
- return e;
-}
+entity ReplaceOldListedChildRubble(IntrusiveList list, entity child, entity oldChild);
-#endif
+entity ListNewChildRubble(IntrusiveList list, entity child);
#endif