6 class(Rubble).float creationtime;
8 IntrusiveList g_rubble;
9 STATIC_INIT(g_rubble) { g_rubble = IL_NEW(); }
11 void RubbleLimit(string cname, int limit, void(entity) deleteproc)
13 // remove rubble of the same type if it's at the limit
14 // remove multiple rubble if the limit has been decreased
17 // walk the list and count the entities, find the oldest
18 // initialize our search with the first entity
22 // compare to all other matching entities
23 IL_EACH(g_rubble, it.classname == cname,
26 if(!oldest || oldesttime > it.creationtime)
29 oldesttime = it.creationtime;
33 // stop if there are less than the limit already
34 if (c <= limit) break;
36 // delete this oldest one and search again
41 entity RubbleNew(string cname)
43 // spawn a new entity and return it
46 e.creationtime = time;