Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sortlist.qc
Go to the documentation of this file.
1#include "sortlist.qh"
2
5{
6 entity sort = new_pure(sortlist);
7 sort.sort_next = NULL;
8 sort.chain = sort;
9 return sort;
10}
11/*
12entity Sort_New(float(entity, entity) cmp)
13{
14 entity sort = spawn();
15 sort.sort_cmp = cmp;
16 sort.sort_next = NULL;
17 sort.chain = sort;
18 return sort;
19}
20
21void Sort_Remove(entity sort)
22{
23 entity next;
24 while (sort.sort_next)
25 {
26 next = sort.sort_next;
27 remove(sort);
28 sort = next;
29 }
30 remove(sort);
31}
32
33void Sort_Add(entity sort, entity ent)
34{
35 entity next, parent;
36 parent = sort;
37 next = sort.sort_next;
38 while (next)
39 {
40 if (!sort.sort_cmp(next, ent))
41 break;
42 parent = next;
43 next = next.sort_next;
44 }
45 ent.sort_next = next;
46 ent.sort_prev = parent;
47 parent.sort_next = ent;
48 if (next)
49 next.sort_prev = ent;
50}
51
52void Sort_Reset(entity sort)
53{
54 sort.chain = sort;
55}
56
57float Sort_HasNext(entity sort)
58{
59 return (sort.chain.sort_next != NULL);
60}
61
62entity Sort_Next(entity sort)
63{
64 entity next = sort.chain.sort_next;
65 if (!next)
66 {
67 next = spawn();
68 sort.chain.sort_next = next;
69 next.sort_prev = sort.chain;
70 next.sort_next = NULL;
71 }
72 sort.chain = next;
73 return next;
74}
75
76void Sort_Finish(entity sort)
77{
78 entity next = sort.chain;
79 if (!next)
80 return;
81
82 while (next.sort_next)
83 {
84 sort = next.sort_next;
85 next.sort_next = sort.sort_next;
86 remove(sort);
87 }
88}
89
90entity Sort_Get(entity sort, float i)
91{
92 for (; sort.sort_next && i > 0; --i)
93 sort = sort.sort_next;
94 return sort;
95}
96*/
97
98/*
99void Sort_Erase(entity ent)
100{
101 ent.sort_prev.sort_next = ent.sort_next;
102 if (ent.sort_next)
103 ent.sort_next.sort_prev = ent.sort_prev;
104 remove(ent);
105}
106
107void Sort_RemoveOld(entity sort)
108{
109 entity tmp;
110 for (tmp = sort.sort_next; tmp; tmp = tmp.sort_next)
111 if (tmp.frame < time)
112 {
113 tmp = tmp.sort_prev;
114 Sort_Erase(tmp.sort_next);
115 }
116}
117*/
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define ERASEABLE
Definition _all.inc:37
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:66
#define NULL
Definition post.qh:14
ERASEABLE entity Sort_Spawn()
Definition sortlist.qc:4