]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
move the exterior weapon entity to csqcmodel (preparation for forcemodels)
authorRudolf Polzer <divverent@alientrap.org>
Fri, 2 Dec 2011 09:46:12 +0000 (10:46 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 2 Dec 2011 09:46:12 +0000 (10:46 +0100)
qcsrc/csqcmodel/settings.qh
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_weaponsystem.qc

index 4147329242bf937335e66043b97fe69a096ad0c5..54023873307689af87dc1d450812726c92dc7491 100644 (file)
 //vector PL_CROUCH_MIN  = ...;
 //vector PL_CROUCH_MAX  = ...;
 //vector PL_CROUCH_VIEW_OFS  = ...;
+
+#ifdef SVQC
+# ifdef NO_LEGACY_NETWORKING
+#  define CSQCMODEL_AUTOINIT() CSQCModel_LinkEntity()
+#  define CSQCMODEL_AUTOUPDATE() CSQCModel_CheckUpdate()
+# else
+.float iscsqcmodel;
+float autocvar_sv_use_csqc_players;
+#  define CSQCMODEL_AUTOINIT() \
+       if(autocvar_sv_use_csqc_players) \
+       { \
+               CSQCModel_LinkEntity(); \
+               self.iscsqcmodel = 1; \
+       }
+#  define CSQCMODEL_AUTOUPDATE() \
+       if(autocvar_sv_use_csqc_players && !self.iscsqcmodel) \
+       { \
+               CSQCModel_LinkEntity(); \
+               self.iscsqcmodel = 1; \
+       } \
+       if(!autocvar_sv_use_csqc_players && self.iscsqcmodel) \
+       { \
+               CSQCModel_UnlinkEntity(); \
+               self.iscsqcmodel = 0; \
+       } \
+       if(self.iscsqcmodel) \
+               CSQCModel_CheckUpdate();
+# endif
+#endif
index c3e267cceebf390ad1a4346adb3af3ec8d679086..7f006745efa7ba48ea86f6bf161b9a683ca35933 100644 (file)
@@ -1194,6 +1194,3 @@ float autocvar_sv_gameplayfix_gravityunaffectedbyticrate;
 float autocvar_g_trueaim_minrange;
 float autocvar_g_debug_defaultsounds;
 float autocvar_g_loituma;
-#ifndef NO_LEGACY_NETWORKING
-float autocvar_sv_use_csqc_players;
-#endif
index 2386c3ca9b407a04ac21c6e7c7c6448d8b726b39..65b30b1d643da3978e4c261a596481e5f1bee8b4 100644 (file)
@@ -1424,10 +1424,6 @@ float PlayerInIDList(entity p, string idlist)
        return 0;
 }
 
-#ifndef NO_LEGACY_NETWORKING
-.float iscsqcmodel;
-#endif
-
 /*
 =============
 ClientConnect
@@ -1687,15 +1683,7 @@ void ClientConnect (void)
        if(!autocvar_g_campaign)
                Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), autocvar_welcome_message_time, 0);
 
-#ifndef NO_LEGACY_NETWORKING
-       if(autocvar_sv_use_csqc_players)
-       {
-               CSQCModel_LinkEntity();
-               self.iscsqcmodel = 1;
-       }
-#else
-       CSQCModel_LinkEntity();
-#endif
+       CSQCMODEL_AUTOINIT();
 
        self.model_randomizer = random();
 }
@@ -3150,22 +3138,5 @@ void PlayerPostThink (void)
                dprint(sprintf("%f %.6f\n", time, race_GetFractionalLapCount(self)));
        */
 
-#ifndef NO_LEGACY_NETWORKING
-       if(autocvar_sv_use_csqc_players && !self.iscsqcmodel)
-       {
-               CSQCModel_LinkEntity();
-               self.iscsqcmodel = 1;
-       }
-
-       if(!autocvar_sv_use_csqc_players && self.iscsqcmodel)
-       {
-               CSQCModel_UnlinkEntity();
-               self.iscsqcmodel = 0;
-       }
-
-       if(self.iscsqcmodel)
-               CSQCModel_CheckUpdate();
-#else
-       CSQCModel_CheckUpdate();
-#endif
+       CSQCMODEL_AUTOUPDATE();
 }
index 4acb8da891fa4fa4158b5ef01b7026a176cced5e..ae275ac679b6786a094f380577d602ea1d37388a 100644 (file)
@@ -681,6 +681,8 @@ void CL_ExteriorWeaponentity_Think()
 
        self.glowmod = self.owner.weaponentity_glowmod;
        self.colormap = self.owner.colormap;
+
+       CSQCMODEL_AUTOUPDATE();
 }
 
 // spawning weaponentity for client
@@ -708,6 +710,13 @@ void CL_SpawnWeaponentity()
        self.exteriorweaponentity.angles = '0 0 0';
        self.exteriorweaponentity.think = CL_ExteriorWeaponentity_Think;
        self.exteriorweaponentity.nextthink = time;
+
+       {
+               entity oldself = self;
+               self = self.exteriorweaponentity;
+               CSQCMODEL_AUTOINIT();
+               self = oldself;
+       }
 }
 
 void Send_WeaponComplain (entity e, float wpn, string wpnname, float type)