#endif
self.enttype = t;
bool done = false;
- FOREACH(Linked, it.m_id == t, LAMBDA(
+ FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
it.m_read(self, bIsNewEntity);
done = true;
break;
// CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
// You must ALWAYS first acquire the temporary ID, which is sent as a byte.
// Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
-float CSQC_Parse_TempEntity()
+bool CSQC_Parse_TempEntity()
{
// Acquire TE ID
int nTEID = ReadByte();
if (autocvar_developer_csqcentities)
LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
+ FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
+ it.m_read(NULL, true);
+ return true;
+ ));
switch (nTEID)
{
case TE_CSQC_MUTATOR:
}
#endif // CSQC
-REGISTER_LINKED(Nade_Heal, bool isNew)
+REGISTER_NET_LINKED(Nade_Heal, bool isNew)
#ifdef CSQC
{
+ Net_Accept();
int sf = ReadByte();
if (sf & 1) {
this.origin_x = ReadCoord();
#endif
#ifdef SVQC
-float healer_send(entity to, int sf)
+bool healer_send(entity to, int sf)
{
SELFPARAM();
- WriteByte(MSG_ENTITY, Linked_Nade_Heal.m_id);
- WriteByte(MSG_ENTITY, sf);
+ int channel = MSG_ENTITY;
+ WriteHeader(channel, Nade_Heal);
+ WriteByte(channel, sf);
if (sf & 1) {
- WriteCoord(MSG_ENTITY, this.origin.x);
- WriteCoord(MSG_ENTITY, this.origin.y);
- WriteCoord(MSG_ENTITY, this.origin.z);
+ WriteCoord(channel, this.origin.x);
+ WriteCoord(channel, this.origin.y);
+ WriteCoord(channel, this.origin.z);
- WriteByte(MSG_ENTITY, this.healer_lifetime);
+ WriteByte(channel, this.healer_lifetime);
//WriteByte(MSG_ENTITY, this.ltime - time + 1);
- WriteShort(MSG_ENTITY, this.healer_radius);
+ WriteShort(channel, this.healer_radius);
// round time delta to a 1/10th of a second
- WriteByte(MSG_ENTITY, (this.ltime - time)*10.0+0.5);
+ WriteByte(channel, (this.ltime - time)*10.0+0.5);
}
return true;
}
#include "registry.qh"
#include "sort.qh"
-REGISTRY(Linked, 24)
-
.string netname;
.int m_id;
.void(entity this, bool isNew) m_read;
#ifdef CSQC
- #define REGISTER_LINKED(id, param) \
+ #define Net_Accept() do { if (!this) this = spawn(); } while (0)
+ #define Net_Reject() do { if (this) remove(this); } while (0)
+#else
+ #define WriteHeader(to, id) do { \
+ if (NET_##id##_istemp) WriteByte(to, SVC_TEMPENTITY); \
+ WriteByte(to, NET_##id.m_id); \
+ } while (0)
+#endif
+
+#ifdef CSQC
+ #define REGISTER_NET_LINKED(id, param) \
void Ent_Read##id(entity this, param) { this = self; } \
- REGISTER(RegisterLinked, Linked, Linked, Linked_COUNT, id, m_id, spawn()) { \
+ REGISTER(RegisterLinkedEntities, NET, LinkedEntities, LinkedEntities_COUNT, id, m_id, spawn()) { \
this.netname = #id; \
this.m_read = Ent_Read##id; \
} \
[[accumulate]] void Ent_Read##id(entity this, param)
#else
- #define REGISTER_LINKED(id, param) \
- REGISTER(RegisterLinked, Linked, Linked, Linked_COUNT, id, m_id, spawn()) { \
+ #define REGISTER_NET_LINKED(id, param) \
+ const bool NET_##id##_istemp = false; \
+ REGISTER(RegisterLinkedEntities, NET, LinkedEntities, LinkedEntities_COUNT, id, m_id, spawn()) { \
+ this.netname = #id; \
+ }
+#endif
+
+REGISTRY(LinkedEntities, 24)
+REGISTER_REGISTRY(RegisterLinkedEntities)
+REGISTRY_SORT(LinkedEntities, netname, 0)
+STATIC_INIT(RegisterLinkedEntities_renumber) {
+ for (int i = 0; i < LinkedEntities_COUNT; ++i) {
+ LinkedEntities[i].m_id = 100 + i;
+ }
+}
+
+#ifdef CSQC
+ #define REGISTER_NET_TEMP(id, param) \
+ void Net_Read##id(entity this, param); \
+ REGISTER(RegisterTempEntities, NET, TempEntities, TempEntities_COUNT, id, m_id, spawn()) { \
+ this.netname = #id; \
+ this.m_read = Net_Read##id; \
+ } \
+ void Net_Read##id(entity this, param)
+#else
+ #define REGISTER_NET_TEMP(id, param) \
+ const bool NET_##id##_istemp = true; \
+ REGISTER(RegisterTempEntities, NET, TempEntities, TempEntities_COUNT, id, m_id, spawn()) { \
this.netname = #id; \
}
#endif
-REGISTER_REGISTRY(RegisterLinked)
-REGISTRY_SORT(Linked, netname, 0)
-STATIC_INIT(RegisterLinked_renumber) {
- for (int i = 0; i < Linked_COUNT; ++i) {
- Linked[i].m_id = 100 + i;
+REGISTRY(TempEntities, 24)
+REGISTER_REGISTRY(RegisterTempEntities)
+REGISTRY_SORT(TempEntities, netname, 0)
+STATIC_INIT(RegisterTempEntities_renumber) {
+ for (int i = 0; i < TempEntities_COUNT; ++i) {
+ TempEntities[i].m_id = 115 + i;
}
}