]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/iter.qh
Viewmodels: cl_bobmodel: check onground for other players too
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / iter.qh
1 #ifndef ITER_H
2 #define ITER_H
3
4 #define FOREACH_ARRAY(arr, start, end, cond, body) \
5         do \
6         { \
7                 for (int i = start; i < end; ++i) \
8                 {                 \
9                         const noref entity it = arr[i];                 \
10                         if (cond) { body }                              \
11                 }                                                   \
12         } \
13         while (0)
14
15 #define FOREACH_LIST(list, next, cond, body) \
16         do \
17         {               \
18                 noref int i = 0;                                            \
19                 for (entity it = list##_first; it; (it = it.next, ++i)) \
20                 {   \
21                         if (cond) { body }                                      \
22                 }                                                           \
23         } \
24         while (0)
25
26 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)
27
28 #endif