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;
15 sort = spawn();
16 sort.sort_cmp = cmp;
17 sort.sort_next = NULL;
18 sort.chain = sort;
19 return sort;
20}
21
22void Sort_Remove(entity sort)
23{
24 entity next;
25 while(sort.sort_next)
26 {
27 next = sort.sort_next;
28 remove(sort);
29 sort = next;
30 }
31 remove(sort);
32}
33
34void Sort_Add(entity sort, entity ent)
35{
36 entity next, parent;
37 parent = sort;
38 next = sort.sort_next;
39 while(next)
40 {
41 if(!sort.sort_cmp(next, ent))
42 break;
43 parent = next;
44 next = next.sort_next;
45 }
46 ent.sort_next = next;
47 ent.sort_prev = parent;
48 parent.sort_next = ent;
49 if(next)
50 next.sort_prev = ent;
51}
52
53void Sort_Reset(entity sort)
54{
55 sort.chain = sort;
56}
57
58float Sort_HasNext(entity sort)
59{
60 return (sort.chain.sort_next != NULL);
61}
62
63entity Sort_Next(entity sort)
64{
65 entity next;
66 next = sort.chain.sort_next;
67 if(!next) {
68 next = spawn();
69 sort.chain.sort_next = next;
70 next.sort_prev = sort.chain;
71 next.sort_next = NULL;
72 }
73 sort.chain = next;
74 return next;
75}
76
77void Sort_Finish(entity sort)
78{
79 entity next;
80 next = sort.chain;
81 if(!next)
82 return;
83
84 while(next.sort_next)
85 {
86 sort = next.sort_next;
87 next.sort_next = sort.sort_next;
88 remove(sort);
89 }
90}
91
92entity Sort_Get(entity sort, float i)
93{
94 for (; sort.sort_next && i > 0; --i)
95 sort = sort.sort_next;
96 return sort;
97}
98*/
99
100/*
101void Sort_Erase(entity ent)
102{
103 ent.sort_prev.sort_next = ent.sort_next;
104 if(ent.sort_next)
105 ent.sort_next.sort_prev = ent.sort_prev;
106 remove(ent);
107}
108
109void Sort_RemoveOld(entity sort)
110{
111 entity tmp;
112 for(tmp = sort.sort_next; tmp; tmp = tmp.sort_next)
113 {
114 if(tmp.frame < time)
115 {
116 tmp = tmp.sort_prev;
117 Sort_Erase(tmp.sort_next);
118 }
119 }
120}
121*/
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:67
#define NULL
Definition post.qh:14
ERASEABLE entity Sort_Spawn()
Definition sortlist.qc:4