From f70f1f159c575868eae493d4cd47249041b209ca Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Sun, 30 Jan 2011 22:03:46 +0200 Subject: [PATCH] Commonize even more code, now that its possible --- qcsrc/server/cl_client.qc | 7 +++++++ qcsrc/server/w_crylink.qc | 5 ----- qcsrc/server/w_electro.qc | 3 --- qcsrc/server/w_fireball.qc | 3 --- qcsrc/server/w_grenadelauncher.qc | 5 ----- qcsrc/server/w_hagar.qc | 5 ----- qcsrc/server/w_hlac.qc | 5 ----- qcsrc/server/w_laser.qc | 5 ----- qcsrc/server/w_minelayer.qc | 5 ----- qcsrc/server/w_minstanex.qc | 3 --- qcsrc/server/w_nex.qc | 5 ----- qcsrc/server/w_rocketlauncher.qc | 3 --- qcsrc/server/w_seeker.qc | 5 ----- qcsrc/server/w_shotgun.qc | 5 ----- qcsrc/server/w_sniperrifle.qc | 3 --- qcsrc/server/w_uzi.qc | 5 ----- 16 files changed, 7 insertions(+), 65 deletions(-) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 229e1729c7..fed5100c0a 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1050,8 +1050,15 @@ void PutClientInServer (void) // reset fields the weapons may use for (j = WEP_FIRST; j <= WEP_LAST; ++j) + { weapon_action(j, WR_RESETPLAYER); + // all weapons must be fully loaded when we spawn + entity e; + e = get_weaponinfo(j); + self.weapon_load[j] = cvar(strcat("g_balance_", e.netname, "_reload_ammo")); + } + oldself = self; self = spot; activator = oldself; diff --git a/qcsrc/server/w_crylink.qc b/qcsrc/server/w_crylink.qc index 9d9f32edf3..f3ae7b10e9 100644 --- a/qcsrc/server/w_crylink.qc +++ b/qcsrc/server/w_crylink.qc @@ -666,11 +666,6 @@ float w_crylink(float req) ammo_amount += self.weapon_load[WEP_CRYLINK] >= autocvar_g_balance_crylink_secondary_ammo; return ammo_amount; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_CRYLINK] = autocvar_g_balance_crylink_reload_ammo; - } else if (req == WR_RELOAD) { W_Crylink_Reload(); diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc index d6b555e076..1f802bdd54 100644 --- a/qcsrc/server/w_electro.qc +++ b/qcsrc/server/w_electro.qc @@ -564,9 +564,6 @@ float w_electro(float req) else if (req == WR_RESETPLAYER) { self.electro_secondarytime = time; - - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_ELECTRO] = autocvar_g_balance_electro_reload_ammo; } else if (req == WR_RELOAD) { diff --git a/qcsrc/server/w_fireball.qc b/qcsrc/server/w_fireball.qc index b95a1e2a7a..f079e1c42d 100644 --- a/qcsrc/server/w_fireball.qc +++ b/qcsrc/server/w_fireball.qc @@ -424,9 +424,6 @@ float w_fireball(float req) else if (req == WR_RESETPLAYER) { self.fireball_primarytime = time; - - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_FIREBALL] = autocvar_g_balance_fireball_reload_ammo; } else if (req == WR_RELOAD) { diff --git a/qcsrc/server/w_grenadelauncher.qc b/qcsrc/server/w_grenadelauncher.qc index 0e4e0b852e..d611d70beb 100644 --- a/qcsrc/server/w_grenadelauncher.qc +++ b/qcsrc/server/w_grenadelauncher.qc @@ -393,11 +393,6 @@ float w_glauncher(float req) ammo_amount += self.weapon_load[WEP_GRENADE_LAUNCHER] >= autocvar_g_balance_grenadelauncher_secondary_ammo; return ammo_amount; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_GRENADE_LAUNCHER] = autocvar_g_balance_grenadelauncher_reload_ammo; - } else if (req == WR_RELOAD) { W_GrenadeLauncher_Reload(); diff --git a/qcsrc/server/w_hagar.qc b/qcsrc/server/w_hagar.qc index b27f25aa2b..e51444738e 100644 --- a/qcsrc/server/w_hagar.qc +++ b/qcsrc/server/w_hagar.qc @@ -217,11 +217,6 @@ float w_hagar(float req) ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo; return ammo_amount; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_HAGAR] = autocvar_g_balance_hagar_reload_ammo; - } else if (req == WR_RELOAD) { W_Hagar_Reload(); diff --git a/qcsrc/server/w_hlac.qc b/qcsrc/server/w_hlac.qc index 2913ff2f35..62aacc6cfc 100644 --- a/qcsrc/server/w_hlac.qc +++ b/qcsrc/server/w_hlac.qc @@ -256,11 +256,6 @@ float w_hlac(float req) ammo_amount += self.weapon_load[WEP_HLAC] >= autocvar_g_balance_hlac_secondary_ammo; return ammo_amount; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_HLAC] = autocvar_g_balance_hlac_reload_ammo; - } else if (req == WR_RELOAD) { W_HLAC_Reload(); diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index 3794c69159..15580c2df6 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -318,11 +318,6 @@ float w_laser(float req) { return TRUE; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_LASER] = autocvar_g_balance_laser_reload_ammo; - } else if (req == WR_RELOAD) { W_Laser_Reload(); diff --git a/qcsrc/server/w_minelayer.qc b/qcsrc/server/w_minelayer.qc index 3db7ad4f7a..729dc47270 100644 --- a/qcsrc/server/w_minelayer.qc +++ b/qcsrc/server/w_minelayer.qc @@ -464,11 +464,6 @@ float w_minelayer(float req) { return FALSE; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_MINE_LAYER] = autocvar_g_balance_minelayer_reload_ammo; - } else if (req == WR_RELOAD) { W_MineLayer_Reload(); diff --git a/qcsrc/server/w_minstanex.qc b/qcsrc/server/w_minstanex.qc index de6fcff245..567e4fa100 100644 --- a/qcsrc/server/w_minstanex.qc +++ b/qcsrc/server/w_minstanex.qc @@ -300,9 +300,6 @@ float w_minstanex(float req) else if (req == WR_RESETPLAYER) { self.minstanex_lasthit = 0; - - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_MINSTANEX] = autocvar_g_balance_minstanex_reload_ammo; } else if (req == WR_RELOAD) { diff --git a/qcsrc/server/w_nex.qc b/qcsrc/server/w_nex.qc index 66aea05638..e6c2aaafe2 100644 --- a/qcsrc/server/w_nex.qc +++ b/qcsrc/server/w_nex.qc @@ -268,11 +268,6 @@ float w_nex(float req) ammo_amount += self.weapon_load[WEP_NEX] >= autocvar_g_balance_nex_secondary_ammo; return ammo_amount; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_NEX] = autocvar_g_balance_nex_reload_ammo; - } else if (req == WR_RELOAD) { W_Nex_Reload(); diff --git a/qcsrc/server/w_rocketlauncher.qc b/qcsrc/server/w_rocketlauncher.qc index 1198bc7419..46d3c70abb 100644 --- a/qcsrc/server/w_rocketlauncher.qc +++ b/qcsrc/server/w_rocketlauncher.qc @@ -506,9 +506,6 @@ float w_rlauncher(float req) else if (req == WR_RESETPLAYER) { self.rl_release = 0; - - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_ROCKET_LAUNCHER] = autocvar_g_balance_rocketlauncher_reload_ammo; } else if (req == WR_RELOAD) { diff --git a/qcsrc/server/w_seeker.qc b/qcsrc/server/w_seeker.qc index 18c5bc95ad..9517d1e308 100644 --- a/qcsrc/server/w_seeker.qc +++ b/qcsrc/server/w_seeker.qc @@ -518,11 +518,6 @@ float w_seeker(float req) ammo_amount += self.weapon_load[WEP_SEEKER] >= autocvar_g_balance_seeker_flac_ammo; return ammo_amount; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_SEEKER] = autocvar_g_balance_seeker_reload_ammo; - } else if (req == WR_RELOAD) { W_Seeker_Reload(); diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index 68b4ab2b18..a0db92215c 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -198,11 +198,6 @@ float w_shotgun(float req) // melee attack is always available return TRUE; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_SHOTGUN] = autocvar_g_balance_shotgun_reload_ammo; - } else if (req == WR_RELOAD) { W_Shotgun_Reload(); diff --git a/qcsrc/server/w_sniperrifle.qc b/qcsrc/server/w_sniperrifle.qc index 6147953968..1b62b25f63 100644 --- a/qcsrc/server/w_sniperrifle.qc +++ b/qcsrc/server/w_sniperrifle.qc @@ -230,9 +230,6 @@ float w_sniperrifle(float req) else if (req == WR_RESETPLAYER) { self.sniperrifle_accumulator = time - autocvar_g_balance_sniperrifle_bursttime; - - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_SNIPERRIFLE] = autocvar_g_balance_sniperrifle_reload_ammo; } else if (req == WR_RELOAD) { diff --git a/qcsrc/server/w_uzi.qc b/qcsrc/server/w_uzi.qc index 0482f43772..5c46f72c98 100644 --- a/qcsrc/server/w_uzi.qc +++ b/qcsrc/server/w_uzi.qc @@ -340,11 +340,6 @@ float w_uzi(float req) } return ammo_amount; } - else if (req == WR_RESETPLAYER) - { - // all weapons must be fully loaded when we spawn - self.weapon_load[WEP_UZI] = autocvar_g_balance_uzi_reload_ammo; - } else if (req == WR_RELOAD) { W_UZI_Reload(); -- 2.39.5