From c27a8af0034e6b4576056c2b08a120e22f597873 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Oct 2015 08:55:14 +1000 Subject: [PATCH] Clean up shotorg code a bit --- qcsrc/server/miscfunctions.qc | 73 ---------------------------- qcsrc/server/miscfunctions.qh | 4 -- qcsrc/server/weapons/weaponsystem.qc | 47 +++++++++++++++--- qcsrc/server/weapons/weaponsystem.qh | 4 ++ 4 files changed, 45 insertions(+), 83 deletions(-) diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 74eb09f5e..cbf296f84 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1521,79 +1521,6 @@ void write_recordmarker(entity pl, float tstart, float dt) " ", ftos(tstart), " ", ftos(dt), "\n")); } -vector shotorg_adjustfromclient(vector vecs, float y_is_right, float allowcenter, float algn) -{ - switch(algn) - { - default: - case 3: // right - break; - - case 4: // left - vecs.y = -vecs.y; - break; - - case 1: - if(allowcenter) // 2: allow center handedness - { - // center - vecs.y = 0; - vecs.z -= 2; - } - else - { - // right - } - break; - - case 2: - if(allowcenter) // 2: allow center handedness - { - // center - vecs.y = 0; - vecs.z -= 2; - } - else - { - // left - vecs.y = -vecs.y; - } - break; - } - return vecs; -} - -vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float algn) -{ - string s; - - if(visual) - vecs = shotorg_adjustfromclient(vecs, y_is_right, true, algn); - else if(autocvar_g_shootfromeye) - vecs.y = vecs.z = 0; - else if(autocvar_g_shootfromcenter) - { - vecs.y = 0; - vecs.z -= 2; - } - else if((s = autocvar_g_shootfromfixedorigin) != "") - { - vector v = stov(s); - if(y_is_right) { v.y = -v.y; } - if(v.x != 0) { vecs.x = v.x; } - vecs.y = v.y; - vecs.z = v.z; - } - - return vecs; -} - -vector shotorg_adjust(vector vecs, float y_is_right, float visual) -{SELFPARAM(); - return shotorg_adjust_values(vecs, y_is_right, visual, self.owner.cvar_cl_gunalign); -} - - void attach_sameorigin(entity e, entity to, string tag) { vector org, t_forward, t_left, t_up, e_forward, e_up; diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index ca8c41e9b..3d1c59dfd 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -65,8 +65,6 @@ void stopsoundto(float _dest, entity e, float chan); void soundtoat(float _dest, entity e, vector o, float chan, string samp, float vol, float _atten); float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d); -vector shotorg_adjust(vector vecs, float y_is_right, float visual); - float DistributeEvenly_amount; float DistributeEvenly_totalweight; void objerror(string s); @@ -119,8 +117,6 @@ void remove_unsafely(entity e); void SetMovetypeFollow(entity ent, entity e); -vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float algn); - void soundto(float dest, entity e, float chan, string samp, float vol, float atten); void stopsound(entity e, float chan); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index dd7e2b599..75a18e4f8 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -14,14 +14,49 @@ #include "../../common/weapons/all.qh" #include "../../lib/csqcmodel/sv_model.qh" -/* -=========================================================================== +vector shotorg_adjustfromclient(vector vecs, float y_is_right, float algn) +{ + switch(algn) + { + default: case 3: break; // right alignment + case 4: vecs.y = -vecs.y; break; // left + case 1: case 2: vecs.y = 0; vecs.z -= 2; break; // center + } + + return vecs; +} + +vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float algn) +{ + string s; - CLIENT WEAPONSYSTEM CODE - Bring back W_Weaponframe + if(visual) + vecs = shotorg_adjustfromclient(vecs, y_is_right, algn); + else if(autocvar_g_shootfromeye) + vecs.y = vecs.z = 0; + else if(autocvar_g_shootfromcenter) + { + vecs.y = 0; + vecs.z -= 2; + } + else if((s = autocvar_g_shootfromfixedorigin) != "") + { + vector v = stov(s); + if(y_is_right) { v.y = -v.y; } + if(v.x != 0) { vecs.x = v.x; } + vecs.y = v.y; + vecs.z = v.z; + } + else // just do the same as top + vecs = shotorg_adjustfromclient(vecs, y_is_right, algn); -=========================================================================== -*/ + return vecs; +} + +vector shotorg_adjust(vector vecs, float y_is_right, float visual) +{SELFPARAM(); + return shotorg_adjust_values(vecs, y_is_right, visual, self.owner.cvar_cl_gunalign); +} .int state; diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index e1fc0922d..be64958c3 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -14,6 +14,10 @@ const float WFRAME_FIRE2 = 1; const float WFRAME_IDLE = 2; const float WFRAME_RELOAD = 3; +vector shotorg_adjust(vector vecs, float y_is_right, float visual); + +vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float algn); + void CL_SpawnWeaponentity(entity e); vector CL_Weapon_GetShotOrg(float wpn); -- 2.39.2