Commit 7da64d3 added the ability to select a weapon when firing stops.
However, it did not take into account that
select_primary_weapon/select_secondary_weapon do not check whether the
selected weapon is available. The caller must perform that check. The
draft version proposed by Mako88 in the original feature request mostly
avoided the problem by clearing the delayed auto-select when it was
first applied. That version would only manifest the problem if the
player had a delayed auto-select and lost the weapon before resolving
it, whether due to death, a thief bot, or, in the case of mines,
direct-dropping the last mine by the "Drop Bomb" key.
The version that went in switched to using delayed==active to indicate
that no change was required. Under that design, the incorrect
auto-select appears if the player loses the active weapon even if no
delayed selection was pending.
Add a check that the player has the weapon before switching to it and
reset delayed=current if the delayed weapon is not available. This
fixes all known cases under which a spurious delayed selection could
activate a missing weapon and prevents repeated checks for weapon
availability.
Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/158>
Fixes: 7da64d3782 ("Add new autoselect-while-firing mode: "when firing stops"")
The count of mines was not decremented, so a player who entered the loop
could continue to drop until (d_rand() < rthresh) became false. Halving
rthresh on each pass guaranteed that it would stop, but with the right
string of random numbers, the player could drop more mines than he had.
Remove the ==1 qualifier, so that mines can spawn whenever one will be
lost to rounding.
Commit 3adc5fe77a added the ability to
bind mouse buttons to change weapons, but a copying error bound the
fusion/omega entry to joystick instead of mouse. Switch it to mouse as
clearly intended.
This fix is needed for any commit with the underlying feature, but only
applies cleanly to 0.58.1 after applying cleanup commits:
00381b2652 ("Abstract out weapon names")
d035fb258a ("Remove unused kc_item->id")
fc1e00dae6 ("Pre-compute labelx+inputx")
a4f3c93247 ("Separate mutable and const kconfig data")
953a1888d7 ("Combine state pointer and count pointer")
2bd302cddd ("Move Controls ubyte values into substructure")
ff8db8d39e ("Reduce relocations for Controls members")
593d0b25ff ("Remove duplicate kconfig labels")
dc36ee3ab3 ("Store kconfig labels separately")
Fixes: 3adc5fe77a ("Saving weapon keys in PLX like in D1X-Rebirth" ...)