]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Set gun alignment on the server (hopefully more reliable)
authorMario <mario@smbclan.net>
Mon, 3 Oct 2016 10:19:05 +0000 (20:19 +1000)
committerMario <mario@smbclan.net>
Mon, 3 Oct 2016 10:19:05 +0000 (20:19 +1000)
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/calculations.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/wepent.qc

index 6139d41b494274d9c2fbefd6f5f51eacc9194813..f4a4de7f3fbabc70514310848d551d5cfcab1a92 100644 (file)
@@ -527,7 +527,9 @@ void CL_WeaponEntity_SetModel(entity this, string name, bool _anim)
        {
                //int algn = STAT(GUNALIGN, this.owner);
                int algn = W_GunAlign(this, STAT(GUNALIGN, this.owner));
+       #ifdef SVQC
                this.m_gunalign = algn;
+       #endif
                vector v = this.movedir;
                this.movedir = shotorg_adjust(v, false, false, algn);
                this.view_ofs = shotorg_adjust(v, false, true, algn) - v;
index 071ac4c565a7e1f076674b40ecb8d85a34110816..0e9aae262604fe9e3bc5134b7643f54cec984bda 100644 (file)
@@ -335,8 +335,6 @@ vector weaponentity_glowmod(Weapon wep, entity actor, int c, entity wepent)
 
 #ifdef SVQC
 .entity gunaligns[5];
-#else
-entity gunaligns[5];
 #endif
 
 .int m_gunalign;
index a8587b1ab3167ea24242590a35b714b8ace98fe4..77b6cba260b63b77e28f38c72ec1197cdd781f68 100644 (file)
@@ -170,24 +170,7 @@ vector findperpendicular(vector v)
 #else
        int W_GunAlign(entity this, int preferred_align)
        {
-               // using wasfreed, as we don't actually clear gunaligns yet
-               if(!gunaligns[preferred_align] || wasfreed(gunaligns[preferred_align]) || gunaligns[preferred_align] == this)
-               {
-                       gunaligns[preferred_align] = this;
-                       return preferred_align; // fall back if the good one is already choosable
-               }
-
-               for(int j = 4; j > 0; --j)
-               {
-                       if(!gunaligns[j] || wasfreed(gunaligns[j]) || gunaligns[j] == this)
-                       {
-                               gunaligns[j] = this;
-                               return j;
-                       }
-               }
-
-               gunaligns[preferred_align] = this;
-               return preferred_align; // no other choice
+               return this.m_gunalign > 0 ? this.m_gunalign : preferred_align;
        }
 #endif
 
index 06d784af20a1c66342358bca2bae1ec5496ba8d5..6f8b6691ab11e52d53f4ff9d2a1b76d6349b913c 100644 (file)
@@ -1304,17 +1304,9 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
 
        if(isnew)
        {
-               int gunalign = W_GunAlign(NULL, STAT(GUNALIGN));
+               int gunalign = W_GunAlign(viewmodels[slot], STAT(GUNALIGN));
 
-               this.beam_shotorigin = arc_shotorigin[gunalign]; // quick
-               for(int j = 1; j < 5; ++j)
-               {
-                       if(gunaligns[j] == viewmodels[slot])
-                       {
-                               this.beam_shotorigin = arc_shotorigin[j - 1]; // accurate
-                               break;
-                       }
-               }
+               this.beam_shotorigin = arc_shotorigin[gunalign];
 
                // set other main attributes of the beam
                this.draw = Draw_ArcBeam;
index 0d18908c46d98438f6d0965e9d8031a0bc5d604f..44a9d71f8b428c787fe34fd53b95a589ea56a98d 100644 (file)
@@ -17,6 +17,7 @@ MACRO_END
 //.float w_weapon_nextthink;
 .float w_m_alpha;
 .float w_vortex_charge;
+.int w_m_gunalign;
 
 // #define PROP(public, fld, set, sv, cl)
 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
@@ -39,6 +40,10 @@ MACRO_END
     PROP(false, vortex_charge, WEPENT_SET_NORMAL, \
        { WriteByte(chan, this.vortex_charge * 16); }, \
        { (viewmodels[this.m_wepent_slot]).vortex_charge = ReadByte() / 16; }) \
+    \
+    PROP(false, m_gunalign, WEPENT_SET_NORMAL, \
+       { WriteByte(chan, this.m_gunalign); }, \
+       { (viewmodels[this.m_wepent_slot]).m_gunalign = ReadByte(); }) \
     \
        /**/