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")
bool id##_check(entity ent, entity player) { \
return (floor(GetResource(ent, checkprop) / decfactor) != floor(GetResource(player, checkprop) / decfactor)); \
} \
- void id##_set(entity ent, entity player) { SetResource(ent, checkprop, GetResource(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; \
ENTCS_PROP_RESOURCE(ARMOR, false, RES_ARMOR, ENTCS_SET_NORMAL, DEC_FACTOR,
{ WriteByte(chan, bound(0, GetResource(ent, RES_ARMOR) / DEC_FACTOR, 255)); },
- { SetResource(ent, RES_ARMOR, ReadByte() * DEC_FACTOR); })
+ { SetResourceExplicit(ent, RES_ARMOR, ReadByte() * DEC_FACTOR); })
#undef DEC_FACTOR
ENTCS_PROP(NAME, true, netname, ENTCS_SET_MUTABLE_STRING,
WriteShort(chan, sf);
FOREACH(EntCSProps, sf & BIT(it.m_id),
{
- it.m_set(this, player);
it.m_send(chan, this);
});
return true;
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),
{
+ it.m_set(this, player);
this.SendFlags |= BIT(it.m_id);
});
setorigin(this, this.origin); // relink
setthink(e, entcs_think);
e.nextthink = time;
Net_LinkEntity(e, false, 0, entcs_send);
+ if (!IS_REAL_CLIENT(player)) return;
+ FOREACH_CLIENT(true, {
+ assert(CS(it).entcs);
+ _entcs_send(CS(it).entcs, msg_entity = player, BITS(23), MSG_ONE);
+ });
}
void entcs_detach(entity player)