]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into divVerent/csqcmodel
authorRudolf Polzer <divverent@xonotic.org>
Mon, 14 Nov 2011 05:44:06 +0000 (06:44 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Mon, 14 Nov 2011 05:44:06 +0000 (06:44 +0100)
14 files changed:
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/progs.src
qcsrc/common/constants.qh
qcsrc/csqcmodel/cl_model.qc [new file with mode: 0644]
qcsrc/csqcmodel/cl_model.qh [new file with mode: 0644]
qcsrc/csqcmodel/cl_player.qc [new file with mode: 0644]
qcsrc/csqcmodel/cl_player.qh [new file with mode: 0644]
qcsrc/csqcmodel/common.qc [new file with mode: 0644]
qcsrc/csqcmodel/settings.qh [new file with mode: 0644]
qcsrc/csqcmodel/sv_model.qc [new file with mode: 0644]
qcsrc/csqcmodel/sv_model.qh [new file with mode: 0644]
qcsrc/server/cl_client.qc
qcsrc/server/progs.src

index 326bae22b5118a7be4a9566ae83dda022167560a..51d1694cb3a5990e1e29e1f3bbe6fe71b707cf67 100644 (file)
@@ -1008,6 +1008,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
                case ENT_CLIENT_TURRET: ent_turret(); break; 
+               case ENT_CLIENT_MODEL: CSQCModel_Read(); break; 
                default:
                        //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
index 2d79f8f1045b4c181694d9e76f946e546680eb8f..c0123c87f721d93559a2409820a802173b996872 100644 (file)
@@ -398,6 +398,8 @@ void CSQC_UpdateView(float w, float h)
 
        WaypointSprite_Load();
 
+       CSQCPlayer_SetCamera();
+
        if(spectatee_status)
                myteam = GetPlayerColor(spectatee_status - 1);
        else
index f650d04bda64703050ecd00610833db629dd7dcc..f769f4ea23e7e4df1e825effeffe0c49ba37341d 100644 (file)
@@ -35,6 +35,9 @@ tturrets.qh
 ../server/movelib.qc
 main.qh
 vehicles/vehicles.qh
+../csqcmodel/settings.qh
+../csqcmodel/cl_model.qh
+../csqcmodel/cl_player.qh
 
 sortlist.qc
 miscfunctions.qc
@@ -56,6 +59,9 @@ projectile.qc
 gibs.qc
 damage.qc
 casings.qc
+../csqcmodel/common.qc
+../csqcmodel/cl_model.qc
+../csqcmodel/cl_player.qc
 effects.qc
 wall.qc
 modeleffects.qc
index 0f22893075e36ddab30f9ae380fab7597e9a930c..02530c2da34ba0f003abd2ae8137c51d3ce90e2a 100644 (file)
@@ -114,6 +114,7 @@ const float ENT_CLIENT_GAUNTLET = 29;
 const float ENT_CLIENT_ACCURACY = 30;
 const float ENT_CLIENT_SHOWNAMES = 31;
 const float ENT_CLIENT_WARPZONE_TELEPORTED = 32;
+const float ENT_CLIENT_MODEL = 33;
 
 const float ENT_CLIENT_TURRET = 40;
 const float ENT_CLIENT_AUXILIARYXHAIR = 50;
diff --git a/qcsrc/csqcmodel/cl_model.qc b/qcsrc/csqcmodel/cl_model.qc
new file mode 100644 (file)
index 0000000..b163e6d
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+// generic CSQC model code
+
+var float autocvar_cl_lerpanim_maxdelta_framegroups = 0.1;
+var float autocvar_cl_nolerp = 0;
+
+.float csqcmodel_lerpfrac;
+.float csqcmodel_lerpfrac2;
+.float csqcmodel_lerpfractime;
+.float csqcmodel_lerpfrac2time;
+
+void CSQCModel_InterpolateAnimation_PreNote(float sf)
+{
+#ifdef CSQCMODELS_HAVE_TWO_FRAMES
+       if(sf & PROPERTY_FRAME)
+       {
+               self.frame3 = self.frame;
+               self.frame3time = self.frame1time;
+       }
+       if(sf & PROPERTY_FRAME2)
+       {
+               self.frame4 = self.frame2;
+               self.frame4time = self.frame2time;
+       }
+       if(sf & PROPERTY_LERPFRAC)
+       {
+               self.csqcmodel_lerpfrac2 = self.csqcmodel_lerpfrac;
+               self.csqcmodel_lerpfrac2time = self.csqcmodel_lerpfractime;
+               self.lerpfrac = self.csqcmodel_lerpfrac;
+       }
+#else
+       if(sf & PROPERTY_FRAME)
+       {
+               self.frame2 = self.frame;
+               self.frame2time = self.frame1time;
+       }
+#endif
+}
+
+void CSQCModel_InterpolateAnimation_Note(float sf)
+{
+#ifdef CSQCMODELS_HAVE_TWO_FRAMES
+       if(sf & PROPERTY_FRAME)
+       {
+               self.frame1time = time;
+       }
+       if(sf & PROPERTY_FRAME2)
+       {
+               self.frame2time = time;
+       }
+       if(sf & PROPERTY_LERPFRAC)
+       {
+               self.csqcmodel_lerpfrac = self.lerpfrac;
+               self.csqcmodel_lerpfractime = time;
+       }
+#else
+       if(sf & PROPERTY_FRAME)
+       {
+               self.frame1time = time;
+       }
+#endif
+}
+
+void CSQCModel_InterpolateAnimation_Do()
+{
+#ifdef CSQCMODELS_HAVE_TWO_FRAMES
+       if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
+       {
+               self.lerpfrac = self.csqcmodel_lerpfrac;
+               self.lerpfrac3 = 0;
+               self.lerpfrac4 = 0;
+       }
+       else
+       {
+               float l13, l24, llf;
+               float l24_13;
+
+               if(self.frame3time == 0) // if frame1/3 were not previously displayed, only frame1 can make sense
+                       l13 = 1;
+               else
+                       l13 = bound(0, (time - self.frame1time) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+
+               if(self.frame4time == 0) // if frame2/4 were not previously displayed, only frame2 can make sense
+                       l24 = 1;
+               else
+                       l24 = bound(0, (time - self.frame2time) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+
+               if(self.lerpfrac2time == 0) // if there is no old lerpfrac (newly displayed model), only lerpfrac makes sense
+                       llf = 1;
+               else
+                       llf = bound(0, (time - self.csqcmodel_lerpfractime) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+
+               l24_13 = self.csqcmodel_lerpfrac * llf + self.csqcmodel_lerpfrac2 * (1 - llf);
+
+               self.lerpfrac  = l24 * l24_13;
+               self.lerpfrac4 = (1 - l24) * l24_13;
+               self.lerpfrac3 = (1 - l13) * (1 - l24_13);
+
+               if(l24_13 == 0) // if frames 2/4 are not displayed, clear their frametime
+               {
+                       self.frame2time = 0;
+                       self.frame4time = 0;
+               }
+
+               if(l24_13 == 1) // if frames 1/3 are not displayed, clear their frametime
+               {
+                       self.frametime = 0;
+                       self.frame3time = 0;
+               }
+       }
+#else
+       if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
+       {
+               self.lerpfrac = 0;
+       }
+       else
+       {
+               self.lerpfrac = 1 - bound(0, (time - self.frame1time) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
+       }
+#endif
+}
+
+void CSQCModel_Draw()
+{
+       InterpolateOrigin_Do();
+       // TODO csqcplayers: run prediction here too
+       CSQCModel_InterpolateAnimation_Do();
+}
+
+void CSQCModel_Read()
+{
+       float sf;
+       sf = ReadShort();
+
+       self.iflags |= IFLAG_ANGLES; // interpolate angles too
+
+       CSQCPlayer_PreUpdate();
+       InterpolateOrigin_Undo();
+       CSQCModel_InterpolateAnimation_PreNote(sf);
+
+#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
+       
+       CSQCModel_InterpolateAnimation_Note(sf);
+       InterpolateOrigin_Note();
+       CSQCPlayer_PostUpdate();
+
+#ifdef CSQCMODELS_SUPPORT_GETTAGINFO_BEFORE_DRAW
+       InterpolateOrigin_Do();
+       CSQCModel_InterpolateAnimation_Do();
+#endif
+
+       // draw it
+       self.drawmask = MASK_NORMAL;
+       self.predraw = CSQCModel_Draw;
+}
diff --git a/qcsrc/csqcmodel/cl_model.qh b/qcsrc/csqcmodel/cl_model.qh
new file mode 100644 (file)
index 0000000..e087ee6
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+// generic CSQC model code
+
+void CSQCModel_Read();
diff --git a/qcsrc/csqcmodel/cl_player.qc b/qcsrc/csqcmodel/cl_player.qc
new file mode 100644 (file)
index 0000000..eb1715c
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+var float autocvar_cl_predictionerrorcompensation = 0;
+var float autocvar_cl_movement_replay;
+var float autocvar_chase_active;
+var float autocvar_chase_back;
+
+.float pmove_flags;
+
+entity csqcplayer;
+vector csqcplayer_origin, csqcplayer_velocity;
+float csqcplayer_sequence, player_pmflags;
+float csqcplayer_moveframe;
+vector csqcplayer_predictionerror;
+float csqcplayer_predictionerrortime;
+
+vector CSQCPlayer_GetPredictionError()
+{
+       if(!autocvar_cl_predictionerrorcompensation)
+               return '0 0 0';
+       if(time < csqcplayer_predictionerrortime)
+               return csqcplayer_predictionerror * (csqcplayer_predictionerrortime - time) * autocvar_cl_predictionerrorcompensation;
+       return '0 0 0';
+}
+
+void CSQCPlayer_SetPredictionError(vector v)
+{
+       if(!autocvar_cl_predictionerrorcompensation)
+               return;
+       csqcplayer_predictionerror = (csqcplayer_predictionerrortime - time) * autocvar_cl_predictionerrorcompensation * csqcplayer_predictionerror + v;
+       csqcplayer_predictionerrortime = time + 1.0 / autocvar_cl_predictionerrorcompensation;
+}
+
+void CSQCPlayer_Unpredict()
+{
+       if(csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED)
+               return;
+       if(csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED)
+               error("Cannot unpredict in current status");
+       self.origin = csqcplayer_origin;
+       self.velocity = csqcplayer_velocity;
+       csqcplayer_moveframe = csqcplayer_sequence+1; //+1 because the recieved frame has the move already done (server side)
+       self.pmove_flags = player_pmflags;
+}
+
+void CSQCPlayer_SavePrediction()
+{
+       player_pmflags = self.pmove_flags;
+       csqcplayer_origin = self.origin;
+       csqcplayer_velocity = self.velocity;
+       csqcplayer_sequence = servercommandframe;
+       csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
+}
+
+void CSQCPlayer_PredictTo(float endframe)
+{
+       CSQCPlayer_Unpredict();
+
+       csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
+
+       if (getstatf(STAT_HEALTH) <= 0)
+       {
+               csqcplayer_moveframe = clientcommandframe;
+               getinputstate(csqcplayer_moveframe-1);
+               return;
+       }
+
+       while(csqcplayer_moveframe < endframe)
+       {
+               if (!getinputstate(csqcplayer_moveframe))
+               {
+                       break;
+               }
+               runstandardplayerphysics(self);
+
+               csqcplayer_moveframe++;
+       }
+
+       //add in anything that was applied after (for low packet rate protocols)
+       input_angles = view_angles;
+}
+
+void CSQCPlayer_SetCamera()
+{
+       if(csqcplayer)
+       {
+               vector org, ang;
+               entity oldself;
+               oldself = self;
+               self = csqcplayer;
+
+               if(servercommandframe == 0)
+               {
+                       InterpolateOrigin_Do();
+               }
+               else
+               {
+                       if(csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER)
+                       {
+                               vector o, v;
+                               o = self.origin;
+                               v = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
+                               csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
+                               CSQCPlayer_PredictTo(servercommandframe + 1);
+                               CSQCPlayer_SetPredictionError(o - self.origin);
+                               self.origin = o;
+                               self.velocity = v;
+                               CSQCPlayer_SavePrediction();
+                       }
+                       CSQCPlayer_PredictTo(clientcommandframe);
+               }
+
+               self = oldself;
+
+               org = csqcplayer.origin + csqcplayer.view_ofs + CSQCPlayer_GetPredictionError();
+               ang = R_SetView3fv(VF_ANGLES);
+
+               // simulate missing engine features
+               if(autocvar_chase_active)
+               {
+                       float dist;
+                       vector chase_dest;
+                       dist = -autocvar_chase_back - 8;
+                       makevectors(ang);
+                       chase_dest = org + v_forward * dist;
+                       traceline(org, chase_dest, MOVE_NOMONSTERS, csqcplayer);
+                       org = trace_endpos + 8 * v_forward + 4 * trace_plane_normal;
+               }
+
+               R_SetView3fv(VF_ORIGIN, org);
+               R_SetView3fv(VF_ANGLES, ang);
+       }
+}
+
+float CSQCPlayer_PreUpdate()
+{
+       if(self.entnum != player_localentnum)
+               return 0;
+       cvar_clientsettemp("cl_movement_replay", "0");
+       if(csqcplayer_status != CSQCPLAYERSTATUS_FROMSERVER)
+               CSQCPlayer_Unpredict();
+       return 1;
+}
+
+float CSQCPlayer_PostUpdate()
+{
+       if(self.entnum <= maxclients)
+               self.renderflags |= RF_EXTERNALMODEL;
+       else
+               self.renderflags &~= RF_EXTERNALMODEL;
+       if(self.entnum != player_localentnum)
+               return 0;
+       csqcplayer_status = CSQCPLAYERSTATUS_FROMSERVER;
+       csqcplayer = self;
+       return 1;
+}
diff --git a/qcsrc/csqcmodel/cl_player.qh b/qcsrc/csqcmodel/cl_player.qh
new file mode 100644 (file)
index 0000000..7f7329b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+float csqcplayer_status;
+#define CSQCPLAYERSTATUS_UNPREDICTED 0
+#define CSQCPLAYERSTATUS_FROMSERVER 1
+#define CSQCPLAYERSTATUS_PREDICTED 2
+
+void CSQCPlayer_SetCamera();
+float CSQCPlayer_PreUpdate();
+float CSQCPlayer_PostUpdate();
diff --git a/qcsrc/csqcmodel/common.qc b/qcsrc/csqcmodel/common.qc
new file mode 100644 (file)
index 0000000..5677f9a
--- /dev/null
@@ -0,0 +1,44 @@
+.vector glowmod;
+.vector view_ofs;
+.float frame;
+.float frame1time;
+.float frame2;
+.float frame2time;
+.float lerpfrac;
+
+#define PROPERTY_FRAME 32768
+#define PROPERTY_FRAME2 16384
+#define PROPERTY_LERPFRAC 8192
+
+#define ALLPROPERTIES_COMMON \
+       PROPERTY(PROPERTY_FRAME, ReadByte, WriteByte, frame) \
+       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(16, ReadByte, WriteByte, skin) \
+       PROPERTY(32, ReadInt24_t, WriteInt24_t, effects) \
+       PROPERTY_SCALED(64, ReadByte, WriteByte, alpha, 255, 0, 255) \
+       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) \
+       PROPERTY(256, ReadChar, WriteChar, view_ofs_z) \
+       PROPERTY(512, ReadShort, WriteShort, colormap)
+
+#ifdef CSQCMODELS_HAVE_TWO_FRAMES
+.float frame3;
+.float frame3time;
+.float lerpfrac3;
+.float frame4;
+.float frame4time;
+.float lerpfrac4;
+#define ALLPROPERTIES ALLPROPERTIES_COMMON \
+       PROPERTY(PROPERTY_FRAME2, ReadByte, WriteByte, frame2) \
+       PROPERTY_SCALED(PROPERTY_LERPFRAC, ReadByte, WriteByte, lerpfrac, 255, 0, 255)
+#else
+#define ALLPROPERTIES ALLPROPERTIES_COMMON
+#endif
+
diff --git a/qcsrc/csqcmodel/settings.qh b/qcsrc/csqcmodel/settings.qh
new file mode 100644 (file)
index 0000000..e542bfa
--- /dev/null
@@ -0,0 +1,2 @@
+//#define CSQCMODELS_HAVE_TWO_FRAMES
+//#define CSQCMODELS_SUPPORT_GETTAGINFO_BEFORE_DRAW
diff --git a/qcsrc/csqcmodel/sv_model.qc b/qcsrc/csqcmodel/sv_model.qc
new file mode 100644 (file)
index 0000000..010258b
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+// generic CSQC model code
+
+#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_CLIENT_MODEL);
+       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);
+}
diff --git a/qcsrc/csqcmodel/sv_model.qh b/qcsrc/csqcmodel/sv_model.qh
new file mode 100644 (file)
index 0000000..bb45a74
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2011 Rudolf Polzer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+// generic CSQC model code
+
+void CSQCModel_CheckUpdate();
+void CSQCModel_LinkEntity();
index 7445c6b38b0cf5f2c4f4f43ea47ea3cf11ab1efc..352be72107c837cbb222ee6bfa25d81132a6df36 100644 (file)
@@ -1795,6 +1795,8 @@ void ClientConnect (void)
 
        if(!autocvar_g_campaign)
                Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), autocvar_welcome_message_time, 0);
+
+       CSQCModel_LinkEntity();
 }
 
 /*
@@ -3262,4 +3264,6 @@ void PlayerPostThink (void)
        if(g_race)
                dprint(sprintf("%f %.6f\n", time, race_GetFractionalLapCount(self)));
        */
+
+       CSQCModel_CheckUpdate();
 }
index c29ac5ff965380bd8dde021b95856a8eef9a385d..734ba840b1f2f96dbaebb596102dd19901fdea8c 100644 (file)
@@ -40,6 +40,8 @@ campaign.qh
 
 accuracy.qh
 csqcprojectile.qh
+../csqcmodel/settings.qh
+../csqcmodel/sv_model.qh
 csqceffects.qc
 
 anticheat.qh
@@ -178,6 +180,8 @@ target_music.qc
 
 
 accuracy.qc
+../csqcmodel/common.qc
+../csqcmodel/sv_model.qc
 csqcprojectile.qc
 
 playerdemo.qc