float bgmscriptbufsize;
float bgmscriptbufloaded;
-class(BGMScript) .float bgmscriptline;
-class(BGMScript) .float bgmscriptline0;
-class(BGMScript) .float bgmscriptvolume;
-class(BGMScript) .float bgmscripttime;
-class(BGMScript) .float bgmscriptstate;
-class(BGMScript) .float bgmscriptstatetime;
+classfield(BGMScript) .float bgmscriptline;
+classfield(BGMScript) .float bgmscriptline0;
+classfield(BGMScript) .float bgmscriptvolume;
+classfield(BGMScript) .float bgmscripttime;
+classfield(BGMScript) .float bgmscriptstate;
+classfield(BGMScript) .float bgmscriptstatetime;
float GetAttackDecaySustainAmplitude(float a, float d, float s, float t)
{
#pragma once
entityclass(BGMScript);
-class(BGMScript) .string bgmscript;
-class(BGMScript) .float bgmscriptattack;
-class(BGMScript) .float bgmscriptdecay;
-class(BGMScript) .float bgmscriptsustain;
-class(BGMScript) .float bgmscriptrelease;
+classfield(BGMScript) .string bgmscript;
+classfield(BGMScript) .float bgmscriptattack;
+classfield(BGMScript) .float bgmscriptdecay;
+classfield(BGMScript) .float bgmscriptsustain;
+classfield(BGMScript) .float bgmscriptrelease;
-class(BGMScript) .float just_toggled;
+classfield(BGMScript) .float just_toggled;
#ifdef CSQC
void BGMScript_InitEntity(entity e);
entity panel;
entityclass(HUDPanel);
-class(HUDPanel) .string panel_name;
-class(HUDPanel) .int panel_id;
-class(HUDPanel) .vector current_panel_pos;
-class(HUDPanel) .vector current_panel_size;
-class(HUDPanel) .string current_panel_bg;
-class(HUDPanel) .float current_panel_bg_alpha;
-class(HUDPanel) .float current_panel_bg_border;
-class(HUDPanel) .vector current_panel_bg_color;
-class(HUDPanel) .float current_panel_bg_color_team;
-class(HUDPanel) .float current_panel_bg_padding;
-class(HUDPanel) .float current_panel_fg_alpha;
-class(HUDPanel) .float update_time;
+classfield(HUDPanel) .string panel_name;
+classfield(HUDPanel) .int panel_id;
+classfield(HUDPanel) .vector current_panel_pos;
+classfield(HUDPanel) .vector current_panel_size;
+classfield(HUDPanel) .string current_panel_bg;
+classfield(HUDPanel) .float current_panel_bg_alpha;
+classfield(HUDPanel) .float current_panel_bg_border;
+classfield(HUDPanel) .vector current_panel_bg_color;
+classfield(HUDPanel) .float current_panel_bg_color_team;
+classfield(HUDPanel) .float current_panel_bg_padding;
+classfield(HUDPanel) .float current_panel_fg_alpha;
+classfield(HUDPanel) .float update_time;
float panel_enabled;
vector panel_pos;
vector panel_size;
float panel_bg_padding;
string panel_bg_padding_str;
-class(HUDPanel) .void() panel_draw;
+classfield(HUDPanel) .void() panel_draw;
// chat panel can be reduced / moved while the mapvote is active
// let know the mapvote panel about chat pos and size
.float v_angle_save_x;
-class(Skeleton) .float skeleton_info_modelindex;
-class(Skeleton) .float skeleton_info_skin;
+classfield(Skeleton) .float skeleton_info_modelindex;
+classfield(Skeleton) .float skeleton_info_skin;
const int BONETYPE_LOWER = 0;
const int BONETYPE_UPPER = 1;
const int MAX_BONES = 128;
-class(Skeleton) .float skeleton_bonetype[MAX_BONES];
-class(Skeleton) .float skeleton_numbones;
+classfield(Skeleton) .float skeleton_bonetype[MAX_BONES];
+classfield(Skeleton) .float skeleton_numbones;
void skeleton_loadinfo(entity e)
{
void skeleton_loadinfo(entity e);
entityclass(Skeleton);
-class(Skeleton) .float bone_upperbody;
-class(Skeleton) .int bone_weapon;
-class(Skeleton) .float bone_aim[MAX_AIM_BONES];
-class(Skeleton) .float bone_aimweight[MAX_AIM_BONES];
-class(Skeleton) .float fixbone;
+classfield(Skeleton) .float bone_upperbody;
+classfield(Skeleton) .int bone_weapon;
+classfield(Skeleton) .float bone_aim[MAX_AIM_BONES];
+classfield(Skeleton) .float bone_aimweight[MAX_AIM_BONES];
+classfield(Skeleton) .float fixbone;
#pragma once
entityclass(ShowNames);
-class(ShowNames) .float healthvalue;
-class(ShowNames) .float armorvalue;
-class(ShowNames) .float sameteam;
-class(ShowNames) .float fadedelay;
-class(ShowNames) .float pointtime;
+classfield(ShowNames) .float healthvalue;
+classfield(ShowNames) .float armorvalue;
+classfield(ShowNames) .float sameteam;
+classfield(ShowNames) .float fadedelay;
+classfield(ShowNames) .float pointtime;
void Draw_ShowNames_All();
entityclass(TeamRadar);
// to make entities have dots on the team radar
-class(TeamRadar) .float teamradar_icon;
-class(TeamRadar) .float teamradar_times[MAX_TEAMRADAR_TIMES];
-class(TeamRadar) .int teamradar_time_index;
-class(TeamRadar) .vector teamradar_color;
+classfield(TeamRadar) .float teamradar_icon;
+classfield(TeamRadar) .float teamradar_times[MAX_TEAMRADAR_TIMES];
+classfield(TeamRadar) .int teamradar_time_index;
+classfield(TeamRadar) .vector teamradar_color;
float teamradar_angle; // player yaw angle
vector teamradar_origin3d_in_texcoord; // player origin
#pragma once
entityclass(Wall);
-class(Wall) .float lip;
-class(Wall) .float bgmscriptangular;
-class(Wall) .int lodmodelindex0, lodmodelindex1, lodmodelindex2;
-class(Wall) .float loddistance1, loddistance2;
-class(Wall) .vector saved;
+classfield(Wall) .float lip;
+classfield(Wall) .float bgmscriptangular;
+classfield(Wall) .int lodmodelindex0, lodmodelindex1, lodmodelindex2;
+classfield(Wall) .float loddistance1, loddistance2;
+classfield(Wall) .vector saved;
// Needed for interactive clientwalls
.float inactive; // Clientwall disappears when inactive
#include <common/sounds/sound.qh>
entityclass(Projectile);
-class(Projectile).int traileffect;
-
-class(Projectile).vector iorigin1, iorigin2;
-class(Projectile).float spawntime;
-class(Projectile).vector trail_oldorigin;
-class(Projectile).float trail_oldtime;
-class(Projectile).float fade_time, fade_rate;
-
-class(Projectile).float alphamod;
-class(Projectile).int count; // set if clientside projectile
-class(Projectile).int cnt; // sound index
-class(Projectile).float gravity;
-class(Projectile).int snd_looping;
-class(Projectile).bool silent;
+classfield(Projectile).int traileffect;
+
+classfield(Projectile).vector iorigin1, iorigin2;
+classfield(Projectile).float spawntime;
+classfield(Projectile).vector trail_oldorigin;
+classfield(Projectile).float trail_oldtime;
+classfield(Projectile).float fade_time, fade_rate;
+
+classfield(Projectile).float alphamod;
+classfield(Projectile).int count; // set if clientside projectile
+classfield(Projectile).int cnt; // sound index
+classfield(Projectile).float gravity;
+classfield(Projectile).int snd_looping;
+classfield(Projectile).bool silent;
void SUB_Stop(entity this, entity toucher);
#define EffectInfos_from(i) _EffectInfos_from(i, NULL)
REGISTER_REGISTRY(EffectInfos)
#define EFFECTINFO(name) \
- [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
+ ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
REGISTER(EffectInfos, EFFECTINFO, name, m_id, NEW(EffectInfoGroup)) { \
effectinfo_##name(this, NULL); \
}
#define MY(f) this.effectinfo_##f
#define DEF(name) EFFECTINFO(name)
#define SUB(name) \
- [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { parent = EFFECTINFO_##name; parent.children[parent.children_count++] = this = NEW(EffectInfo, #name); } \
- [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this)
+ ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { parent = EFFECTINFO_##name; parent.children[parent.children_count++] = this = NEW(EffectInfo, #name); } \
+ ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this)
#include "effectinfo.inc"
#undef MY
#undef DEF
#ifdef CSQC
entityclass(Casing);
-class(Casing) .float alpha;
-class(Casing) .bool silent;
-class(Casing) .int state;
-class(Casing) .float cnt;
+classfield(Casing) .float alpha;
+classfield(Casing) .bool silent;
+classfield(Casing) .int state;
+classfield(Casing) .float cnt;
void Casing_Delete(entity this)
{
#ifdef CSQC
entityclass(ModelEffect);
-class(ModelEffect) .float frame1time;
-class(ModelEffect) .float lifetime, fadetime;
-class(ModelEffect) .float teleport_time;
-class(ModelEffect) .float scale1, scale2;
+classfield(ModelEffect) .float frame1time;
+classfield(ModelEffect) .float lifetime, fadetime;
+classfield(ModelEffect) .float teleport_time;
+classfield(ModelEffect) .float scale1, scale2;
.float cnt;
.float scale;
#ifdef CSQC
entityclass(Rubble);
-class(Rubble).float creationtime;
+classfield(Rubble).float creationtime;
IntrusiveList g_rubble;
STATIC_INIT(g_rubble) { g_rubble = IL_NEW(); }
params(_MUTATOR_HANDLE_NOP, _MUTATOR_HANDLE_POPOUT) \
return ret; \
} \
- [[accumulate]] void RegisterHooks() { HOOK_##id = NEW(CallbackChain, #id); }
+ ACCUMULATE void RegisterHooks() { HOOK_##id = NEW(CallbackChain, #id); }
#define MUTATOR_CALLHOOK(id, ...) _MUTATOR_CALLHOOK(id, __VA_ARGS__)
#ifdef __STDC__
bool MUTATOR_##id##_check() { return dependence; } \
REGISTER(Mutators, MUTATOR, id, m_id, NEW(Mutator, #id, MUTATORFUNCTION_##id)) \
{ this.mutatorcheck = MUTATOR_##id##_check; } \
- [[accumulate]] bool MUTATORFUNCTION_##id(int mode)
+ ACCUMULATE bool MUTATORFUNCTION_##id(int mode)
STATIC_INIT(Mutators) {
RegisterHooks();
#define _MUTATOR_CALLBACK(name, func) \
Callback CALLBACK_##name; \
bool func(); \
- [[accumulate]] void RegisterCallbacks() { CALLBACK_##name = NEW(Callback, func); }
+ ACCUMULATE void RegisterCallbacks() { CALLBACK_##name = NEW(Callback, func); }
#define MUTATOR_HOOKFUNCTION(...) \
EVAL_MUTATOR_HOOKFUNCTION(OVERLOAD(MUTATOR_HOOKFUNCTION, __VA_ARGS__))
#define MUTATOR_HOOKFUNCTION_3(mut, cb, order) \
_MUTATOR_CALLBACK(mut##_##cb, mut##_##cb) \
- [[accumulate]] bool MUTATORFUNCTION_##mut##_hooks(int mode) { MUTATOR_HOOK(cb, mut##_##cb, order); } \
+ ACCUMULATE bool MUTATORFUNCTION_##mut##_hooks(int mode) { MUTATOR_HOOK(cb, mut##_##cb, order); } \
bool mut##_##cb() { return = false; } \
- [[accumulate]] bool mut##_##cb()
+ ACCUMULATE bool mut##_##cb()
#define MUTATOR_HOOK(cb, func, order) MACRO_BEGIN { \
MUTATOR_ONADD { \
#ifdef CSQC
entityclass(WaypointSprite);
-class(WaypointSprite) .float helpme;
-class(WaypointSprite) .float rule;
-class(WaypointSprite) .string netname; // primary picture
-class(WaypointSprite) .string netname2; // secondary picture
-class(WaypointSprite) .string netname3; // tertiary picture
-class(WaypointSprite) .int team; // team that gets netname2
-class(WaypointSprite) .float lifetime;
-class(WaypointSprite) .float fadetime;
-class(WaypointSprite) .float maxdistance;
-class(WaypointSprite) .int hideflags;
-class(WaypointSprite) .float spawntime;
-class(WaypointSprite) .float health;
-class(WaypointSprite) .float build_started;
-class(WaypointSprite) .float build_starthealth;
-class(WaypointSprite) .float build_finished;
+classfield(WaypointSprite) .float helpme;
+classfield(WaypointSprite) .float rule;
+classfield(WaypointSprite) .string netname; // primary picture
+classfield(WaypointSprite) .string netname2; // secondary picture
+classfield(WaypointSprite) .string netname3; // tertiary picture
+classfield(WaypointSprite) .int team; // team that gets netname2
+classfield(WaypointSprite) .float lifetime;
+classfield(WaypointSprite) .float fadetime;
+classfield(WaypointSprite) .float maxdistance;
+classfield(WaypointSprite) .int hideflags;
+classfield(WaypointSprite) .float spawntime;
+classfield(WaypointSprite) .float health;
+classfield(WaypointSprite) .float build_started;
+classfield(WaypointSprite) .float build_starthealth;
+classfield(WaypointSprite) .float build_finished;
float autocvar_g_waypointsprite_alpha;
float autocvar_g_waypointsprite_crosshairfadealpha;
.int dphitcontentsmask;
entityclass(PointParticles);
-class(PointParticles) .int cnt; // effect number
-class(PointParticles) .vector velocity; // particle velocity
-class(PointParticles) .float waterlevel; // direction jitter
-class(PointParticles) .int count; // count multiplier
-class(PointParticles) .int impulse; // density
-class(PointParticles) .string noise; // sound
-class(PointParticles) .float atten;
-class(PointParticles) .float volume;
-class(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
-class(PointParticles) .vector movedir; // trace direction
-class(PointParticles) .float glow_color; // palette index
+classfield(PointParticles) .int cnt; // effect number
+classfield(PointParticles) .vector velocity; // particle velocity
+classfield(PointParticles) .float waterlevel; // direction jitter
+classfield(PointParticles) .int count; // count multiplier
+classfield(PointParticles) .int impulse; // density
+classfield(PointParticles) .string noise; // sound
+classfield(PointParticles) .float atten;
+classfield(PointParticles) .float volume;
+classfield(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
+classfield(PointParticles) .vector movedir; // trace direction
+classfield(PointParticles) .float glow_color; // palette index
void Draw_PointParticles(entity this)
{
// it has color 'colormod'
// and stops when something is in the way
entityclass(Laser);
-class(Laser) .int cnt; // end effect
-class(Laser) .vector colormod;
-class(Laser) .int state; // on-off
-class(Laser) .int count; // flags for the laser
-class(Laser) .vector velocity;
-class(Laser) .float alpha;
-class(Laser) .float scale; // scaling factor of the thickness
-class(Laser) .float modelscale; // scaling factor of the dlight
+classfield(Laser) .int cnt; // end effect
+classfield(Laser) .vector colormod;
+classfield(Laser) .int state; // on-off
+classfield(Laser) .int count; // flags for the laser
+classfield(Laser) .vector velocity;
+classfield(Laser) .float alpha;
+classfield(Laser) .float scale; // scaling factor of the thickness
+classfield(Laser) .float modelscale; // scaling factor of the dlight
void Draw_Laser(entity this)
{
// FIXME also control bgmvolume here, to not require a target_music for the default track.
entityclass(TargetMusic);
-class(TargetMusic) .int state;
-class(TargetMusic) .float lastvol;
+classfield(TargetMusic) .int state;
+classfield(TargetMusic) .float lastvol;
void TargetMusic_Advance();
void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg);
entityclass(Hook);
-class(Hook) .entity HookType; // ENT_CLIENT_*
-class(Hook) .vector origin;
-class(Hook) .vector velocity;
-class(Hook) .float HookSilent;
-class(Hook) .float HookRange;
+classfield(Hook) .entity HookType; // ENT_CLIENT_*
+classfield(Hook) .vector origin;
+classfield(Hook) .vector velocity;
+classfield(Hook) .float HookSilent;
+classfield(Hook) .float HookRange;
string Draw_GrapplingHook_trace_callback_tex;
float Draw_GrapplingHook_trace_callback_rnd;
Draw_GrapplingHook_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
}
-class(Hook) .float teleport_time;
+classfield(Hook) .float teleport_time;
void Draw_GrapplingHook(entity this)
{
vector a, b, atrans;
#ifdef CSQC
entityclass(Tuba);
-class(Tuba) .int note;
-class(Tuba) .bool tuba_attenuate;
-class(Tuba) .float tuba_volume;
-class(Tuba) .float tuba_volume_initial;
-class(Tuba) .int tuba_instrument;
+classfield(Tuba) .int note;
+classfield(Tuba) .bool tuba_attenuate;
+classfield(Tuba) .float tuba_volume;
+classfield(Tuba) .float tuba_volume_initial;
+classfield(Tuba) .int tuba_instrument;
#endif
#define bool float
#endif
+#ifndef QCC_SUPPORT_ACCUMULATE
+ #warning "QCC does not support accumulate, may not compile correctly"
+ #define ACCUMULATE
+#else
+ #define ACCUMULATE [[accumulate]]
+#endif
+
#ifndef QCC_SUPPORT_ERASEABLE
#define ERASEABLE
#else
#define ERASEABLE [[eraseable]]
#endif
+#ifndef QCC_SUPPORT_ALIAS
+ #warning "QCC does not support alias, may not compile correctly"
+ #define ALIAS(var)
+#else
+ #define ALIAS(var) [[alias(var)]]
+#endif
+
#include <dpdefs/pre.qh>
#if defined(CSQC)
#include <dpdefs/post.qh>
+#ifndef QCC_SUPPORT_POW
+ #define pow(a, b) pow(a, b)
+#else
+ #define pow(a, b) (a ** b)
+#endif
+
#include "self.qh"
#define USING(name, T) typedef T name
#ifdef QCC_SUPPORT_ACCUMULATE
#define ACCUMULATE_FUNCTION(func, otherfunc) \
- [[accumulate]] void func() \
+ ACCUMULATE void func() \
{ \
otherfunc(); \
}
#endif
#endif
+#ifndef QCC_SUPPORT_ALIAS
+ #ifdef GMQCC
+ #define QCC_SUPPORT_ALIAS
+ #endif
+#endif
+
+#ifndef QCC_SUPPORT_POW
+ #ifdef GMQCC
+ #define QCC_SUPPORT_POW
+ #endif
+#endif
+
#ifdef GMQCC
#define LABEL(id) :id
#else
// e.g.: AUTOCVAR(mycvar, float, 2.5, "cvar description")
#define __AUTOCVAR(file, archive, var, type, desc, default) \
- [[accumulate]] void RegisterCvars(void(string, string, string, bool, string) f) \
+ ACCUMULATE void RegisterCvars(void(string, string, string, bool, string) f) \
{ \
f( #var, repr_cvar_##type(default), desc, archive, file); \
} \
#include "self.qh"
entityclass(Defer);
- class(Defer).entity owner;
- class(Defer).void(entity) defer_func;
+ classfield(Defer).entity owner;
+ classfield(Defer).void(entity) defer_func;
/** Remove entity */
void SUB_Remove(entity this)
#include "p99.qh"
#define OVERLOAD(F, ...) P99_IF_EMPTY(__VA_ARGS__)(P99_PASTE2(F, _00)())(P99_PASTE3(F, _, P00_NARG(__VA_ARGS__))(__VA_ARGS__))
- /** for use within a macro */
+ /** for use within macros */
#define OVERLOAD_(F, ...) P99_IF_EMPTY(__VA_ARGS__)(P99_PASTE2(F, _00)())(P99_PASTE3(F, _, P00_NARG(__VA_ARGS__))(__VA_ARGS__))
+ #define OVERLOAD__(F, ...) P99_IF_EMPTY(__VA_ARGS__)(P99_PASTE2(F, _00)())(P99_PASTE3(F, _, P00_NARG(__VA_ARGS__))(__VA_ARGS__))
#else
#define EVAL(...) __VA_ARGS__
- #define OVERLOAD_(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
#define OVERLOAD(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
+ #define OVERLOAD_(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
+ #define OVERLOAD__(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
#endif
#if defined(CSQC)
#ifdef CSQC
#define REGISTER_NET_LINKED(id) \
- [[accumulate]] NET_HANDLE(id, bool isnew) \
+ ACCUMULATE NET_HANDLE(id, bool isnew) \
{ \
this = __self; \
this.sourceLoc = __FILE__ ":" STR(__LINE__); \
// noises "usually" start in the range -1..1
entityclass(Noise);
-class(Noise).float noise_baccum;
-class(Noise).float noise_paccum;
-class(Noise).float noise_paccum2;
-class(Noise).float noise_paccum3;
-class(Noise).float noise_bstate;
+classfield(Noise).float noise_baccum;
+classfield(Noise).float noise_paccum;
+classfield(Noise).float noise_paccum2;
+classfield(Noise).float noise_paccum3;
+classfield(Noise).float noise_bstate;
ERASEABLE
float Noise_Brown(entity e, float dt)
#include "static.qh"
.vector origin;
+
.bool pure_data;
-/** @deprecated use new_pure or NEW(class) */
-#define make_pure(e) \
- MACRO_BEGIN \
- { \
- (e).pure_data = true; \
- } MACRO_END
-#define make_impure(e) \
- MACRO_BEGIN \
- { \
- (e).pure_data = false; \
- } MACRO_END
#define is_pure(e) ((e).pure_data)
+/** @deprecated use new_pure or NEW(class) */
+#define make_pure(e) MACRO_BEGIN \
+ (e).pure_data = true; \
+MACRO_END
+#define make_impure(e) MACRO_BEGIN \
+ (e).pure_data = false; \
+MACRO_END
.string classname;
/** Location entity was spawned from in source */
#define entityclass_1(name) entityclass_2(name, Object)
#ifndef QCC_SUPPORT_ENTITYCLASS
#define entityclass_2(name, base) USING(name, entity)
- #define class(name)
+ #define classfield(name)
#define _new(class, pure) __spawn( #class, __FILE__ ":" STR(__LINE__), pure)
#else
#define entityclass_2(name, base) entityclass name : base {}
- #define class(name) [[class(name)]]
+ #define classfield(name) [[class(name)]]
#define _new(class, pure) ((class) __spawn( #class, __FILE__ ":" STR(__LINE__), pure))
#endif
/** entities you care about seeing (.origin works) */
#define new_pure(class) _new(class, true)
#define spawn() __spawn("entity", __FILE__ ":" STR(__LINE__), false)
-[[accumulate]] void ONREMOVE(entity this) {}
+ACCUMULATE void ONREMOVE(entity this) {}
#ifndef SVQC
#define delete_fn builtin_remove
#endif
+.void(entity this) dtor;
#define delete(this) MACRO_BEGIN { \
entity _this = (this); \
void(entity) _dtor = _this.dtor; \
}
// Classes have a `spawn##cname(entity)` constructor
-// The parameter is used across [[accumulate]] functions
+// The parameter is used across ACCUMULATE functions
.bool transmute;
} \
MACRO_END
-#define CONSTRUCTOR(cname, ...) \
- cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) \
- { \
- return = this; \
- } \
- [[accumulate]] cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__)
+#define CLASS(...) EVAL_CLASS(OVERLOAD__(CLASS, __VA_ARGS__))
+#define EVAL_CLASS(...) __VA_ARGS__
+
+#define ATTRIB(...) EVAL_ATTRIB(OVERLOAD_(ATTRIB, __VA_ARGS__))
+#define EVAL_ATTRIB(...) __VA_ARGS__
+
+#ifdef QCC_SUPPORT_CLASS
+
+#warning "QCC_SUPPORT_CLASS not implemented"
+
+#define CLASS_1(name) CLASS_2(name, entity)
+#define CLASS_2(name, base) class name : base {
+
+#define INIT(class) void class::class()
+#define CONSTRUCTOR(class, ...) void class::class(__VA_ARGS__)
+#define DESTRUCTOR(class) class::~class()
+
+#define SUPER(class) super
+
+#define ATTRIB_3(class, name, T) T name
+#define ATTRIB_4(class, name, T, val) ATTRIB_3(class, name, T) = val
+#define STATIC_ATTRIB(class, name, T, val) static T name = val
+
+#define ATTRIB_STRZONE(class, name, T, val) T name = val
+#define STATIC_ATTRIB_STRZONE(class, name, T, val) static T name = val
+
+#define ATTRIBARRAY(class, name, T, val) T name[val]
+
+#define METHOD(class, name, prototype) virtual void class::name()
+#define STATIC_METHOD(class, name, prototype) static void class::name()
+
+#define ENDCLASS(class) };
+
+#else
+
+#define CLASS_1(cname) CLASS_2(cname, )
+#define CLASS_2(cname, base) \
+ entityclass(cname, base); \
+ classfield(cname).bool instanceOf##cname; \
+ DEBUG_STUFF(cname) \
+ VTBL(cname, base) \
+ _INIT_STATIC(cname) \
+ { \
+ if (cname##_vtbl && !this.transmute) \
+ { \
+ copyentity(cname##_vtbl, this); \
+ return; \
+ } \
+ spawn##base##_static(this); \
+ this.instanceOf##cname = true; \
+ } \
+ INIT(cname) \
+ { \
+ /* Only statically initialize the current class, it contains everything it inherits */ \
+ if (cname##_vtbl.vtblname == this.classname) \
+ { \
+ spawn##cname##_static(this); \
+ this.transmute = false; \
+ this.classname = #cname; \
+ this.vtblname = string_null; \
+ this.vtblbase = cname##_vtbl; \
+ } \
+ spawn##base##_1(this); \
+ }
+
+#define INIT(cname) \
+ ACCUMULATE cname spawn##cname##_1(cname this)
+
+#define CONSTRUCTOR(cname, ...) \
+ cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) \
+ { \
+ return = this; \
+ } \
+ ACCUMULATE cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__)
+
+#define DESTRUCTOR(cname) \
+ STATIC_METHOD(cname, dtorimpl, void(cname this)); \
+ METHOD(cname, dtor, void(cname this)) \
+ { \
+ METHOD_REFERENCE(cname, dtorimpl)(this); \
+ this.instanceOf##cname = false; \
+ entity super = SUPER(cname); \
+ if (super != cname##_vtbl) super.dtor(this); \
+ } \
+ STATIC_METHOD(cname, dtorimpl, void(cname this))
+
+#define SUPER(cname) (cname##_vtbl.vtblbase)
+
+#define ATTRIB_3(cname, name, type) classfield(cname) .type name
+#define ATTRIB_4(cname, name, type, val) \
+ ATTRIB_3(cname, name, type); \
+ INIT(cname) \
+ { \
+ noref bool strzone; /* Error on strzone() calls. */ \
+ this.name = val; \
+ } \
+ ATTRIB_3(cname, name, type)
+
+#define STATIC_ATTRIB(cname, name, type, val) \
+ type cname##_##name; \
+ _INIT_STATIC(cname) \
+ { \
+ noref bool strzone; /* Error on strzone() calls. */ \
+ cname##_##name = val; \
+ }
+
+// cleanup potentially zoned strings from base classes
+#define ATTRIB_STRZONE(cname, name, type, val) \
+ classfield(cname).type name; \
+ INIT(cname) \
+ { \
+ strcpy(this.name, val); \
+ }
+
+#define STATIC_ATTRIB_STRZONE(cname, name, type, val) \
+ type cname##_##name; \
+ _INIT_STATIC(cname) \
+ { \
+ strcpy(cname##_##name, val); \
+ }
+
+#define ATTRIBARRAY(cname, name, type, cnt) \
+ classfield(cname) .type name[cnt]
+
+#define METHOD(cname, name, prototype) \
+ STATIC_METHOD(cname, name, prototype); \
+ classfield(cname) .prototype name; \
+ _INIT_STATIC(cname) \
+ { \
+ this.name = METHOD_REFERENCE(cname, name); \
+ } \
+ STATIC_METHOD(cname, name, prototype)
+
+#define STATIC_METHOD(cname, name, prototype) \
+ prototype METHOD_REFERENCE(cname, name)
+
+#define ENDCLASS(cname) \
+ INIT(cname) \
+ { \
+ return this; \
+ }
+
+// impl
.string vtblname;
.entity vtblbase;
} \
ACCUMULATE_FUNCTION(RegisterClasses, cname##_vtbl_init)
-#define _INIT_STATIC(cname) [[accumulate]] void spawn##cname##_static(cname this)
-#define INIT(cname) [[accumulate]] cname spawn##cname##_1(cname this)
+#define _INIT_STATIC(cname) ACCUMULATE void spawn##cname##_static(cname this)
#if NDEBUG
#define DEBUG_STUFF(cname)
#else
#define DEBUG_STUFF(cname) \
- bool is_##cname(entity e) { return e.instanceOf##cname; } \
- void isnt_##cname(entity e) { eprint(e); }
+ ERASEABLE bool is_##cname(entity e) { return e.instanceOf##cname; } \
+ ERASEABLE void isnt_##cname(entity e) { eprint(e); }
#endif
-
-#define CLASS(cname, base) \
- entityclass(cname, base); \
- class(cname).bool instanceOf##cname; \
- DEBUG_STUFF(cname) \
- VTBL(cname, base) \
- _INIT_STATIC(cname) \
- { \
- if (cname##_vtbl && !this.transmute)\
- { \
- copyentity(cname##_vtbl, this); \
- return; \
- } \
- spawn##base##_static(this); \
- this.instanceOf##cname = true; \
- } \
- INIT(cname) \
- { \
- /* Only statically initialize the current class, it contains everything it inherits */ \
- if (cname##_vtbl.vtblname == this.classname) \
- { \
- spawn##cname##_static(this); \
- this.transmute = false; \
- this.classname = #cname; \
- this.vtblname = string_null; \
- this.vtblbase = cname##_vtbl; \
- } \
- spawn##base##_1(this); \
- }
-
#define METHOD_REFERENCE(cname, name) \
cname##_##name
-#define STATIC_METHOD(cname, name, prototype) \
- prototype METHOD_REFERENCE(cname, name)
-
-#define METHOD(cname, name, prototype) \
- STATIC_METHOD(cname, name, prototype); \
- class(cname) .prototype name; \
- _INIT_STATIC(cname) \
- { \
- this.name = METHOD_REFERENCE(cname, name); \
- } \
- STATIC_METHOD(cname, name, prototype)
-
-#define DESTRUCTOR(cname) \
- STATIC_METHOD(cname, dtorimpl, void(cname this)); \
- METHOD(cname, dtor, void(cname this)) \
- { \
- METHOD_REFERENCE(cname, dtorimpl)(this); \
- this.instanceOf##cname = false; \
- entity super = SUPER(cname); \
- if (super != cname##_vtbl) super.dtor(this); \
- } \
- STATIC_METHOD(cname, dtorimpl, void(cname this))
-
-#define ATTRIB(...) EVAL_ATTRIB(OVERLOAD_(ATTRIB, __VA_ARGS__))
-#define EVAL_ATTRIB(...) __VA_ARGS__
-#define ATTRIB_3(cname, name, type) class(cname) .type name
-#define ATTRIB_4(cname, name, type, val) \
- ATTRIB_3(cname, name, type); \
- INIT(cname) \
- { \
- noref bool strzone; /* Error on strzone() calls. */ \
- this.name = val; \
- } \
- ATTRIB_3(cname, name, type)
-
-#define STATIC_ATTRIB(cname, name, type, val) \
- type cname##_##name; \
- _INIT_STATIC(cname) \
- { \
- noref bool strzone; /* Error on strzone() calls. */ \
- cname##_##name = val; \
- }
-
-// cleanup potentially zoned strings from base classes
-
-#define ATTRIB_STRZONE(cname, name, type, val) \
- class(cname).type name; \
- INIT(cname) \
- { \
- strcpy(this.name, val); \
- }
-
-#define STATIC_ATTRIB_STRZONE(cname, name, type, val) \
- type cname##_##name; \
- _INIT_STATIC(cname) \
- { \
- strcpy(cname##_##name, val); \
- }
-
-#define ATTRIBARRAY(cname, name, type, cnt) \
- class(cname) .type name[cnt]
-
-#define ENDCLASS(cname) \
- INIT(cname) \
- { \
- return this; \
- }
-
-#define SUPER(cname) (cname##_vtbl.vtblbase)
+#endif
#define spawn_static(this)
#define spawn_1(this)
#define _vtbl NULL
-CLASS(Object, );
+CLASS(Object)
DESTRUCTOR(Object) { builtin_remove(this); }
#define remove(this) delete(this)
METHOD(Object, describe, string(Object this))
*/
#define REGISTRY(id, max) \
void Register##id(); \
- [[accumulate]] void REGISTRY_DEPENDS_(id) {} \
+ ACCUMULATE void REGISTRY_DEPENDS_(id) {} \
REGISTRY_BEGIN(id) {} \
REGISTRY_END(id) {} \
void _Register##id() {} \
#define REGISTRY_DEPENDS_(id) Register##id##_Depends()
/** Called before initializing a registry. */
-#define REGISTRY_BEGIN(id) [[accumulate]] void REGISTRY_BEGIN_(id) { noref void() f = Register##id; } void REGISTRY_BEGIN_(id)
+#define REGISTRY_BEGIN(id) ACCUMULATE void REGISTRY_BEGIN_(id) { noref void() f = Register##id; } void REGISTRY_BEGIN_(id)
#define REGISTRY_BEGIN_(id) Register##id##_First()
/** Called after initializing a registry. */
-#define REGISTRY_END(id) [[accumulate]] void REGISTRY_END_(id) { noref void() f = Register##id; } void REGISTRY_END_(id)
+#define REGISTRY_END(id) ACCUMULATE void REGISTRY_END_(id) { noref void() f = Register##id; } void REGISTRY_END_(id)
#define REGISTRY_END_(id) Register##id##_Done()
REGISTRY(Registries, BITS(8))
REGISTRY_PUSH(registry, fld, e); \
} MACRO_END
-#define REGISTER_INIT(id) [[accumulate]] void Register_##id##_init(entity this)
+#define REGISTER_INIT(id) ACCUMULATE void Register_##id##_init(entity this)
/** internal next pointer */
#define REGISTRY_NEXT enemy
#define REGISTRY_HASH(id) Registry_hash_##id
ERASEABLE
-[[accumulate]] void Registry_check(string r, string server) { }
+ACCUMULATE void Registry_check(string r, string server) { }
ERASEABLE
-[[accumulate]] void Registry_send_all() { }
+ACCUMULATE void Registry_send_all() { }
#ifdef SVQC
void Registry_send(string id, string hash);
#define REPLICATE(...) EVAL_REPLICATE(OVERLOAD(REPLICATE, __VA_ARGS__))
#define EVAL_REPLICATE(...) __VA_ARGS__
- [[accumulate]] void ReplicateVars(entity this, entity store, string thisname, int i) {}
+ ACCUMULATE void ReplicateVars(entity this, entity store, string thisname, int i) {}
#define REPLICATE_3(fld, type, var) REPLICATE_4(fld, type, var, )
#define REPLICATE_4(fld, type, var, func) REPLICATE_##type(fld, var, func)
// Step 2: const self
#if 1
#define self (RVALUE, self)
- [[alias("self")]] entity __self;
+ ALIAS("self") entity __self;
#define setself(s) (__self = s)
#define WITHSELF(value, block) WITH(entity, __self, value, (RVALUE, block))
#endif
entityclass(Sort);
// .float(entity,entity) sort_cmp;
-class(Sort).entity chain, sort_next, sort_prev;
+classfield(Sort).entity chain, sort_next, sort_prev;
entity Sort_Spawn();
#define spawnfunc_1(id) spawnfunc_2(id, FIELDS_UNION)
#define spawnfunc_2(id, whitelist) \
void __spawnfunc_##id(entity this); \
- [[accumulate]] void spawnfunc_##id(entity this) \
+ ACCUMULATE void spawnfunc_##id(entity this) \
{ \
if (!__spawnfunc_first) { \
__spawnfunc_first = true; \
}
#define _STATIC_INIT(func, where) \
- [[accumulate]] void _static_##func() { profile(#func); } \
+ ACCUMULATE void _static_##func##profile() { profile(#func); } \
+ ACCUMULATE_FUNCTION(where, _static_##func##profile) \
+ ACCUMULATE void _static_##func(); \
ACCUMULATE_FUNCTION(where, _static_##func) \
void _static_##func()
REGISTRY_RESERVE(Stats, m_id, STAT_##id, z); \
} \
} \
- [[accumulate]] void stats_get() \
+ ACCUMULATE void stats_get() \
{ \
T it = getstat_##T(STAT_##id.m_id); \
/* if (it != CAT(_STAT(id), _prev)) \
REGISTRY_RESERVE(Stats, m_id, STAT_##id, z); \
} \
} \
- [[accumulate]] void stats_add() \
+ ACCUMULATE void stats_add() \
{ \
.T fld = _STAT(id); \
addstat_##T(STAT_##id.m_id, fld); \
/** TODO: do we want the global copy to update? */
#define REGISTER_STAT_3(id, T, expr) \
REGISTER_STAT_2(id, T); \
- [[accumulate]] void GlobalStats_update(entity this) { STAT(id, this) = (expr); } \
+ ACCUMULATE void GlobalStats_update(entity this) { STAT(id, this) = (expr); } \
STATIC_INIT(worldstat_##id) { entity this = STATS; STAT(id, this) = (expr); }
#else
#define REGISTER_STAT_2(id, type)
/** Use UpperCamelCase for suite and test only */
#define TEST(suite, test) \
void _TEST_##suite##_##test(); \
- [[accumulate]] int TEST_RunAll_accumulated(int f) { \
+ ACCUMULATE int TEST_RunAll_accumulated(int f) { \
if (!TEST_Run(#suite "_" #test)) ++f; \
return = f; \
} \
float exp(float e)
{
- return (M_E ** e);
+ return pow(M_E, e);
}
float exp2(float e)
{
- return (2 ** e);
+ return pow(2, e);
}
float expm1(float e)
{
vector v;
v.z = 0;
v.y = ilogb(e) + 1;
- v.x = e / (2 ** v.y);
+ v.x = e / pow(2, v.y);
return v;
}
int ilogb(float e)
{
return floor(log2(fabs(e)));
}
-float ldexp(float e, int e)
+float ldexp(float x, int e)
{
- return e * (2 ** e);
+ return x * pow(2, e);
}
float logn(float e, float base)
{
float scalbn(float e, int n)
{
- return e * (2 ** n);
+ return e * pow(2, n);
}
float cbrt(float e)
{
- return copysign((fabs(e) ** (1.0/3.0)), e);
+ return copysign(pow(fabs(e), (1.0/3.0)), e);
}
float hypot(float e, float f)
{
bool Spectate(entity this, entity pl);
-#define SPECTATE_COPY() [[accumulate]] void SpectateCopy(entity this, entity spectatee)
+#define SPECTATE_COPY() ACCUMULATE void SpectateCopy(entity this, entity spectatee)
#define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }
#include "../common/triggers/triggers.qh"
entityclass(BGMScript);
-class(BGMScript) .string bgmscript;
-class(BGMScript) .float bgmscriptattack;
-class(BGMScript) .float bgmscriptdecay;
-class(BGMScript) .float bgmscriptsustain;
-class(BGMScript) .float bgmscriptrelease;
+classfield(BGMScript) .string bgmscript;
+classfield(BGMScript) .float bgmscriptattack;
+classfield(BGMScript) .float bgmscriptdecay;
+classfield(BGMScript) .float bgmscriptsustain;
+classfield(BGMScript) .float bgmscriptrelease;
#include "../common/constants.qh"
#include "../lib/csqcmodel/sv_model.qh"