5 .int Version; // deprecated, use SendFlags
7 .bool(entity to, int sendflags)SendEntity;
8 .bool(entity this, entity to, int sendflags)SendEntity3;
10 bool SendEntity_self(entity to, int sendflags) { return self.SendEntity3(self, to, sendflags); }
12 void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags)sendfunc)
14 if (e.classname == "") e.classname = "net_linked";
16 if (e.model == "" || self.modelindex == 0)
24 e.SendEntity = SendEntity_self;
25 e.SendEntity3 = sendfunc;
26 e.SendFlags = 0xFFFFFF;
28 if (!docull) e.effects |= EF_NODEPTHTEST;
32 e.nextthink = time + dt;
37 .void() uncustomizeentityforclient;
38 .float uncustomizeentityforclient_set;
40 void SetCustomizer(entity e, float(void)customizer, void(void)uncustomizer)
42 e.customizeentityforclient = customizer;
43 e.uncustomizeentityforclient = uncustomizer;
44 e.uncustomizeentityforclient_set = !!uncustomizer;
47 void UncustomizeEntitiesRun()
49 for (entity e = NULL; (e = findfloat(e, uncustomizeentityforclient_set, 1)); )
50 WITH(entity, self, e, e.uncustomizeentityforclient());
55 #include "registry.qh"
60 .void(entity this, bool isNew)m_read;
63 #define Net_Accept() \
66 if (!this) this = spawn(); \
69 #define Net_Reject() \
72 if (this) remove(this); \
76 #define WriteHeader(to, id) \
79 if (NET_##id##_istemp) WriteByte(to, SVC_TEMPENTITY); \
80 WriteByte(to, NET_##id.m_id); \
86 #define REGISTER_NET_LINKED(id, param) \
87 void Ent_Read##id(entity this, param) \
91 REGISTER(RegisterLinkedEntities, NET, LinkedEntities, id, m_id, spawn()) \
94 this.m_read = Ent_Read##id; \
96 [[accumulate]] void Ent_Read##id(entity this, param)
98 #define REGISTER_NET_LINKED(id, param) \
99 const bool NET_##id##_istemp = false; \
100 REGISTER(RegisterLinkedEntities, NET, LinkedEntities, id, m_id, spawn()) \
102 this.netname = #id; \
106 REGISTRY(LinkedEntities, BIT(0))
107 REGISTER_REGISTRY(RegisterLinkedEntities)
108 REGISTRY_SORT(LinkedEntities, netname, 0)
109 STATIC_INIT(RegisterLinkedEntities_renumber)
111 for (int i = 0; i < LinkedEntities_COUNT; ++i)
112 LinkedEntities[i].m_id = 100 + i;
116 #define REGISTER_NET_TEMP(id, param) \
117 void Net_Read##id(entity this, param); \
118 REGISTER(RegisterTempEntities, NET, TempEntities, id, m_id, spawn()) \
120 this.netname = #id; \
121 this.m_read = Net_Read##id; \
123 void Net_Read##id(entity this, param)
125 #define REGISTER_NET_TEMP(id, param) \
126 const bool NET_##id##_istemp = true; \
127 REGISTER(RegisterTempEntities, NET, TempEntities, id, m_id, spawn()) \
129 this.netname = #id; \
133 REGISTRY(TempEntities, BITS(3))
134 REGISTER_REGISTRY(RegisterTempEntities)
135 REGISTRY_SORT(TempEntities, netname, 0)
136 STATIC_INIT(RegisterTempEntities_renumber)
138 for (int i = 0; i < TempEntities_COUNT; ++i)
139 TempEntities[i].m_id = 115 + i;
146 int v = ReadShort() << 8; // note: this is signed
147 v += ReadByte(); // note: this is unsigned
167 void WriteInt24_t(float dst, float val)
170 WriteShort(dst, (v = floor(val >> 8)));
171 WriteByte(dst, val - (v << 8)); // 0..255
173 void WriteInt48_t(float dst, vector val)
175 WriteInt24_t(dst, val.x);
176 WriteInt24_t(dst, val.y);
178 void WriteInt72_t(float dst, vector val)
180 WriteInt24_t(dst, val.x);
181 WriteInt24_t(dst, val.y);
182 WriteInt24_t(dst, val.z);