Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
arraylist.qh
Go to the documentation of this file.
1#pragma once
2
4.int al_buf;
5.int al_len;
6
7#define AL_NEW(this, n, default, T) MACRO_BEGIN \
8 ArrayList _al = this = new_pure(ArrayList); \
9 _al.al_buf = buf_create(); \
10 for (int i = 0, _n = _al.al_len = n; i < _n; ++i) \
11 { \
12 const _AL_type__##T() it = default; \
13 AL_set##T(this, i, it); \
14 } \
15MACRO_END
16
17#define AL_DELETE(this) MACRO_BEGIN \
18 buf_del(this.al_buf); \
19 delete(this); \
20 this = NULL; \
21MACRO_END
22
23#define _AL_type__s() string
24#define AL_gets(this, idx) bufstr_get(this.al_buf, idx)
25#define AL_sets(this, idx, val) bufstr_set(this.al_buf, idx, val)
26
27#ifdef CSQC
28string al_ftos(float f) = #26;
29float al_stof(string s) = #81;
30#elifdef SVQC
31string al_ftos(float f) = #26;
32float al_stof(string s) = #81;
33#elifdef MENUQC
34string al_ftos(float f) = #17;
35float al_stof(string s) = #21;
36#endif
37
38#define _AL_type__f() float
39#define AL_getf(this, idx) al_stof(AL_gets(this, idx))
40#define AL_setf(this, idx, val) AL_sets(this, idx, al_ftos(val))
41
42#ifdef CSQC
43int al_etof(entity e) = #512;
44entity al_ftoe(int i) = #459;
45#elifdef SVQC
46int al_etof(entity e) = #512;
47entity al_ftoe(int i) = #459;
48#elifdef MENUQC
49int al_etof(entity e) = #79;
50entity al_ftoe(int i) = #80;
51#endif
52
53#define _AL_type__e() entity
54#define AL_gete(this, idx) al_ftoe(AL_getf(this, idx))
55#define AL_sete(this, idx, val) AL_setf(this, idx, al_etof(val))
56
57#define AL_EACH(this, T, cond, body) MACRO_BEGIN \
58 const noref ArrayList _al = this; \
59 for (int i = 0, n = _al.al_len; i < n; ++i) \
60 { \
61 const noref _AL_type__##T() it = AL_get##T(_al, i); \
62 if (cond) \
63 LAMBDA(body) \
64 } \
65MACRO_END
entity ArrayList
Definition arraylist.qh:3
string al_ftos(float f)
int al_etof(entity e)
int al_len
Definition arraylist.qh:5
int al_buf
Definition arraylist.qh:4
float al_stof(string s)
entity al_ftoe(int i)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define USING(name, T)
Definition _all.inc:72