Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / sortlist.qh
1 #ifndef SORTLIST_H
2 #define SORTLIST_H
3
4 entityclass(Sort);
5 //.float(entity,entity) sort_cmp;
6 class(Sort) .entity chain, sort_next, sort_prev;
7
8 entity Sort_Spawn();
9
10 /**
11  * Swap two neighbours in a sortlist.
12  * @param a FIRST entity
13  * @param b entity after a
14  */
15 #define SORT_SWAP(a,b)                                                                  \
16         b.sort_prev = a.sort_prev;                                                      \
17         a.sort_next = b.sort_next;                                                      \
18         if(b.sort_next) b.sort_next.sort_prev = a;                      \
19         if(a.sort_prev) a.sort_prev.sort_next = b;                      \
20         a.sort_prev = b;                                                                        \
21         b.sort_next = a
22
23 #endif