3 // LordHavoc: rewrote this file, it was really bad code
\r
5 void RubbleLimit(string cname, float limit, void() deleteproc)
\r
15 // remove rubble of the same type if it's at the limit
\r
16 // remove multiple rubble if the limit has been decreased
\r
19 e = findchain(classname,cname);
\r
22 // walk the list and count the entities, find the oldest
\r
23 // initialize our search with the first entity
\r
26 oldesttime = e.creationtime;
\r
28 // compare to all other matching entities
\r
32 if (oldesttime > e.creationtime)
\r
34 oldesttime = e.creationtime;
\r
40 // stop if there are less than the limit already
\r
44 // delete this oldest one and search again
\r
51 entity RubbleNew(string cname)
\r
54 // spawn a new entity and return it
\r
56 e.classname = cname;
\r
57 e.creationtime = time;
\r