From: terencehill Date: Sat, 16 Mar 2024 16:58:54 +0000 (+0100) Subject: Optimize Arc and Hook initialization. Also get rid of the useless shotorg_adjust... X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=102cf72d9dae4e7691ce09c33cc651bb2ce665ec Optimize Arc and Hook initialization. Also get rid of the useless shotorg_adjust macro and fix some parameter types --- diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 0d0c56858..8425bb810 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -285,7 +285,7 @@ vector shotorg_adjustfromclient(vector vecs, float y_is_right, float algn) return vecs; } -vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn) +vector shotorg_adjust(vector vecs, bool y_is_right, bool visual, int algn) { string s; if (visual) @@ -317,7 +317,6 @@ vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn return vecs; } -#define shotorg_adjust shotorg_adjust_values /** * supported formats: diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 141b8b5ee..50c6e3cb5 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -390,7 +390,7 @@ ENUMCLASS_END(WFRAME) #define G_SHOOTFROMFIXEDORIGIN autocvar_cl_shootfromfixedorigin #endif -vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn); +vector shotorg_adjust(vector vecs, bool y_is_right, bool visual, int algn); void CL_WeaponEntity_SetModel(entity this, string name, bool _anim); REPLICATE_INIT(int, cvar_cl_gunalign); diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 5bacdc35e..981d8d3f0 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -721,10 +721,11 @@ METHOD(Arc, wr_init, void(entity thiswep)) { if(!arc_shotorigin[0]) { - arc_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 1); - arc_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 2); - arc_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 3); - arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 4); + vector vecs = CL_Weapon_GetShotOrg(WEP_ARC.m_id); + arc_shotorigin[0] = shotorg_adjust(vecs, false, false, 1); + arc_shotorigin[1] = shotorg_adjust(vecs, false, false, 2); + arc_shotorigin[2] = shotorg_adjust(vecs, false, false, 3); + arc_shotorigin[3] = shotorg_adjust(vecs, false, false, 4); } } METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) diff --git a/qcsrc/server/hook.qc b/qcsrc/server/hook.qc index a50830348..e734addfa 100644 --- a/qcsrc/server/hook.qc +++ b/qcsrc/server/hook.qc @@ -431,9 +431,10 @@ PRECACHE(GrappleHookInit) { Weapon w = WEP_HOOK; w.wr_init(w); - hook_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 1); - hook_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 2); - hook_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 3); - hook_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK.m_id), false, false, 4); + vector vecs = CL_Weapon_GetShotOrg(WEP_HOOK.m_id); + hook_shotorigin[0] = shotorg_adjust(vecs, false, false, 1); + hook_shotorigin[1] = shotorg_adjust(vecs, false, false, 2); + hook_shotorigin[2] = shotorg_adjust(vecs, false, false, 3); + hook_shotorigin[3] = shotorg_adjust(vecs, false, false, 4); } } diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 20e713c2a..7cfade409 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -833,7 +833,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen this.clip_load = this.(weapon_load[this.m_weapon.m_id]) = -1; } -void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity) +void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, int weapon_type, entity weapon_item, .entity weaponentity) { Weapon w = REGISTRY_GET(Weapons, weapon_type); weapon_dropevent_item = weapon_item; diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index c0e0c221f..b09d91010 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -47,7 +47,7 @@ void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire); void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire); -vector CL_Weapon_GetShotOrg(float wpn); +vector CL_Weapon_GetShotOrg(int wpn); bool weaponUseForbidden(entity player); bool weaponLocked(entity player); @@ -56,7 +56,7 @@ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity); -void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity); +void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, int weapon_type, entity weapon_item, .entity weaponentity); void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound); @@ -70,9 +70,9 @@ float W_WeaponSpeedFactor(entity this); bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime); -bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponentity, float secondary, float attacktime); +bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime); -void weapon_prepareattack_do(entity actor, .entity weaponentity, float secondary, float attacktime); +void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary, float attacktime); void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func);