Mako88 reports that some users want not to autoselect while firing, but
do not notice when a new weapon is added to the HUD, and end up never
activating a preferred weapon. Add a new autoselect mode that remembers
what would be selected and switches to it once the player ceases firing.
Changes since Mako88's proposed version:
- Use `enum class` for autoselection mode and a radio button to
represent the decision of Immediate/Never/Delayed.
- Handle delayed autoselect for vulcan ammo.
- Set Delayed_primary == Primary_weapon to indicate no change is needed,
rather than Delayed_primary==-1. This lets some paths use
Delayed_primary without checking for a magic value.
- Likewise Delayed_secondary / Secondary_weapon.
- Update Delayed_primary/Delayed_secondary when changing active
primary/secondary weapon, so that a player who changes weapons while
firing will automatically clear any deferred change.
Requested-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/97>
Based-on-patch-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/pull/147>
gcc-4.6 chokes on `static constexpr type value{};`, but accepts
`static constexpr auto value = type{};`
Fixes: 9d213b5282 ("Wrap player_has_weapon return type")
Fix potential for initializing .children to wrong value with old data
files. Currently, this cannot be hit because no caller uses the right
combination of arguments to cause it.
Rely on partial_range to report invalid custom files.
C++ does not require this pattern.
import re, fileinput
to = re.compile(r'^typedef struct ([a-z_A-Z]+)\s*{')
tc = re.compile(r'^}(.*?)\s*([a-z_A-Z]+);$')
osn = None
for line in fileinput.input(inplace=True):
m = to.match(line)
if m:
osn = m.group(1)
print 'struct %s\n{' % osn
continue
if osn:
m = tc.match(line)
if m:
csn = m.group(2)
if osn == csn:
print '}%s;' % m.group(1)
osn = None
continue
else:
osn = None
print line,