From da5cb69c009b4c8fafbb2498787bd4b05d0274e7 Mon Sep 17 00:00:00 2001 From: flowtron Date: Sun, 28 Aug 2022 10:38:20 +0200 Subject: [PATCH] protocol robustness (based on _Flo comment) --- source/src/entity.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/src/entity.h b/source/src/entity.h index cf3fb309..96500eb4 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -538,13 +538,14 @@ public: void selectweapon(int w, bool other = false) { + if(!valid_weapon(w)) return; if(weaponsel) prevweaponsel = weaponsel; weaponsel = weapons[(gunselect = w)]; if(!prevweaponsel) prevweaponsel = weaponsel; if(other && (prevweaponsel != weaponsel)) weaponswitch(weaponsel, true); } - void setprimary(int w) { primweap = weapons[(primary = w)]; } + void setprimary(int w) { if(!valid_weapon(w)) return; primweap = weapons[(primary = w)]; } void setnextprimary(int w) { nextprimweap = weapons[(nextprimary = w)]; } bool isspectating() { return state==CS_SPECTATE || (state==CS_DEAD && spectatemode > SM_NONE); } void weaponswitch(weapon *w, bool sound = true)