Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
rubble.qc File Reference
#include "rubble.qh"
Include dependency graph for rubble.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void LimitedChildrenRubble (IntrusiveList list, string cname, int limit, void(entity) deleteproc, entity parent)
entity ListNewChildRubble (IntrusiveList list, entity child)
entity ReplaceOldListedChildRubble (IntrusiveList list, entity child, entity oldChild)

Function Documentation

◆ LimitedChildrenRubble()

void LimitedChildrenRubble ( IntrusiveList list,
string cname,
int limit,
void(entity) deleteproc,
entity parent )

Definition at line 5 of file rubble.qc.

5 {
6 // remove rubble of the same type if it's at the limit
7 // remove multiple rubble if the limit has been decreased
8 while (1)
9 {
10 // walk the list and count the entities, find the oldest
11 // initialize our search with the first entity
12 int c = 0;
13 entity oldest = NULL;
14 float oldesttime = 0;
15 // compare to all other matching entities
16 IL_EACH(list, it.classname == cname,
17 {
18 if(!parent || parent == it.owner){
19 ++c;
20 if(!oldest || oldesttime > it.creationtime)
21 {
22 oldest = it;
23 oldesttime = it.creationtime;
24 }
25 }
26 });
27
28 // stop if there are less than the limit already
29 if (c <= limit) break;
30
31 // delete this oldest one and search again
32 deleteproc(oldest);
33 }
34}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IL_EACH(this, cond, body)
#define NULL
Definition post.qh:14

References entity(), IL_EACH, NULL, and parent.

Referenced by NET_HANDLE(), TossGib(), and W_Electro_Attack_Orb().

◆ ListNewChildRubble()

entity ListNewChildRubble ( IntrusiveList list,
entity child )

Definition at line 46 of file rubble.qc.

46 {
47 child.creationtime = time;
48 IL_PUSH(list, child);
49 return child;
50}
float time
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.

References entity(), IL_PUSH(), and time.

Referenced by NET_HANDLE(), TossGib(), and W_Electro_Attack_Orb().

◆ ReplaceOldListedChildRubble()

entity ReplaceOldListedChildRubble ( IntrusiveList list,
entity child,
entity oldChild )

Definition at line 39 of file rubble.qc.

39 {
40 child.creationtime = oldChild.creationtime;
41 IL_REMOVE(list, oldChild);
42 IL_PUSH(list, child);
43 return child;
44}
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.

References entity(), IL_PUSH(), and IL_REMOVE().

Referenced by W_Electro_Orb_Stick().