From df1388f9fc3ddee9fa55d79ab3c211fcef0b7adf Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Wed, 18 Nov 2020 13:17:43 +0100 Subject: [PATCH] Server: Add sv_forceweapondraw 0/1, which lets mods override whether or not the first weapon the player picks up will be deployed automatically. --- src/server/weapons.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/server/weapons.c b/src/server/weapons.c index f5a723c1..7e64cea4 100644 --- a/src/server/weapons.c +++ b/src/server/weapons.c @@ -1,4 +1,22 @@ -#ifdef SERVER +/* + * Copyright (c) 2016-2020 Marco Hladik + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* force the drawing of the first weapon that's picked up */ +var int autocvar_sv_forceweapondraw = TRUE; + int Weapon_GetCount(void) { @@ -84,7 +102,7 @@ Weapons_AddItem(base_player pl, int w, int startammo) value = TRUE; /* it's new, so autoswitch? */ - if (pl.activeweapon == 0) { + if (pl.activeweapon == 0 && autocvar_sv_forceweapondraw) { pl.activeweapon = w; Weapons_Draw(); } else { @@ -101,7 +119,7 @@ Weapons_AddItem(base_player pl, int w, int startammo) value = g_weapons[w].pickup(TRUE, startammo); /* it's new, so autoswitch? */ - if (pl.activeweapon == 0) { + if (pl.activeweapon == 0 && autocvar_sv_forceweapondraw) { pl.activeweapon = w; Weapons_Draw(); } else { @@ -201,4 +219,3 @@ CSEv_DropWeapon(void) player pl = (player)self; Weapon_DropCurrentWeapon(pl); } -#endif