REGISTER_REGISTRY(EntCSProps)
REGISTRY_SORT(EntCSProps)
REGISTRY_CHECK(EntCSProps)
-STATIC_INIT(RegisterEntCSProps_renumber) { FOREACH(EntCSProps, true, it.m_id = i); }
+STATIC_INIT(EntCSProps_renumber) { FOREACH(EntCSProps, true, it.m_id = i); }
// these entcs_props ids need to be referenced directly
int ENTCS_PROP_ENTNUM_id = 0;
int ENTCS_PROP_ORIGIN_id = 0;
-STATIC_INIT(RegisterEntCSProps_setglobalids)
+STATIC_INIT(EntCSProps_setglobalids)
{
FOREACH(EntCSProps, true, {
if (it.registered_id == "ENTCS_PROP_ENTNUM")
#ifdef SVQC
#define ENTCS_PROP_RESOURCE(id, ispublic, checkprop, setprop, decfactor, svsend, clreceive) \
bool id##_check(entity ent, entity player) { \
- return (floor(GetResourceAmount(ent, checkprop) / decfactor) != floor(GetResourceAmount(player, checkprop) / decfactor)); \
+ return (floor(GetResource(ent, checkprop) / decfactor) != floor(GetResource(player, checkprop) / decfactor)); \
} \
- void id##_set(entity ent, entity player) { SetResourceAmount(ent, checkprop, GetResourceAmount(player, checkprop)); } \
+ void id##_set(entity ent, entity player) { SetResourceExplicit(ent, checkprop, GetResource(player, checkprop)); } \
void id##_send(int chan, entity ent) { LAMBDA(svsend); } \
REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \
this.m_public = ispublic; \
// FIXME: use a better scale?
#define DEC_FACTOR 10
-ENTCS_PROP_RESOURCE(HEALTH, false, RESOURCE_HEALTH, ENTCS_SET_NORMAL, DEC_FACTOR,
- { WriteByte(chan, bound(0, GetResourceAmount(ent, RESOURCE_HEALTH) / DEC_FACTOR, 255)); },
+ENTCS_PROP_RESOURCE(HEALTH, false, RES_HEALTH, ENTCS_SET_NORMAL, DEC_FACTOR,
+ { WriteByte(chan, bound(0, GetResource(ent, RES_HEALTH) / DEC_FACTOR, 255)); },
{ ent.healthvalue = ReadByte() * DEC_FACTOR; })
-ENTCS_PROP_RESOURCE(ARMOR, false, RESOURCE_ARMOR, ENTCS_SET_NORMAL, DEC_FACTOR,
- { WriteByte(chan, bound(0, GetResourceAmount(ent, RESOURCE_ARMOR) / DEC_FACTOR, 255)); },
- { SetResourceAmount(ent, RESOURCE_ARMOR, ReadByte() * DEC_FACTOR); })
+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); })
#undef DEC_FACTOR
ENTCS_PROP(NAME, true, netname, ENTCS_SET_MUTABLE_STRING,
void entcs_think(entity this)
{
this.nextthink = time + 0.033333333333; // TODO: increase this to like 0.15 once the client can do smoothing
- entity o = this.owner;
- FOREACH(EntCSProps, it.m_check(this, o),
+ entity player = this.owner;
+ FOREACH(EntCSProps, it.m_check(this, player),
{
this.SendFlags |= BIT(it.m_id);
});