#include "hud.qh"
#include "hud_config.qh"
-#include "mapvoting.qh"
-#include "scoreboard.qh"
-#include "teamradar.qh"
-#include "../common/t_items.qh"
-#include "../common/deathtypes/all.qh"
-#include "../common/items/all.qc"
-#include "../common/mapinfo.qh"
-#include "../common/mutators/mutator/waypoints/all.qh"
-#include "../common/stats.qh"
-#include "../lib/csqcmodel/cl_player.qh"
+#include "../mapvoting.qh"
+#include "../scoreboard.qh"
+#include "../teamradar.qh"
+#include "../../common/t_items.qh"
+#include "../../common/deathtypes/all.qh"
+#include "../../common/items/all.qc"
+#include "../../common/mapinfo.qh"
+#include "../../common/mutators/mutator/waypoints/all.qh"
+#include "../../common/stats.qh"
+#include "../../lib/csqcmodel/cl_player.qh"
// TODO: remove
-#include "../server/mutators/mutator/gamemode_ctf.qc"
+#include "../../server/mutators/mutator/gamemode_ctf.qc"
/*
#ifndef CLIENT_HUD_H
#define CLIENT_HUD_H
-#include "../common/weapons/all.qh"
+#include "../../common/weapons/all.qh"
bool HUD_Radar_Clickable();
void HUD_Radar_Mouse();
vector autocvar_sv_player_headsize = '24 24 12';
-// not so constant
-#define PL_VIEW_OFS STAT(PL_VIEW_OFS, NULL)
-#define PL_CROUCH_VIEW_OFS STAT(PL_CROUCH_VIEW_OFS, NULL)
-#define PL_MIN STAT(PL_MIN, NULL)
-#define PL_CROUCH_MIN STAT(PL_CROUCH_MIN, NULL)
-#define PL_MAX STAT(PL_MAX, NULL)
-#define PL_CROUCH_MAX STAT(PL_CROUCH_MAX, NULL)
-
// a bit more constant
const vector PL_MAX_CONST = '16 16 45';
const vector PL_MIN_CONST = '-16 -16 -24';
#define CSQCPLAYER_HOOK_POSTCAMERASETUP() \
CSQCPlayer_SetViewLocation()
-// force updates of player entities that often even if unchanged
+// force updates of player entities this frequently (per second) even if unchanged
#ifndef CSQCPLAYER_FORCE_UPDATES
-#define CSQCPLAYER_FORCE_UPDATES 0.25
+#define CSQCPLAYER_FORCE_UPDATES 4
#endif
// mod must define:
.bool silent;
#include "rubble.qh"
-#include "../common/physics/movetypes/movetypes.qh"
+#include "../../physics/movetypes/movetypes.qh"
.float scale;
.float alpha;
{
AL_DELETE(_entcs);
}
- #define entcs_receiver(...) EVAL(OVERLOAD(entcs_receiver, __VA_ARGS__))
+ #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
+ #define EVAL_entcs_receiver(...) __VA_ARGS__
#define entcs_receiver_1(i) AL_gete(_entcs, i)
#define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
#define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
loc += tele_target.origin + '0 0 128' * iteration_scale;
- tracebox(loc, PL_MIN, PL_MAX, loc, MOVE_NORMAL, player);
+ tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(tele_target.origin, loc, MOVE_NOMONSTERS, tele_target); // double check to make sure we're not spawning outside the world
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 96' * iteration_scale;
loc += ('0 1 0' * random()) * 128 * iteration_scale;
- tracebox(loc, PL_MIN, PL_MAX, loc, MOVE_NORMAL, self);
+ tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, self);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the world
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 128' * iteration_scale;
loc += ('0 1 0' * random()) * 256 * iteration_scale;
- tracebox(loc, PL_MIN, PL_MAX, loc, MOVE_NORMAL, self);
+ tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, self);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the world
[[accumulate]] void RegisterCallbacks() { CALLBACK_##name = NEW(Callback, func); }
#define MUTATOR_HOOKFUNCTION(...) \
- EVAL(OVERLOAD(MUTATOR_HOOKFUNCTION, __VA_ARGS__))
+ EVAL_MUTATOR_HOOKFUNCTION(OVERLOAD(MUTATOR_HOOKFUNCTION, __VA_ARGS__))
+#define EVAL_MUTATOR_HOOKFUNCTION(...) __VA_ARGS__
#define MUTATOR_HOOKFUNCTION_2(mut, cb) \
MUTATOR_HOOKFUNCTION_3(mut, cb, CBC_ORDER_ANY)
/**/
#define MUTATOR_ARGV(x, type) MUTATOR_ARGV_##x##_##type
-#define MUTATOR_NEWGLOBAL(x, type) type MUTATOR_ARGV(x, type);
+#define MUTATOR_NEWGLOBAL(x, type) type MUTATOR_ARGV_##x##_##type;
MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 0)
MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 1)
if(it.frozen == 0)
if(it != self)
{
- tracebox(it.origin, PL_MIN, PL_MAX, it.origin - '0 0 100', MOVE_WORLDONLY, it);
+ tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - '0 0 100', MOVE_WORLDONLY, it);
if(trace_fraction != 1.0)
if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
{
switch(pc)
{
case 0:
- tracebox(it.origin , PL_MIN, PL_MAX, it.origin + v_right * 128, MOVE_NORMAL, it);
+ tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128, MOVE_NORMAL, it);
break;
case 1:
- tracebox(it.origin , PL_MIN, PL_MAX, it.origin - v_right * 128 , MOVE_NORMAL, it);
+ tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 , MOVE_NORMAL, it);
break;
case 2:
- tracebox(it.origin , PL_MIN, PL_MAX, it.origin + v_right * 64 - v_forward * 64, MOVE_NORMAL, it);
+ tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 64 - v_forward * 64, MOVE_NORMAL, it);
break;
case 3:
- tracebox(it.origin , PL_MIN, PL_MAX, it.origin - v_right * 64 - v_forward * 64, MOVE_NORMAL, it);
+ tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 64 - v_forward * 64, MOVE_NORMAL, it);
break;
case 4:
- tracebox(it.origin , PL_MIN, PL_MAX, it.origin - v_forward * 128, MOVE_NORMAL, it);
+ tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128, MOVE_NORMAL, it);
break;
}
#define X(unstick_offset) \
{ \
vector neworigin = unstick_offset + this.origin; \
- tracebox(neworigin, PL_CROUCH_MIN, PL_CROUCH_MAX, neworigin, MOVE_NORMAL, this); \
+ tracebox(neworigin, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL), neworigin, MOVE_NORMAL, this); \
if (!trace_startsolid) \
{ \
setorigin(this, neworigin); \
// wants to stand, if currently crouching we need to check for a low ceiling first
if (IS_DUCKED(this))
{
- tracebox(this.origin, PL_MIN, PL_MAX, this.origin, MOVE_NORMAL, this);
+ tracebox(this.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), this.origin, MOVE_NORMAL, this);
if (!trace_startsolid) UNSET_DUCKED(this);
}
}
// first calculate a typical start point for the jump
org = (self.absmin + self.absmax) * 0.5;
- org_z = self.absmax.z - PL_MIN.z;
+ org_z = self.absmax.z - STAT(PL_MIN, NULL).z;
if (self.target)
{
#ifdef SVQC
entity e = spawn();
setorigin(e, org);
- setsize(e, PL_MIN, PL_MAX);
+ setsize(e, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
e.velocity = trigger_push_calculatevelocity(org, t, self.height);
tracetoss(e, e);
if(e.movetype == MOVETYPE_NONE)
{
entity e = spawn();
setorigin(e, org);
- setsize(e, PL_MIN, PL_MAX);
+ setsize(e, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
e.velocity = self.movedir;
tracetoss(e, e);
waypoint_spawnforteleporter(self, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity));
//vector exitspot;
float mysize;
- tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
+ tracebox(self.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, self.owner);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return prefer_spot;
v = randomvec();
v_z = 0;
v = v2 + normalize(v) * mysize;
- tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
+ tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, self.owner);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return v;
}
WriteAngle(MSG_ONE, 0);
}
- setsize(_player, PL_MIN,PL_MAX);
+ setsize(_player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
_player.takedamage = DAMAGE_AIM;
_player.solid = SOLID_SLIDEBOX;
_player.alpha = 1;
_player.PlayerPhysplug = func_null;
_player.vehicle = world;
- _player.view_ofs = PL_VIEW_OFS;
+ _player.view_ofs = STAT(PL_VIEW_OFS, NULL);
_player.event_damage = PlayerDamage;
_player.hud = HUD_NORMAL;
PS(_player).m_switchweapon = _vehicle.m_switchweapon;
veh.vehicle_hudmodel.viewmodelforclient = pl;
- tracebox(pl.origin, PL_MIN, PL_MAX, pl.origin, false, pl);
+ tracebox(pl.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), pl.origin, false, pl);
pl.crouch = false;
- pl.view_ofs = PL_VIEW_OFS;
- setsize (pl, PL_MIN, PL_MAX);
+ pl.view_ofs = STAT(PL_VIEW_OFS, NULL);
+ setsize (pl, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
veh.event_damage = vehicles_damage;
veh.nextthink = 0;
//vector exitspot;
float mysize;
- tracebox(gunner.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, player);
+ tracebox(gunner.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return prefer_spot;
- mysize = 1.5 * vlen(PL_MAX - PL_MIN); // can't use gunner's size, as they don't have a size
+ mysize = 1.5 * vlen(STAT(PL_MAX, NULL) - STAT(PL_MIN, NULL)); // can't use gunner's size, as they don't have a size
float i;
vector v, v2;
v2 = 0.5 * (gunner.absmin + gunner.absmax);
v = randomvec();
v_z = 0;
v = v2 + normalize(v) * mysize;
- tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, player);
+ tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return v;
}
}
CSQCVehicleSetup(player, HUD_NORMAL);
- setsize(player, PL_MIN, PL_MAX);
+ setsize(player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
player.takedamage = DAMAGE_AIM;
player.solid = SOLID_SLIDEBOX;
player.effects &= ~EF_NODRAW;
player.alpha = 1;
player.PlayerPhysplug = func_null;
- player.view_ofs = PL_VIEW_OFS;
+ player.view_ofs = STAT(PL_VIEW_OFS, NULL);
player.event_damage = PlayerDamage;
player.hud = HUD_NORMAL;
player.teleportable = TELEPORT_NORMAL;
}
#endif
-#define REGISTER_WEAPON(...) EVAL(OVERLOAD(REGISTER_WEAPON, __VA_ARGS__))
+#define REGISTER_WEAPON(...) EVAL_REGISTER_WEAPON(OVERLOAD(REGISTER_WEAPON, __VA_ARGS__))
+#define EVAL_REGISTER_WEAPON(...) __VA_ARGS__
#define REGISTER_WEAPON_2(id, inst) REGISTER(Weapons, WEP, id, m_id, inst)
/** TODO: deprecated - remove */
#define REGISTER_WEAPON_3(id, sname, inst) \
norm = trace_plane_normal;
if(trace_ent.iscreature)
{
- traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN.z, MOVE_WORLDONLY, self);
+ traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * STAT(PL_MIN, NULL).z, MOVE_WORLDONLY, self);
if(trace_fraction >= 1)
return;
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
{
if ((this.flags & FL_DUCKED) || !this.isplayermodel)
{
- this.mins = PL_CROUCH_MIN;
- this.maxs = PL_CROUCH_MAX;
- this.view_ofs = PL_CROUCH_VIEW_OFS;
+ this.mins = STAT(PL_CROUCH_MIN, NULL);
+ this.maxs = STAT(PL_CROUCH_MAX, NULL);
+ this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, NULL);
}
else
{
- this.mins = PL_MIN;
- this.maxs = PL_MAX;
- this.view_ofs = PL_VIEW_OFS;
+ this.mins = STAT(PL_MIN, NULL);
+ this.maxs = STAT(PL_MAX, NULL);
+ this.view_ofs = STAT(PL_VIEW_OFS, NULL);
}
}
{
const vector v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
const float vh = STAT(VIEWHEIGHT);
- const vector pl_viewofs = PL_VIEW_OFS;
- const vector pl_viewofs_crouch = PL_CROUCH_VIEW_OFS;
+ const vector pl_viewofs = STAT(PL_VIEW_OFS, NULL);
+ const vector pl_viewofs_crouch = STAT(PL_CROUCH_VIEW_OFS, NULL);
const entity e = csqcplayer;
if (e)
{
#define CSQCMODEL_HOOK_PREDRAW
#define CSQCPLAYER_HOOK_POSTCAMERASETUP
-// force updates of player entities that often even if unchanged
-#define CSQCPLAYER_FORCE_UPDATES 0.25
+// force updates of player entities this frequently (per second) even if unchanged
+#define CSQCPLAYER_FORCE_UPDATES 4
// mod must define:
//vector PL_MIN = ...;
if(isplayer && time > e.csqcmodel_nextforcedupdate)
{
e.SendFlags |= CSQCMODEL_PROPERTY_ORIGIN;
- e.csqcmodel_nextforcedupdate = time + CSQCPLAYER_FORCE_UPDATES * (0.5 + random()); // ensure about 4 origin sends per sec
+ e.csqcmodel_nextforcedupdate = time + (1 / (CSQCPLAYER_FORCE_UPDATES)) * (0.5 + random()); // ensure about 4 origin sends per sec
}
#endif
__AUTOCVAR(file, archive, var, type, desc, default_##type)
#define AUTOCVAR_6(file, archive, var, type, default, desc) \
__AUTOCVAR(file, archive, var, type, desc, default)
-#define _AUTOCVAR(...) EVAL(OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__))
+#define _AUTOCVAR(...) EVAL__AUTOCVAR(OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__))
+#define EVAL__AUTOCVAR(...) __VA_ARGS__
#define AUTOCVAR_SAVE(...) _AUTOCVAR(true, __VA_ARGS__)
#define AUTOCVAR(...) _AUTOCVAR(false, __VA_ARGS__)
return e;
}
-#define LL_CLEAR(...) EVAL(OVERLOAD(LL_CLEAR, __VA_ARGS__))
+#define LL_CLEAR(...) EVAL_LL_CLEAR(OVERLOAD(LL_CLEAR, __VA_ARGS__))
+#define EVAL_LL_CLEAR(...) __VA_ARGS__
#define LL_CLEAR_1(this) LL_CLEAR_2(this, LAMBDA())
#define LL_CLEAR_2(this, dtor) \
MACRO_BEGIN \
} \
} MACRO_END
-#define LL_DELETE(...) EVAL(OVERLOAD(LL_DELETE, __VA_ARGS__))
+#define LL_DELETE(...) EVAL_LL_DELETE(OVERLOAD(LL_DELETE, __VA_ARGS__))
+#define EVAL_LL_DELETE(...) __VA_ARGS__
#define LL_DELETE_1(this) LL_DELETE_2(this, LAMBDA())
#define LL_DELETE_2(this, dtor) \
MACRO_BEGIN \
}
-#define entityclass(...) EVAL(OVERLOAD(entityclass, __VA_ARGS__))
+#define entityclass(...) EVAL_entityclass(OVERLOAD(entityclass, __VA_ARGS__))
+#define EVAL_entityclass(...) __VA_ARGS__
#define entityclass_1(name) entityclass_2(name, Object)
#ifndef QCC_SUPPORT_ENTITYCLASS
#define entityclass_2(name, base) typedef entity name
* @param fld The field to store the locally unique unique entity id
* @param inst An expression to create a new instance, invoked for every registration
*/
-#define REGISTER(...) EVAL(OVERLOAD(REGISTER, __VA_ARGS__))
+#define REGISTER(...) EVAL_REGISTER(OVERLOAD(REGISTER, __VA_ARGS__))
+#define EVAL_REGISTER(...) __VA_ARGS__
#define REGISTER_5(registry, ns, id, fld, inst) REGISTER_4(registry, ns##_##id, fld, inst)
#define REGISTER_4(registry, id, fld, inst) \
entity id; \
#define REGISTRY_NEXT enemy
.entity REGISTRY_NEXT;
-#define REGISTRY_SORT(...) EVAL(OVERLOAD(REGISTRY_SORT, __VA_ARGS__))
+#define REGISTRY_SORT(...) EVAL_REGISTRY_SORT(OVERLOAD(REGISTRY_SORT, __VA_ARGS__))
+#define EVAL_REGISTRY_SORT(...) __VA_ARGS__
#define REGISTRY_SORT_1(id) REGISTRY_SORT_2(id, 0)
#define REGISTRY_SORT_2(id, skip) \
void _REGISTRY_SWAP_##id(int i, int j, entity pass) \
} \
void Registry_send_all() { Registry_send(#id, REGISTRY_HASH(id)); } \
-#define REGISTER_REGISTRY(...) EVAL(OVERLOAD(REGISTER_REGISTRY, __VA_ARGS__))
+#define REGISTER_REGISTRY(...) EVAL_REGISTER_REGISTRY(OVERLOAD(REGISTER_REGISTRY, __VA_ARGS__))
+#define EVAL_REGISTER_REGISTRY(...) __VA_ARGS__
#define REGISTER_REGISTRY_1(id) REGISTER_REGISTRY_2(id, #id)
#define REGISTER_REGISTRY_2(id, str) \
ACCUMULATE_FUNCTION(__static_init, Register##id) \
#define REPLICATE_H
#ifndef MENUQC
- #define REPLICATE(...) EVAL(OVERLOAD(REPLICATE, __VA_ARGS__))
+ #define REPLICATE(...) EVAL_REPLICATE(OVERLOAD(REPLICATE, __VA_ARGS__))
+ #define EVAL_REPLICATE(...) __VA_ARGS__
[[accumulate]] void ReplicateVars(entity this, string thisname, int i) {}
#define FIELDS_COMMON(fld) \
FIELD_SCALAR(fld, classname) \
+ FIELD_SCALAR(fld, sourceLocFile) \
+ FIELD_SCALAR(fld, sourceLocLine) \
FIELD_SCALAR(fld, spawnfunc_checked) \
+ FIELD_VEC(fld, origin) \
/**/
#define FIELDS_UNION(fld) \
- FIELD_SCALAR(fld, sourceLocFile) \
- FIELD_SCALAR(fld, sourceLocLine) \
FIELD_SCALAR(fld, Version) \
FIELD_SCALAR(fld, ammo_cells) \
FIELD_SCALAR(fld, ammo_nails) \
FIELD_VEC(fld, maxs) \
FIELD_VEC(fld, mins) \
FIELD_VEC(fld, modelscale_vec) \
- FIELD_VEC(fld, origin) \
FIELD_VEC(fld, velocity) \
/**/
- #define spawnfunc(...) EVAL(OVERLOAD(spawnfunc, __VA_ARGS__))
+ #define spawnfunc(...) EVAL_spawnfunc(OVERLOAD(spawnfunc, __VA_ARGS__))
+ #define EVAL_spawnfunc(...) __VA_ARGS__
#endif
.int m_id;
typedef vector vectori;
-#define REGISTER_STAT(...) EVAL(OVERLOAD(REGISTER_STAT, __VA_ARGS__))
+#define REGISTER_STAT(...) EVAL_REGISTER_STAT(OVERLOAD(REGISTER_STAT, __VA_ARGS__))
+#define EVAL_REGISTER_STAT(...) __VA_ARGS__
#if defined(CSQC)
/** Get all stats and store them as globals, access with `STAT(ID)` */
void stats_get() {}
- #define STAT(...) EVAL(OVERLOAD(STAT, __VA_ARGS__))
+ #define STAT(...) EVAL_STAT(OVERLOAD(STAT, __VA_ARGS__))
+ #define EVAL_STAT(...) __VA_ARGS__
#define STAT_1(id) STAT_2(id, NULL)
#define STAT_2(id, cl) (0, _STAT(id))
if (it != CAT(_STAT(id), _prev)) \
CAT(_STAT(id), _prev) = _STAT(id) = it; \
}
- #define REGISTER_STAT_3(x, T, expr) REGISTER_STAT(x, T)
+ #define REGISTER_STAT_3(x, T, expr) REGISTER_STAT_2(x, T)
#elif defined(SVQC)
/** Add all registered stats, access with `STAT(ID, player)` or `.type stat = _STAT(ID); player.stat` */
void stats_add() {}
- #define STAT(id, cl) (cl._STAT(id))
+ #define STAT(id, cl) (cl)._STAT(id)
#define addstat_int(id, fld) addstat(id, AS_INT, fld)
#define addstat_bool(id, fld) addstat(id, AS_INT, fld)
} \
[[accumulate]] void stats_add() \
{ \
- addstat_##T(STAT_##id.m_id, _STAT(id)); \
+ .T fld = _STAT(id); \
+ addstat_##T(STAT_##id.m_id, fld); \
}
void GlobalStats_update(entity this) {}
- #define REGISTER_STAT_3(x, T, expr) \
- REGISTER_STAT(x, T); \
- [[accumulate]] void GlobalStats_update(entity this) { STAT(x, this) = (expr); } \
- STATIC_INIT(worldstat_##x) { entity this = world; STAT(x, this) = (expr); }
+ #define REGISTER_STAT_3(id, T, expr) \
+ REGISTER_STAT_2(id, T); \
+ [[accumulate]] void GlobalStats_update(entity this) { STAT(id, this) = (expr); } \
+ STATIC_INIT(worldstat_##id) { entity this = world; STAT(id, this) = (expr); }
#else
#define REGISTER_STAT_2(id, type)
- #define REGISTER_STAT_3(x, T, expr)
+ #define REGISTER_STAT_3(id, T, expr)
#endif
const int STATS_ENGINE_RESERVE = 32;
// Flying
self.BUTTON_HOOK = true;
- if(self.navigation_jetpack_point.z - PL_MAX.z + PL_MIN.z < self.origin.z)
+ if(self.navigation_jetpack_point.z - STAT(PL_MAX, NULL).z + STAT(PL_MIN, NULL).z < self.origin.z)
{
self.movement_x = dir * v_forward * maxspeed;
self.movement_y = dir * v_right * maxspeed;
{
if (walkfromwp)
{
- if (tracewalk(ent, v, PL_MIN, PL_MAX, org, bot_navigation_movemode))
+ if (tracewalk(ent, v, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), org, bot_navigation_movemode))
return true;
}
else
{
- if (tracewalk(ent, org, PL_MIN, PL_MAX, v, bot_navigation_movemode))
+ if (tracewalk(ent, org, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, bot_navigation_movemode))
return true;
}
}
}
org = ent.origin + 0.5 * (ent.mins + ent.maxs);
- org.z = ent.origin.z + ent.mins.z - PL_MIN.z; // player height
+ org.z = ent.origin.z + ent.mins.z - STAT(PL_MIN, NULL).z; // player height
// TODO possibly make other code have the same support for bboxes
if(ent.tag_entity)
org = org + ent.tag_entity.origin;
float zdistance, xydistance, cost, t, fuel;
vector down, npa, npb;
- down = '0 0 -1' * (PL_MAX.z - PL_MIN.z) * 10;
+ down = '0 0 -1' * (STAT(PL_MAX, NULL).z - STAT(PL_MIN, NULL).z) * 10;
do{
npa = pointa + down;
return true;
// if it can reach the goal there is nothing more to do
- if (tracewalk(self, startposition, PL_MIN, PL_MAX, (e.absmin + e.absmax) * 0.5, bot_navigation_movemode))
+ if (tracewalk(self, startposition, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), (e.absmin + e.absmax) * 0.5, bot_navigation_movemode))
return true;
// see if there are waypoints describing a path to the item
// evaluate the next goal on the queue
float d = vlen(self.origin - bot_waypoint_queue_goal.origin);
bot_debug(strcat(self.netname, " evaluating ", bot_waypoint_queue_goal.classname, " with distance ", ftos(d), "\n"));
- if(tracewalk(bot_waypoint_queue_goal, self.origin, PL_MIN, PL_MAX, bot_waypoint_queue_goal.origin, bot_navigation_movemode))
+ if(tracewalk(bot_waypoint_queue_goal, self.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), bot_waypoint_queue_goal.origin, bot_navigation_movemode))
{
if( d > bot_waypoint_queue_bestgoalrating)
{
if(!w.wpisbox)
{
- setsize(w, PL_MIN - '1 1 0', PL_MAX + '1 1 0');
+ setsize(w, STAT(PL_MIN, NULL) - '1 1 0', STAT(PL_MAX, NULL) + '1 1 0');
if(!move_out_of_solid(w))
{
if(!(f & WAYPOINTFLAG_GENERATED))
navigation_testtracewalk = 0;
if (!self.wpisbox)
{
- tracebox(sv - PL_MIN.z * '0 0 1', PL_MIN, PL_MAX, sv, false, self);
+ tracebox(sv - STAT(PL_MIN, NULL).z * '0 0 1', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), sv, false, self);
if (!trace_startsolid)
{
//dprint("sv deviation", vtos(trace_endpos - sv), "\n");
}
if (!e.wpisbox)
{
- tracebox(ev - PL_MIN.z * '0 0 1', PL_MIN, PL_MAX, ev, false, e);
+ tracebox(ev - STAT(PL_MIN, NULL).z * '0 0 1', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), ev, false, e);
if (!trace_startsolid)
{
//dprint("ev deviation", vtos(trace_endpos - ev), "\n");
}
//traceline(self.origin, e.origin, false, world);
//if (trace_fraction == 1)
- if (!self.wpisbox && tracewalk(self, sv, PL_MIN, PL_MAX, ev, MOVE_NOMONSTERS))
+ if (!self.wpisbox && tracewalk(self, sv, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), ev, MOVE_NOMONSTERS))
waypoint_addlink(self, e);
else
relink_walkculled += 0.5;
- if (!e.wpisbox && tracewalk(e, ev, PL_MIN, PL_MAX, sv, MOVE_NOMONSTERS))
+ if (!e.wpisbox && tracewalk(e, ev, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), sv, MOVE_NOMONSTERS))
waypoint_addlink(e, self);
else
relink_walkculled += 0.5;
vector waypoint_fixorigin(vector position)
{
- tracebox(position + '0 0 1' * (1 - PL_MIN.z), PL_MIN, PL_MAX, position + '0 0 -512', MOVE_NOMONSTERS, world);
+ tracebox(position + '0 0 1' * (1 - STAT(PL_MIN, NULL).z), STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), position + '0 0 -512', MOVE_NOMONSTERS, world);
if(trace_fraction < 1)
position = trace_endpos;
//traceline(position, position + '0 0 -512', MOVE_NOMONSTERS, world);
float botframe_autowaypoints_fixdown(vector v)
{
- tracebox(v, PL_MIN, PL_MAX, v + '0 0 -64', MOVE_NOMONSTERS, world);
+ tracebox(v, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v + '0 0 -64', MOVE_NOMONSTERS, world);
if(trace_fraction >= 1)
return 0;
return 1;
e.nextthink = time;
e.solid = 0; // nothing special
setmodel(e, MDL_MARKER);
- setsize(e, PL_MIN, PL_MAX);
+ setsize(e, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
e.skin = 2;
if(argc == 3)
e.cnt = stof(argv(1));
self.crouch = false;
self.revival_time = 0;
- setorigin (self, (spot.origin + PL_VIEW_OFS)); // offset it so that the spectator spawns higher off the ground, looks better this way
+ setorigin (self, (spot.origin + STAT(PL_VIEW_OFS, NULL))); // offset it so that the spectator spawns higher off the ground, looks better this way
self.prevorigin = self.origin;
self.items = 0;
self.weapons = '0 0 0';
setmodel(self, MDL_Null);
self.drawonlytoclient = self;
- setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
+ setsize (self, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL)); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
PS(self).m_weapon = WEP_Null;
this.drawonlytoclient = NULL;
this.crouch = false;
- this.view_ofs = PL_VIEW_OFS;
- setsize(this, PL_MIN, PL_MAX);
+ this.view_ofs = STAT(PL_VIEW_OFS, NULL);
+ setsize(this, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
this.spawnorigin = spot.origin;
setorigin(this, spot.origin + '0 0 1' * (1 - this.mins.z - 24));
// don't reset back to last position, even if new position is stuck in solid
for (entity e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
{
vector org = e.origin;
- tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
+ tracebox(e.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), e.origin - '0 0 512', MOVE_NOMONSTERS, world);
setorigin(e, trace_endpos);
if (navigation_findnearestwaypoint(e, false))
{
start = stov(vtos(start));
end = stov(vtos(end));
- tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
+ tracebox(start, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), end, MOVE_NOMONSTERS, world);
if (!trace_startsolid && trace_fraction < 1)
{
p = trace_endpos;
- tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world);
+ tracebox(p, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), p, MOVE_NOMONSTERS, world);
if (trace_startsolid)
{
rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
- tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
+ tracebox(start, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), end, MOVE_NOMONSTERS, world);
// how much do we need to back off?
safe = 1;
for ( ; ; )
{
pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
- tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world);
+ tracebox(pos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), pos, MOVE_NOMONSTERS, world);
if (trace_startsolid)
{
if ((safe + unsafe) * 0.5 == unsafe) break;
LOG_INFO("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n");
LOG_INFO("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n");
- tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
+ tracebox(p, STAT(PL_MIN, NULL) + '0.1 0.1 0.1', STAT(PL_MAX, NULL) - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
if (trace_startsolid) LOG_INFO("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
else LOG_INFO("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
if (++hitcount >= 10) break;
{
q = p + normalize(end - p) * (dq + dqf);
if (q == q0) break;
- tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world);
+ tracebox(p, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), q, MOVE_NOMONSTERS, world);
if (trace_startsolid) error("THIS ONE cannot happen");
if (trace_fraction > 0) dq += dqf * trace_fraction;
dqf *= 0.5;
o.y += random() * (world.maxs.y - world.mins.y);
o.z += random() * (world.maxs.z - world.mins.z);
- tracebox(o, PL_MIN, PL_MAX, o - '0 0 32768', MOVE_WORLDONLY, world);
+ tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 32768', MOVE_WORLDONLY, world);
if(trace_fraction == 1)
continue;
}
// in any case:
setattachment(key, world, "");
- setorigin(key, key.owner.origin + '0 0 1' * (PL_MIN.z - KH_KEY_MIN_z));
+ setorigin(key, key.owner.origin + '0 0 1' * (STAT(PL_MIN, NULL).z - KH_KEY_MIN_z));
key.angles = key.owner.angles;
#else
setorigin(key, key.owner.origin + key.origin.z * '0 0 1');
{
vector o;
o = portal.origin;
- portal.mins = PL_MIN - SAFERNUDGE;
- portal.maxs = PL_MAX + SAFERNUDGE;
+ portal.mins = STAT(PL_MIN, NULL) - SAFERNUDGE;
+ portal.maxs = STAT(PL_MAX, NULL) + SAFERNUDGE;
fixedmakevectors(portal.mangle);
portal.origin += 16 * v_forward;
if(!move_out_of_solid(portal))
self.touch = checkpoint_touch;
o = (self.absmin + self.absmax) * 0.5;
- tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
+ tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
waypoint_spawnforitem_force(self, trace_endpos);
self.nearestwaypointtimeout = time + 1000000000;
self.touch = checkpoint_touch;
o = (self.absmin + self.absmax) * 0.5;
- tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
+ tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
waypoint_spawnforitem_force(self, trace_endpos);
self.nearestwaypointtimeout = time + 1000000000;