5 void LimitedChildrenRubble(IntrusiveList list, string cname, int limit, void(entity) deleteproc, entity parent){
6 // remove rubble of the same type if it's at the limit
7 // remove multiple rubble if the limit has been decreased
10 // walk the list and count the entities, find the oldest
11 // initialize our search with the first entity
15 // compare to all other matching entities
16 IL_EACH(list, it.classname == cname,
18 if(!parent ||parent == it.owner){
20 if(!oldest || oldesttime > it.creationtime)
23 oldesttime = it.creationtime;
28 // stop if there are less than the limit already
29 if (c <= limit) break;
31 // delete this oldest one and search again
37 // This function doesn't preserve linked list order but it is not needed as creationtime is used instead of list position for comparing ages.
38 // IL_Replace or similiar order preserving function did not exist at the time of creating this.
39 entity ReplaceOldListedChildRubble(IntrusiveList list, entity child, entity oldChild){
40 child.creationtime = oldChild.creationtime;
41 IL_REMOVE(list, oldChild);
46 entity ListNewChildRubble(IntrusiveList list, entity child){
47 child.creationtime = time;