X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Flib%2Farraylist.qh;h=a10dcaa7b919b0c60299393c715bdfb6d1130b5f;hb=991de5e6922cd3c283de56c3249624f0f1bfe767;hp=f9df9e6bfc5c60a97ff5a55d911f3f015914de8b;hpb=2487070c23bdcfc8ac60d414356ec43f52ec1a57;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/arraylist.qh b/qcsrc/lib/arraylist.qh index f9df9e6bf..a10dcaa7b 100644 --- a/qcsrc/lib/arraylist.qh +++ b/qcsrc/lib/arraylist.qh @@ -1,13 +1,11 @@ -#ifndef ARRAYLIST_H -#define ARRAYLIST_H +#pragma once -typedef entity ArrayList; +USING(ArrayList, entity); .int al_buf; .int al_len; #define AL_NEW(this, n, default, T) \ MACRO_BEGIN \ - { \ ArrayList _al = this = new_pure(ArrayList); \ _al.al_buf = buf_create(); \ for (int i = 0, _n = _al.al_len = n; i < _n; ++i) \ @@ -15,15 +13,14 @@ typedef entity ArrayList; const _AL_type__##T() it = default; \ AL_set##T(this, i, it); \ } \ - } MACRO_END + MACRO_END #define AL_DELETE(this) \ MACRO_BEGIN \ - { \ buf_del(this.al_buf); \ - remove(this); \ + delete(this); \ this = NULL; \ - } MACRO_END + MACRO_END #define _AL_type__s() string #define AL_gets(this, idx) bufstr_get(this.al_buf, idx) @@ -61,13 +58,10 @@ entity al_ftoe(int i) = #80; #define AL_EACH(this, T, cond, body) \ MACRO_BEGIN \ - { \ const noref ArrayList _al = this; \ for (int i = 0, n = _al.al_len; i < n; ++i) \ { \ const noref _AL_type__##T() it = AL_get##T(_al, i); \ if (cond) { body } \ } \ - } MACRO_END - -#endif + MACRO_END