From b73dcec3975877fd374b55b425c99bb1d6921b53 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Thu, 4 Oct 2007 22:37:35 +0000 Subject: added mousewheel support. added next/prev weapon support --- src/game/server/game_server.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/game/server/game_server.cpp') diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index cf4be747..95b01967 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -725,16 +725,34 @@ int player::handle_weapons() } // switch weapon if wanted - if(input.activeweapon >= 0 && input.activeweapon < NUM_WEAPONS && weapons[input.activeweapon].got && - data->weapons[active_weapon].duration <= 0) + if(input.activeweapon && data->weapons[active_weapon].duration <= 0) { - if (active_weapon != input.activeweapon) - create_sound(pos, SOUND_WEAPON_SWITCH); + int new_weapon = active_weapon; + if(input.activeweapon > 0) // straight selection + new_weapon = input.activeweapon-1; + else if(input.activeweapon == -1 && !previnput.activeweapon) // next weapon + { + do + new_weapon = (new_weapon+1)%NUM_WEAPONS; + while(!weapons[new_weapon].got); + } + else if(input.activeweapon == -2 && !previnput.activeweapon) + { + do + new_weapon = (new_weapon-1)<0?NUM_WEAPONS-1:new_weapon-1; + while(!weapons[new_weapon].got); + } + + if(new_weapon >= 0 && new_weapon < NUM_WEAPONS && weapons[new_weapon].got) + { + if(active_weapon != new_weapon) + create_sound(pos, SOUND_WEAPON_SWITCH); - last_weapon = active_weapon; - active_weapon = input.activeweapon; + last_weapon = active_weapon; + active_weapon = new_weapon; + } } - + if(!previnput.fire && input.fire) { if(reload_timer == 0) -- cgit 1.4.1