]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/net.qh
Purge other from customizeentityforclient
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / net.qh
index 507807919ac9d6bbf0425b1dd03ea4f1b3c691d8..0ce157848e2ad6d1a411664016eb1644d99db88f 100644 (file)
@@ -97,9 +97,6 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
 
        .int Version;  // deprecated, use SendFlags
        .int SendFlags;
-       .bool(entity to, int sendflags) SendEntity;
-       /** return false to remove from the client */
-       .bool(entity this, entity to, int sendflags) SendEntity3;
 
        void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
        {
@@ -127,13 +124,13 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
 
        void Net_UnlinkEntity(entity e)
        {
-               e.SendEntity = func_null;
+               setSendEntity(e, func_null);
        }
 
        .void(entity this) uncustomizeentityforclient;
        .float uncustomizeentityforclient_set;
 
-       void SetCustomizer(entity e, bool(entity this) customizer, void(entity this) uncustomizer)
+       void SetCustomizer(entity e, bool(entity this, entity client) customizer, void(entity this) uncustomizer)
        {
                setcefc(e, customizer);
                e.uncustomizeentityforclient = uncustomizer;
@@ -206,6 +203,54 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
                } MACRO_END
 #endif
 
+// serialization: new style
+
+USING(Stream, int);
+#if defined(SVQC)
+       #define stream_reading(stream) false
+       #define stream_writing(stream) true
+#elif defined(CSQC)
+       #define stream_reading(stream) true
+       #define stream_writing(stream) false
+#endif
+
+#define serialize(T, stream, ...) serialize_##T(stream, __VA_ARGS__)
+
+#if defined(SVQC)
+       #define serialize_byte(stream, this) \
+               MACRO_BEGIN \
+               WriteByte(stream, this); \
+               MACRO_END
+#elif defined(CSQC)
+       #define serialize_byte(stream, this) \
+               MACRO_BEGIN \
+               this = ReadByte(); \
+               MACRO_END
+#endif
+
+#if defined(SVQC)
+       #define serialize_float(stream, this) \
+               MACRO_BEGIN \
+               WriteCoord(stream, this); \
+               MACRO_END
+#elif defined(CSQC)
+       #define serialize_float(stream, this) \
+               MACRO_BEGIN \
+               this = ReadCoord(); \
+               MACRO_END
+#endif
+
+#define serialize_vector(stream, this) \
+    MACRO_BEGIN \
+    vector _v = this; \
+    serialize_float(stream, _v.x); \
+    serialize_float(stream, _v.y); \
+    serialize_float(stream, _v.z); \
+    this = _v; \
+    MACRO_END
+
+// serialization: old
+
 #define ReadRegistered(r) r##_from(Read_byte())
 #define WriteRegistered(r, to, it) Write_byte(to, it.m_id)