]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make a common function for getting the player's gun alignment
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 22:20:49 +0000 (08:20 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 22:20:49 +0000 (08:20 +1000)
qcsrc/client/hook.qc
qcsrc/common/weapons/calculations.qc
qcsrc/common/weapons/calculations.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/server/g_hook.qc

index 3f623b276ed068bb3baeb4582680b37c495b0ea7..5b8d09312049202197e379e5cb616b504fb8892b 100644 (file)
@@ -31,7 +31,6 @@ void Draw_GrapplingHook(entity this)
        string tex;
        vector rgb;
        float t;
-       int s;
        vector vs;
        float intensity, offset;
 
@@ -44,10 +43,8 @@ void Draw_GrapplingHook(entity this)
 
        InterpolateOrigin_Do();
 
-       s = autocvar_cl_gunalign;
-       if(s != 1 && s != 2 && s != 4)
-               s = 3; // default value
-       --s;
+       int s = W_GetGunAlignment(world);
+
        switch(self.HookType)
        {
                default:
index 16b507d14eee683e65c13e28a42399efdd48054f..dcb7bbb0c1f6daf9ce82de1b97a260684691f0b1 100644 (file)
@@ -142,6 +142,20 @@ vector findperpendicular(vector v)
        return normalize(cliptoplane(p, v));
 }
 
+int W_GetGunAlignment(entity player)
+{
+#ifdef SVQC
+       int gunalign = player.cvar_cl_gunalign;
+#else
+       int gunalign = autocvar_cl_gunalign;
+#endif
+       if(gunalign != 1 && gunalign != 2 && gunalign != 4)
+               gunalign = 3; // default value
+       --gunalign;
+
+       return gunalign;
+}
+
 vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float spreadstyle)
 {
        float sigma;
index d91d22c67c2c0491c9da5bad2b5d2d09ad034aae..4feed9fc549e16a48d44c204435f4a83e21672d7 100644 (file)
@@ -2,4 +2,5 @@
 #define CALCULATIONS_H
 vector damage_explosion_calcpush(vector explosion_f, vector target_v, float speedfactor);
 vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float spreadstyle);
+int W_GetGunAlignment(entity player);
 #endif
index 99eb17d031b89453a0d2da13ec56fd7fedb83702..8d8f4c43b47737354e23fe19c897d6916c75cedb 100644 (file)
@@ -1156,11 +1156,7 @@ void Ent_ReadArcBeam(float isnew)
 
        if(isnew)
        {
-               // calculate shot origin offset from gun alignment
-               int gunalign = autocvar_cl_gunalign;
-               if(gunalign != 1 && gunalign != 2 && gunalign != 4)
-                       gunalign = 3; // default value
-               --gunalign;
+               int gunalign = W_GetGunAlignment(world);
 
                self.beam_shotorigin = arc_shotorigin[gunalign];
 
index 7a77d4aff695a0a1fbfdb50ef10a838223c6d77c..f95115a2ca465a8f8fbe01679da18eed973229a6 100644 (file)
@@ -151,10 +151,7 @@ void GrapplingHookThink()
 
        self.nextthink = time;
 
-       int s = self.realowner.cvar_cl_gunalign;
-       if(s != 1 && s != 2 && s != 4)
-               s = 3; // default value
-       --s;
+       int s = W_GetGunAlignment(self.realowner);
        vs = hook_shotorigin[s];
 
        makevectors(self.realowner.v_angle);
@@ -353,10 +350,7 @@ void FireGrapplingHook (void)
 
        makevectors(self.v_angle);
 
-       int s = self.cvar_cl_gunalign;
-       if(s != 1 && s != 2 && s != 4)
-               s = 3; // default value
-       --s;
+       int s = W_GetGunAlignment(self);
        vs = hook_shotorigin[s];
 
        // UGLY WORKAROUND: play this on CH_WEAPON_B so it can't cut off fire sounds