Commit graph

65 commits

Author SHA1 Message Date
Kp 4257391a47 Use enum class for polygon_model_index 2022-12-18 18:32:14 +00:00
Kp 192988b004 Use enum class for weapon_info::persistent 2021-09-19 10:53:48 +00:00
Kp 21c530a3e2 Use enumerated_array for difficulty-level-specific arrays 2021-09-19 10:53:48 +00:00
Kp baa2823953 Pass player_info to which_bomb
Previously, rendering the preferred bomb type could also change it if
the active type was exhausted.  This is undesirable, since it depends on
the user to have a HUD mode which causes the bomb type to render.
Switch to only change the active type if the user tries to drop a bomb
while the active type is unavailable.  Some call sites already switch
bomb types automatically on depletion.  Those sites will still do so.
2021-01-17 22:23:22 +00:00
Kp 696141eabf Use enum class for weapon_info::bounce 2020-12-20 20:39:07 +00:00
Kp e261ca2884 Use enum class for weapon_info::matter 2020-12-20 20:39:07 +00:00
Kp ffb653c0b8 Pass control_info & to various functions
Switch from a direct global reference to passing control_info& as a
parameter.
2020-10-12 03:28:26 +00:00
Kp 8e81726ac5 Use enum class for laser_level
Remove stored_laser_level, which existed primarily to enforce type
separate.  `enum class` can do that without the need for a separate
class type.
2020-08-24 01:31:28 +00:00
Kp 8839f538e0 Refer to <array> directly, not through "compiler-array.h" 2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 9421c31b5a Replace "compiler-type_traits.h" with <type_traits>
Delete stub "compiler-type_traits.h" header.  Redirect all uses to the
standard <type_traits> header.

git grep -wlz 'compiler-type_traits.h' -- '*.cpp' '*.h' | xargs -0 perl -p -i <<EOF
    BEGIN {
	    $i = 0;
    }
    if (($i == 1 && $_ eq "\n") || ($i < 2 && /^#include "/)) {
	    # First blank line or first user-include after a system-include.
	    # Print, then never again for this file.
	    print "#include <type_traits>\n";
	    $i = 2;
    } elsif ($i == 0) {
	    $i = 1 if (/^#include </);
    } elsif ($_ eq "#include \"compiler-type_traits.h\"\n") {
	    # Remove this line if found.
	    $_ = '';
    }
    # Reset state machine when moving to next file.
    $i = 0 if eof;
EOF
2017-06-25 20:46:03 +00:00
Kp adcf02e454 Expand tt:: indirection to std::
All supported compilers have an acceptable <type_traits>.  Commit
4cb3d46148 ("Move <type_traits> test to Cxx11RequiredFeature") made
<type_traits> support mandatory in August and no one has objected.
Remove the indirection and use namespace std directly for type_traits
members.
2017-06-25 20:46:03 +00:00
Kp ec19a6947f Move more symbols to namespace dsx 2016-10-02 19:35:34 +00:00
Kp e6b44ffef1 Pass player_info to delayed_autoselect 2016-10-02 00:34:43 +00:00
Kp 27cef20eb3 Move namespace dsx handling to dsx-ns.h 2016-03-19 19:08:10 +00:00
Kp c3003fbb22 Fix vulcan ammo display
Do not abuse `f2i` to shift an unsigned quantity.  `f2i` is defined to
work on `fix`, which is `int`.
2016-02-20 17:28:11 +00:00
Kp dd877f52c2 Remove unused weapon defines 2016-01-09 16:38:15 +00:00
Kp b683b4cc68 Scope weapon type 2015-12-03 03:26:49 +00:00
Kp bb41075adb Add preprocessor guards around types that vary by game 2015-11-26 02:56:55 +00:00
Kp 533f1cb3bb Qualify references to primary weapons 2015-10-18 21:01:18 +00:00
Kp 7da64d3782 Add new autoselect-while-firing mode: "when firing stops"
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>
2015-10-18 18:11:57 +00:00
Kp dd0f5cb83f Move fwdvalptridx.h -> fwd-valptridx.h for consistency 2015-10-09 02:46:11 +00:00
Kp 70c4cc87ab Use forward-declaration header for weapon.h 2015-07-25 23:10:45 +00:00
Kp 06b453d617 Enable D1 weapon drops 2015-07-02 02:37:55 +00:00
Kp 2f00efdcc6 Fix gcc-4.6 weapon build
gcc-4.6 chokes on `static constexpr type value{};`, but accepts
`static constexpr auto value = type{};`

Fixes: 9d213b5282 ("Wrap player_has_weapon return type")
2015-05-22 03:33:20 +00:00
Kp 0d564814f5 Convert Primary_weapon to primary_weapon_index_t 2015-04-26 20:15:57 +00:00
Kp 8d849b2b39 Wrap laser level in class
Move enum laser_level_t to weapon.h for the new class.
2015-04-26 20:15:56 +00:00
Kp cca163fc30 Split select_weapon 2015-04-26 20:15:52 +00:00
Kp f789e29b41 Simplify check_to_use_primary 2015-04-26 20:15:52 +00:00
Kp 610f603ebf Pass weapon_name to select_weapon 2015-04-26 20:15:52 +00:00
Kp 10b9206a9b Split do_weapon_select 2015-04-26 20:15:51 +00:00
Kp 4d046c5336 Split auto_select_weapon 2015-04-26 20:15:51 +00:00
Kp b88c232f9f Use powerup_type_t for *_weapon_to_powerup 2015-04-19 04:18:53 +00:00
Kp d7066c3eb9 Remove constant arguments to pick_up_ammo 2015-04-19 04:18:53 +00:00
Kp 9d213b5282 Wrap player_has_weapon return type 2015-04-19 04:18:50 +00:00
Kp a9c81c5614 Move Weapon_is_energy to collide.cpp 2015-04-02 02:36:57 +00:00
Kp 90fbebf8fd Convert most global arrays to array<> 2015-04-02 02:36:52 +00:00
Kp 5212daa4ad Fix seismic duration sync 2015-02-14 22:48:29 +00:00
Kp d4117871a1 Use range_for for intro movies 2015-01-29 04:27:36 +00:00
Kp bca8889695 Simplify Primary_ammo_max 2015-01-17 18:31:42 +00:00
Kp 53aa70cecb Use vsegptridx_t 2014-10-28 03:08:51 +00:00
Kp 78ad2adabf Write weapon_info carefully 2014-09-27 22:46:25 +00:00
Kp 382afad2b8 Refactor weapon_info_read_n
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.
2014-09-27 21:21:58 +00:00
Kp 93bb883563 Use array<> for weapon_info fields 2014-09-27 17:15:17 +00:00
Kp 703f60ac3f Fix -Wtype-limits warnings 2014-09-21 21:41:55 +00:00
Kp b95759aecc Propagate use of objptridx 2014-08-23 23:53:56 +00:00
Kp 125d9257be Use special type names for segment/object numbers 2014-08-13 02:57:12 +00:00
zico ad7cb106bc Changed custom D1X license to GPLv3 2014-06-01 19:55:23 +02:00
Kp 094dfbf3d4 Reduce header inclusions 2013-12-31 03:22:03 +00:00
Kp 073f00974a Eliminate uses of the typedef struct X { ... } X; pattern
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,
2013-12-28 22:48:07 +00:00