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) \
8 MACRO_BEGIN \
9 ArrayList _al = this = new_pure(ArrayList); \
10 _al.al_buf = buf_create(); \
11 for (int i = 0, _n = _al.al_len = n; i < _n; ++i) \
12 { \
13 const _AL_type__##T() it = default; \
14 AL_set##T(this, i, it); \
15 } \
16 MACRO_END
17
18#define AL_DELETE(this) \
19 MACRO_BEGIN \
20 buf_del(this.al_buf); \
21 delete(this); \
22 this = NULL; \
23 MACRO_END
24
25#define _AL_type__s() string
26#define AL_gets(this, idx) bufstr_get(this.al_buf, idx)
27#define AL_sets(this, idx, val) bufstr_set(this.al_buf, idx, val)
28
29#if defined(CSQC)
30string al_ftos(float f) = #26;
31float al_stof(string s) = #81;
32#elif defined(SVQC)
33string al_ftos(float f) = #26;
34float al_stof(string s) = #81;
35#elif defined(MENUQC)
36string al_ftos(float f) = #17;
37float al_stof(string s) = #21;
38#endif
39
40#define _AL_type__f() float
41#define AL_getf(this, idx) al_stof(AL_gets(this, idx))
42#define AL_setf(this, idx, val) AL_sets(this, idx, al_ftos(val))
43
44#if defined(CSQC)
45int al_etof(entity e) = #512;
46entity al_ftoe(int i) = #459;
47#elif defined(SVQC)
48int al_etof(entity e) = #512;
49entity al_ftoe(int i) = #459;
50#elif defined(MENUQC)
51int al_etof(entity e) = #79;
52entity al_ftoe(int i) = #80;
53#endif
54
55#define _AL_type__e() entity
56#define AL_gete(this, idx) al_ftoe(AL_getf(this, idx))
57#define AL_sete(this, idx, val) AL_setf(this, idx, al_etof(val))
58
59#define AL_EACH(this, T, cond, body) \
60 MACRO_BEGIN \
61 const noref ArrayList _al = this; \
62 for (int i = 0, n = _al.al_len; i < n; ++i) \
63 { \
64 const noref _AL_type__##T() it = AL_get##T(_al, i); \
65 if (cond) { body } \
66 } \
67 MACRO_END
string al_ftos(float f)
int al_etof(entity e)
int al_len
Definition arraylist.qh:5
entity ArrayList
Definition arraylist.qh:3
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