]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
add a simple generic CSQC model wrapper
authorRudolf Polzer <divverent@xonotic.org>
Sat, 12 Nov 2011 16:18:47 +0000 (17:18 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 12 Nov 2011 16:20:53 +0000 (17:20 +0100)
qcsrc/server/csqcmodel.qc [new file with mode: 0644]
qcsrc/server/csqcmodel.qh [new file with mode: 0644]
qcsrc/server/progs.src

diff --git a/qcsrc/server/csqcmodel.qc b/qcsrc/server/csqcmodel.qc
new file mode 100644 (file)
index 0000000..793264f
--- /dev/null
@@ -0,0 +1,100 @@
+// generic CSQC model code
+
+#define ALLPROPERTIES \
+       PROPERTY(1, ReadCoord, WriteCoord, origin_x) \
+       PROPERTY(1, ReadCoord, WriteCoord, origin_y) \
+       PROPERTY(1, ReadCoord, WriteCoord, origin_z) \
+       PROPERTY(2, ReadAngle, WriteAngle, angles_x) \
+       PROPERTY(2, ReadAngle, WriteAngle, angles_y) \
+       PROPERTY(2, ReadAngle, WriteAngle, angles_z) \
+       PROPERTY(4, ReadShort, WriteShort, modelindex) \
+       PROPERTY(8, ReadByte, WriteByte, frame) \
+       PROPERTY(16, ReadByte, WriteByte, skin) \
+       PROPERTY(32, ReadInt24_t, WriteInt24_t, effects) \
+       PROPERTY_SCALED(64, ReadByte, WriteByte, alpha, 255, 0, 255) \
+       /* no attachment support */ \
+       /* no rtlight support */ \
+       /* no glow support */ \
+       /* no colormod support */ \
+       PROPERTY_SCALED(128, ReadByte, WriteByte, glowmod_x, 32, 0, 255) \
+       PROPERTY_SCALED(128, ReadByte, WriteByte, glowmod_y, 32, 0, 255) \
+       PROPERTY_SCALED(128, ReadByte, WriteByte, glowmod_z, 32, 0, 255)
+
+#ifdef SVQC
+
+#define PROPERTY(flag,r,w,f) \
+       .float csqcmodel_##f;
+#define PROPERTY_SCALED(flag,r,w,f,s,mi,ma) PROPERTY(flag,r,w,f)
+       ALLPROPERTIES
+#undef PROPERTY_SCALED
+#undef PROPERTY
+
+float CSQCModel_Send(entity to, float sf)
+{
+       WriteByte(MSG_ENTITY, ENT_CS_CSQCMODEL);
+       WriteShort(MSG_ENTITY, sf);
+
+#define PROPERTY(flag,r,w,f) \
+       if(sf & flag) \
+       { \
+               w(MSG_ENTITY, self.csqcmodel_##f); \
+       }
+#define PROPERTY_SCALED(flag,r,w,f,s,mi,ma) PROPERTY(flag,r,w,f)
+       ALLPROPERTIES
+#undef PROPERTY_SCALED
+#undef PROPERTY
+
+       return TRUE;
+}
+
+void CSQCModel_CheckUpdate()
+{
+       float tmp;
+#define PROPERTY(flag,r,w,f) \
+       tmp = self.f; \
+       if(tmp != self.csqcmodel_##f) \
+       { \
+               self.csqcmodel_##f = tmp; \
+               self.SendFlags |= flag; \
+       }
+#define PROPERTY_SCALED(flag,r,w,f,s,mi,ma) \
+       tmp = bound(mi, s * self.f, ma); \
+       if(tmp != self.csqcmodel_##f) \
+       { \
+               self.csqcmodel_##f = tmp; \
+               self.SendFlags |= flag; \
+       }
+       ALLPROPERTIES
+#undef PROPERTY_SCALED
+#undef PROPERTY
+}
+
+void CSQCModel_LinkEntity()
+{
+       Net_LinkEntity(self, TRUE, 0, CSQCModel_Send);
+}
+
+#endif
+
+#ifdef CSQC
+
+void CSQCModel_Read()
+{
+       float sf;
+       sf = ReadShort();
+
+#define PROPERTY(flag,r,w,f) \
+       if(sf & flag) \
+               self.f = r();
+#define PROPERTY_SCALED(flag,r,w,f,s,mi,ma) \
+       if(sf & flag) \
+               self.f = r() / s;
+       ALLPROPERTIES
+#undef PROPERTY_SCALED
+#undef PROPERTY
+       
+       // interpolation
+       // draw it
+}
+
+#endif
diff --git a/qcsrc/server/csqcmodel.qh b/qcsrc/server/csqcmodel.qh
new file mode 100644 (file)
index 0000000..e8387a2
--- /dev/null
@@ -0,0 +1,10 @@
+// generic CSQC model code
+
+#ifdef SVQC
+void CSQCModel_CheckUpdate();
+void CSQCModel_LinkEntity();
+#endif
+
+#ifdef CSQC
+void CSQCModel_Read();
+#endif
index c29ac5ff965380bd8dde021b95856a8eef9a385d..f3bcc06850eaf8ffac6dc76eddbf0f28323e2b12 100644 (file)
@@ -40,6 +40,7 @@ campaign.qh
 
 accuracy.qh
 csqcprojectile.qh
+csqcmodel.qh
 csqceffects.qc
 
 anticheat.qh
@@ -178,6 +179,7 @@ target_music.qc
 
 
 accuracy.qc
+csqcmodel.qc
 csqcprojectile.qc
 
 playerdemo.qc