Xonotic
sortlist.qc
Go to the documentation of this file.
1
#include "
sortlist.qh
"
2
3
ERASEABLE
4
entity
Sort_Spawn
()
5
{
6
entity
sort =
new_pure
(sortlist);
7
sort.sort_next =
NULL
;
8
sort.chain = sort;
9
return
sort;
10
}
11
/*
12
entity 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
22
void 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
34
void 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
53
void Sort_Reset(entity sort)
54
{
55
sort.chain = sort;
56
}
57
58
float Sort_HasNext(entity sort)
59
{
60
return (sort.chain.sort_next != NULL);
61
}
62
63
entity 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
77
void 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
92
entity 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
/*
101
void 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
109
void 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
*/
Sort_Spawn
ERASEABLE entity Sort_Spawn()
Definition:
sortlist.qc:4
entity
entity() spawn
sortlist.qh
ERASEABLE
#define ERASEABLE
Definition:
_all.inc:35
NULL
#define NULL
Definition:
post.qh:17
new_pure
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition:
oo.qh:62
lib
sortlist.qc
Generated on Thu Mar 17 2022 17:26:29 for Xonotic by
1.8.13