28 if (it.registered_id ==
"ENTCS_PROP_ENTNUM") ENTCS_PROP_ENTNUM_id = it.m_id;
29 if (it.registered_id ==
"ENTCS_PROP_ORIGIN") ENTCS_PROP_ORIGIN_id = it.m_id;
30 if (it.registered_id ==
"ENTCS_PROP_HEALTH") ENTCS_PROP_HEALTH_id = it.m_id;
36 void entcs_force_origin(
entity player)
38 CS(player).entcs.m_forceupdate =
BIT(ENTCS_PROP_ORIGIN_id);
45 .void(
int chan,
entity ent) m_send;
46 .void(
entity ent) m_receive;
49 #define _ENTCS_PROP(id, ispublic, checkprop, checkprop_pl, setprop, svsend, clreceive) \ 50 void id##_set(entity ent, entity player) { setprop(ent.(checkprop), player.(checkprop_pl)); } \ 51 void id##_send(int chan, entity ent) { LAMBDA(svsend); } \ 52 REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \ 53 this.m_public = ispublic; \ 54 this.m_check = id##_check; \ 55 this.m_set = id##_set; \ 56 this.m_send = id##_send; \ 59 #define ENTCS_PROP(id, ispublic, checkprop, checkprop_pl, setprop, svsend, clreceive) \ 60 bool id##_check(entity ent, entity player) { return (ent.(checkprop) != player.(checkprop_pl)); } \ 61 _ENTCS_PROP(id, ispublic, checkprop, checkprop_pl, setprop, svsend, clreceive) 63 #define ENTCS_PROP_CODED(id, ispublic, checkprop, checkprop_pl, setprop, decfactor, svsend, clreceive) \ 64 bool id##_check(entity ent, entity player) { \ 65 return (floor(ent.(checkprop)) / decfactor != floor(player.(checkprop_pl)) / decfactor); \ 67 _ENTCS_PROP(id, ispublic, checkprop, checkprop_pl, setprop, svsend, clreceive) 70 #define ENTCS_PROP(id, ispublic, checkprop, checkprop_pl, setprop, svsend, clreceive) \ 71 void id##_receive(entity ent) { LAMBDA(clreceive); } \ 72 REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \ 73 this.m_public = ispublic; \ 74 this.m_receive = id##_receive; \ 77 #define ENTCS_PROP_CODED(id, ispublic, checkprop, checkprop_pl, setprop, decfactor, svsend, clreceive) \ 78 ENTCS_PROP(id, ispublic, checkprop, checkprop_pl, setprop, svsend, clreceive) 82 #define ENTCS_PROP_RESOURCE(id, ispublic, checkprop, setprop, decfactor, svsend, clreceive) \ 83 bool id##_check(entity ent, entity player) { \ 84 return (floor(GetResource(ent, checkprop) / decfactor) != floor(GetResource(player, checkprop) / decfactor)); \ 86 void id##_set(entity ent, entity player) { SetResourceExplicit(ent, checkprop, GetResource(player, checkprop)); } \ 87 void id##_send(int chan, entity ent) { LAMBDA(svsend); } \ 88 REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \ 89 this.m_public = ispublic; \ 90 this.m_check = id##_check; \ 91 this.m_set = id##_set; \ 92 this.m_send = id##_send; \ 95 #define ENTCS_PROP_RESOURCE(id, ispublic, checkprop, setprop, decfactor, svsend, clreceive) \ 96 void id##_receive(entity ent) { LAMBDA(clreceive); } \ 97 REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \ 98 this.m_public = ispublic; \ 99 this.m_receive = id##_receive; \ 103 #define ENTCS_SET_NORMAL(var, x) MACRO_BEGIN \ 108 #define ENTCS_SET_MUTABLE_STRING(var, x) MACRO_BEGIN \ 115 { WriteVector(chan, ent.origin); },
128 { ent.healthvalue = ReadByte() *
DEC_FACTOR; })
145 { ent.skin = ReadByte(); })
149 { ent.colormap = ReadByte(); })
153 { ent.frags = ReadShort(); })
158 { ent.sv_solid = ReadByte(); })
162 int ENTCS_PUBLICMASK = 0, ENTCS_PRIVATEMASK = 0;
168 ENTCS_PUBLICMASK |=
BIT(it.m_id);
170 ENTCS_PRIVATEMASK |=
BIT(it.m_id);
174 void entcs_update_players(
entity player)
178 CS(it).entcs.SendFlags |= ENTCS_PRIVATEMASK;
185 sf |=
BIT(ENTCS_PROP_ENTNUM_id);
189 if (radar_showenemies)
break;
193 sf &= ENTCS_PUBLICMASK;
196 sf |= this.m_forceupdate;
197 this.m_forceupdate = 0;
198 if (chan == MSG_ENTITY)
199 WriteHeader(chan, ENT_CLIENT_ENTCS);
201 WriteHeader(chan, CLIENT_ENTCS);
206 it.m_send(chan, this);
213 return _entcs_send(
this, to, sf, MSG_ENTITY);
216 void entcs_think(
entity this)
220 FOREACH(EntCSProps, it.m_check(
this, player),
222 it.m_set(
this, player);
223 this.SendFlags |=
BIT(it.m_id);
229 this.SendFlags &= ~
BIT(ENTCS_PROP_HEALTH_id);
236 this.SendFlags |=
BIT(ENTCS_PROP_ORIGIN_id);
248 Net_LinkEntity(e,
false, 0, entcs_send);
261 if (!
CS(player).entcs)
return;
262 delete(
CS(player).entcs);
270 void Ent_RemoveEntCS(
entity this)
273 entity e = entcs_receiver(n);
274 entcs_receiver(n,
NULL);
277 if (e !=
this)
delete(e);
280 void entcs_think(
entity this)
287 this.has_origin = this.has_sv_origin;
290 this.has_origin =
true;
297 if (this.
model != e.model)
303 bool ReadEntcs(
entity this)
306 entity e = entcs_receiver(n);
316 entcs_receiver(n, e);
318 else if (e !=
this &&
this)
324 entcs_receiver(n, e);
329 int sf = ReadShort();
330 e.has_sv_origin =
false;
331 e.m_entcs_private =
boolean(sf &
BIT(ENTCS_PROP_ENTNUM_id));
347 this.entremove = Ent_RemoveEntCS;
349 return ReadEntcs(
this);
354 return ReadEntcs(
NULL);
void InterpolateOrigin_Note(entity this)
void entcs_detach(entity this)
void InterpolateOrigin_Undo(entity this)
snap origin to iorigin2 (actual origin)
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
entity CSQCModel_server2csqc(int i)
void entcs_attach(entity this)
ENTCS_PROP_RESOURCE(ARMOR, false, RES_ARMOR, ENTCS_SET_NORMAL, DEC_FACTOR, { WriteByte(chan, bound(0, GetResource(ent, RES_ARMOR)/DEC_FACTOR, 255));}, { SetResourceExplicit(ent, RES_ARMOR, ReadByte() *DEC_FACTOR);}) ENTCS_PROP(NAME
Header file that describes the resource system.
ClientState CS(Client this)
ENTCS_PROP(ENTNUM, false, sv_entnum, sv_entnum, ENTCS_SET_NORMAL, {}, {}) ENTCS_PROP(ORIGIN
#define FOREACH_CLIENT(cond, body)
#define REGISTRY_CHECK(id)
#define NET_HANDLE(id, param)
#define REGISTRY_SORT(...)
#define IS_REAL_CLIENT(v)
#define REGISTER_REGISTRY(id)
#define REGISTRY_DEFINE_GET(id, null)
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
STATIC_INIT(EntCSProps_renumber)
#define REGISTRY(id, max)
Declare a new registry.
#define ENTCS_SET_NORMAL(var, x)
ENTCS_PROP_CODED(ANGLES, false, angles_y, angles_y, ENTCS_SET_NORMAL, DEC_FACTOR, { WriteByte(chan, ent.angles.y/DEC_FACTOR);}, { vector v='0 0 0';v.y=ReadByte() *DEC_FACTOR;ent.angles=v;}) ENTCS_PROP_RESOURCE(HEALTH
#define MODEL(name, path)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define ENTCS_SET_MUTABLE_STRING(var, x)
the engine player name strings are mutable!
void InterpolateOrigin_Reset(entity this)
#define new_pure(class)
purely logical entities (.origin doesn't work)
bool intermission_running
#define FOREACH(list, cond, body)
void InterpolateOrigin_Do(entity this)
set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time