Commit graph

4137 commits

Author SHA1 Message Date
Kp 0dfd462c64 Change fvi_query to pass LevelUniqueObjectState if checking objects
Remove the definition of FQ_CHECK_OBJS and all uses of it.  Add a new
fvi_query member d_level_unique_object_state *LevelUniqueObjectState.
If object checking is enabled, pass &LevelUniqueObjectState in that
member.  If object checking is disabled, pass nullptr in that member.

Change fvi_sub to use this member to decide whether to perform object
checking.
2022-07-09 13:39:29 +00:00
Kp 4bc901b0a9 fvi_sub: validate object once at start of FQ_CHECK_OBJS
If FQ_CHECK_OBJS is used, a valid object is required.  Copy the
icobjptridx_t from fvi_query into a local vcobjptridx_t to force a
validation, then use that validated copy for later work.
2022-07-09 13:39:29 +00:00
Kp 4ab619b7c2 Restructure use of fvi_query
- Make all members constant, and pass an anonymous temporary fvi_query
  to find_vector_intersection.
- Change `p0`/`p1` to `const vms_vector &`, since the positions are
  mandatory.  Callers can no longer pass `nullptr` or an uninitialized
  value here.
- Change `thisobjnum` to `icobjptridx_t`.  Calls to fvi_sub built an
  objptridx at need, so moving it to the caller allows it to be
  constructed once per find_vector_intersection call.
- Move `flags` and `rad` out of fvi_query, since calls to fvi_sub may
  use other values than the ones in fvi_query.  This prepares for
  passing fvi_query to fvi_sub.
2022-07-09 13:39:29 +00:00
Kp a690374916 Pass state to place_object 2022-07-09 13:39:29 +00:00
Kp 8ba1390947 Pass state to explode_object 2022-07-09 13:39:29 +00:00
Kp e25b476de7 Use enum for segnum_t
Add checked conversions for sites which load from external integers.
2022-07-02 18:10:45 +00:00
Kp fca59adb53 Split out creating OBJ_WEAPON objects 2022-07-02 18:10:45 +00:00
Kp e2509fc840 Move d_robot_info_array out of d_level_shared_robot_info_state
Embedding it in d_level_shared_robot_info_state is reasonable from a
relational perspective, but interferes with referencing
d_robot_info_array when only a forward declaration of
d_level_shared_robot_info_state is available.
2022-07-02 18:10:45 +00:00
Kp 25d0ae8f65 Use an explicitly defaulted exact_type<T>::operator==
clang-13 needed an operator==(const exact_type<T>&) defined to avoid an
ambiguity.  Now that C++20 mode is enabled, switch to a
compiler-generated operator== instead of manually defining the
equivalent function.
2022-07-02 18:10:45 +00:00
Kp 1bcc5c40d0 Work around clang-13 ambiguous operator==
In C++ 20 mode, clang-13 gets confused about how to handle operator==.
Rewrite the test to encourage it to pick the correct version.

```
common/include/gr.h:129:12: error: use of overloaded operator '==' is ambiguous (with operand types 'dcx::grs_main_bitmap *' and 'exact_type<dcx::grs_bitmap>')
        if (this == &r)
            ~~~~ ^  ~~
common/include/pack.h:31:17: note: candidate function (with reversed parameter order)
    constexpr bool operator==(const T *rhs) const { return p == rhs; }
                   ^
common/include/gr.h:129:12: note: built-in candidate operator==(struct dcx::grs_bitmap *, struct dcx::grs_bitmap *)
        if (this == &r)
```
2022-07-02 18:10:45 +00:00
Kp 33d938ac06 Prepare exact_type for clang-13 in C++20 mode
clang-13 in C++20 mode fails:

```
similar/main/newmenu.cpp:202:18: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'exact_type<const dcx::grs_font>' and 'exact_
type<const dcx::grs_font>') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
    return &cv_font == &game_font ? "\202" : "\207";  // 135
	   ~~~~~~~~ ^  ~~~~~~~~~~
common/include/pack.h:31:17: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
    constexpr bool operator==(const T *rhs) const { return p == rhs; }
		   ^
```

Add an operator== that exactly matches the input types so that clang
does not attempt a conversion.
2022-07-02 18:10:45 +00:00
Kp bdeca5687e Remove unused copy_diminish_palette
Fixes: f413017317 ("Delegate bald_guy_load PCX to SDL image")
2022-07-02 18:10:45 +00:00
Kp e45ff2da5e Use named enum types for netflag and netgrant 2022-07-02 18:10:45 +00:00
Kp e79af7c55f Restrict RAIIdmem to use on integral types
There are no remaining uses of RAIIdmem on structure types.  Restrict it
to integral types, to remove use of std::is_pod.
2022-07-02 18:10:45 +00:00
Kp a906f13c83 Replace deprecated std::is_pod in physfsx helpers
C++20 deprecates std::is_pod.  Expand std::is_pod to its equivalent long
form of std::is_standard_layout && std::is_trivial.
2022-07-02 18:10:45 +00:00
Kp fd7ab4388c Remove unused CALLOC code
TGA generation was the last user of CALLOC.  Remove it.
2022-07-02 18:10:45 +00:00
Kreeblah 1c8ff1ac0f
Fix gl.h include location for macOS 2022-06-24 23:06:27 -07:00
Kp a1bdd81d41 Exclude unused code from D2 non-editor build
gamedata_read_tbl is only called if (D1 || (D2 && EDITOR)).  Exclude
defining it for (D2 && !EDITOR).  From there, also exclude defining or
reading the alias list, which is only written by a function
called by gamedata_read_tbl.

Reported-by: heftig <https://github.com/dxx-rebirth/dxx-rebirth/issues/642>
2022-06-11 15:00:02 +00:00
Kp 2f78951b02 Change underlying_value to use a deleted function for the bad case
This produces a better error message than a static_assert failure, since
gcc points directly to the call which resolved to the deleted overload.
When the caller is correct, this produces the same result as the prior
version.
2022-06-11 15:00:02 +00:00
Kp 522c696af0 Remove unnecessary members in splitpath_t
splitpath_t is designed for MS-DOS paths, even though Rebirth now runs
on many platforms that never used DOS conventions.  Most of the members
of splitpath_t are unused on all platforms.  Remove them, and switch to
returning an initialized version of the structure.
2022-06-11 15:00:02 +00:00
Kp 346906ae9f Simplify UPID_QUIT_JOINING
The host only needs to check the source address.  Remove the check on
the callsign, and shrink the message accordingly.
2022-06-05 17:44:53 +00:00
Kp 9816475706 Pass Object array to object_goto_next_viewer 2022-06-05 17:44:53 +00:00
Kp c5de47b51e Add const qualifiers to some net_udp functions 2022-06-05 17:44:53 +00:00
Kp 3d7cb4abc7 Remove force_dump_ai_objects_all
It rotted because it is only ever used when PARALLAX is defined.  No one
has reported it broken, so remove it.
2022-06-05 17:44:53 +00:00
Kp e180375f97 Pass GameBitmaps to draw_object_blob 2022-06-05 17:44:52 +00:00
Kp cc2f3caa7e Split piggy.h -> fwd-piggy.h 2022-06-05 17:44:52 +00:00
Kp 6228b07b45 Fix check_header_includes=1 build of fvi.h 2022-06-05 17:44:52 +00:00
Kp 6e2ed26659 Pass object to init_player_object 2022-06-05 17:44:52 +00:00
Kp 9f207daf95 Pass player object to reset_player_object 2022-06-05 17:44:52 +00:00
Kp 11a0aae9ee Pass GameBitmaps to piggy_bitmap_page_in 2022-06-05 17:44:52 +00:00
Kp 33152640bc Remove fvi_info::hit_type
Its value is always readily available as the return value of
find_vector_intersection, so remove the structure member and rely on the
returned value.
2022-06-05 17:44:52 +00:00
Kp be7388a369 Enable repaircenter in D1
The code exists in D2, and the segment special is reserved for both
games.  Include the repaircenter code in D1, also.
2022-06-05 17:44:52 +00:00
Kp 6bd6a47612 Rework compress_segments to use segment iterators
This removes direct math on segnum_t, which will simplify later use of
`enum class segnum_t`.
2022-06-05 17:44:52 +00:00
Kp 86a32dd0ff Change enum sidenum_t to enum class sidenum_t 2022-06-05 17:44:52 +00:00
Kp 4fd412b2ea Precompute g3_draw_line GL color data 2022-06-05 17:44:52 +00:00
Kp e54338ce4e Combine canvas+color into g3_draw_line_context 2022-06-05 17:44:52 +00:00
Kp a8e7f6ad59 Use enum class for find_vector_intersection result 2022-05-24 02:32:58 +00:00
Kp d8ab3c9bd3 Remove quadint members low, high
Always access the data through the member `q`.  This makes the code
independent of architecture endian decisions.
2022-05-24 02:32:58 +00:00
Kp e154d37e5e Tighten valptridx::ptridx range checking for pointer_type constructor
Previously, the supplied pointer was converted to an array index, then
passed to valptridx::idx for validation.  If the index_type is smaller
than std::size_t, this would truncate the value before validation.
Certain out-of-range indexes would be in-range after truncation, and
incorrectly not be reported.

Reorder the check to validate the index against the array size before
truncation.
2022-05-24 02:32:58 +00:00
Kp 67705bdd7a Return checkmuldiv result in std::optional 2022-05-24 02:32:58 +00:00
Kp 1f5d72e747 Use native 64-bit math in checkmuldiv 2022-05-24 02:32:58 +00:00
Kp 62635ec285 Use enum class for vm_magnitude_squared 2022-05-24 02:32:58 +00:00
Kp cf51ac4ee0 Fix BUG on show-path cheat
Players are not robots, but the show-path cheat tried to pretend they
are, and triggered a BUG warning[1] when looking up robot information
from the player object.  Fix this by passing in the robot_info when the
caller is providing a robot, and a named `nullptr` value (as
`create_path_unused_robot_info`) when the caller is providing a
non-robot object.

[1] As below, but repeated many times
```
similar/main/ai.cpp:1905: BUG: object 0x555555858550 has type 4, expected 2
similar/main/ai.cpp:1974: BUG: object 0x555555858550 has type 4, expected 2
```
2022-05-21 19:51:18 +00:00
Kp 8c5eff2ba0 Remove unused return value of callsign_t::copy 2022-05-10 01:58:55 +00:00
Kp 7b7145f20a Simplify zeroing callsign on copy-in
Zero the entire array, then overwrite the leading portion with the
received data.  This permits the compiler to do a fixed number of large
stores, instead of a variable number of small stores.
2022-05-10 01:58:55 +00:00
Kp 163a6222c2 Remove unnecessary endian instances in serial.h
The type aliases are sufficient.  Individual bytebuffer_t
implementations can define a `static constexpr` member `endian` from the
type alias and rely on `std::integral_constant<T, V>::operator()`
instead of defining a `static` method just to return an instance of the
`std::integral_constant`.
2022-05-05 02:59:11 +00:00
Kp bdff6f7a00 Remove unused return value of attempt_to_steal_item 2022-05-05 02:59:11 +00:00
Kp 504b38759c Use enum class for weapon_sound_flag
Pass the silent/audible flag as an enum:uint8_t to avoid type confusion
issues.
2022-04-24 20:42:01 +00:00
Kp a610a7b32d Pass bare object & to thief stealing routines
Use `object &` instead of `vmobjptr_t`.  This should generate equivalent
code, but produce smaller debug information and may require less
inlining by the compiler.
2022-04-24 20:42:01 +00:00
Kp 1c2e1c6946 Tighten type info for d_strdup
The allocated block is part of the dmem subsystem, so return a type that
reflects that.
2022-04-24 20:42:01 +00:00
Kp 8f8989e049 Propagate do_laser_firing nfires as 1
Every caller passes `1`, so remove the parameter and always use `1`.
For backward compatibility with the previous network protocol, continue
to send a `1` in the network message.
2022-04-17 22:27:19 +00:00
Kp f79baf722c Move static obj_* functions into anonymous namespace 2022-04-17 22:27:19 +00:00
Kp cf2c7bbe80 Replace serial byteswap macros with constexpr function
This allows taking the input by-value instead of by-reference, while
still protecting against unwanted type conversion.

Add some basic static_assert tests that the swapped values are correct.
2022-04-17 22:27:19 +00:00
Kp 71b4c11f8c Combine DXX_HAVE_BUILTIN_BSWAP, DXX_HAVE_BUILTIN_BSWAP16
Commit f1606f7747 ("Simplify test for
__builtin_bswap16") changed the SConstruct test to either define both
DXX_HAVE_BUILTIN_BSWAP and DXX_HAVE_BUILTIN_BSWAP16 or to define neither
of them.  Follow up that commit by removing the definition of
DXX_HAVE_BUILTIN_BSWAP16 and redirecting uses of it to
DXX_HAVE_BUILTIN_BSWAP.
2022-04-17 22:27:19 +00:00
Kp 2a6c513ffd Fix LTO ODR build failure in wall.h
The conditional definition of a D2X flag causes a technical ODR
violation.  It is legal, though not useful, to define this flag in D1X
and in common code.  Remove the preprocessor guard so that D2X and
common code use the same definition for the enum.
2022-04-17 22:27:19 +00:00
Kp d0c32b8cf2 Pass LevelUniqueWallSubsystemState to wall_init 2022-04-17 22:27:19 +00:00
Kp 211dcede72 Inline trigger_init
It is used in only one place.  Move it inline.
2022-04-17 22:27:19 +00:00
Kp 99747e092f Avoid index truncation in check_explicit_index_range_ref
Split check_index_range to check_index_range+check_index_range_size.
Redirect check_explicit_index_range_ref to check_index_range_size, so
that the index_type is not truncated and then extended.
2022-04-17 22:27:19 +00:00
Kp bbd49251cf Simplify susegment constructor overloads
Use a single constructor that accepts anything convertible to both of
the required types, rather than special constructors for:
- Accepting a qualified_segment
- Accepting a variant of susegment with compatible const qualifiers
- Accepting a type T that converts to qualified_segment

This reduces the number of constructors to consider, which improves
error messages when an invalid input is used.
2022-04-17 22:27:19 +00:00
Kp 06a0de1c90 Remove write-only legacy trigger field time
v29_trigger and v30_trigger define a field `time`.  v29_trigger never
initializes it.  v30_trigger initializes it from the uninitialized
v29_trigger in legacy mode, and from a file field otherwise.  No program
logic ever reads this member, so remove it.
2022-04-16 19:38:02 +00:00
Kp 0142c02edd Use Mix_LoadMUSType_RW for named files, too
When a file name is available, use SDL_RWFromFile + Mix_LoadMUSType_RW,
rather than calling Mix_LoadMUS(filename).  This allows the calling code
to be more consistent.
2022-03-19 22:55:58 +00:00
Kp f5e9daf7a5 Use Mix_LoadMUSType_RW to unify SDL1/SDL2 call to Mix_LoadMUS_RW
SDL1 defines Mix_LoadMUS_RW as:

```
Mix_LoadMUS_RW(SDL_RWops *rw)
	Mix_LoadMUSType_RW(rw, MUS_NONE, SDL_FALSE);
```

SDL2 defines Mix_LoadMUS_RW as:

```
Mix_LoadMUS_RW(SDL_RWops *src, int freesrc)
	Mix_LoadMUSType_RW(src, MUS_NONE, freesrc);
```

The version with freesrc is preferable, and Rebirth used it to set
freesrc=SDL_TRUE in SDL2 mode.  For SDL1, Rebirth used special logic
in the reset() call to emulate setting freesrc=SDL_TRUE.  SDL1 also
exposes Mix_LoadMUSType_RW, which allows the caller to set freesrc in
both SDL1 and SDL2.  Switch to that, so that the same code is used in
SDL1 and SDL2.
2022-03-19 22:55:58 +00:00
Kp 2099c54ac7 Remove mix_play_file use of PHYSFSX_getRealPath
If the file is accessible via PhysFS, the next branch, based on
PHYSFS_openRead, will find it and use it.  If it is not accessible via
PhysFS, then attempting to resolve its path would fail.  Thus, this
attempt is redundant regardless of whether the file is reachable by
PhysFS.  Remove it.
2022-03-19 22:55:58 +00:00
Kp 9cdf9152bc Always check return value of PHYSFSX_getRealPath
The contents of the output buffer are undefined if PHYSFSX_getRealPath
fails, so mark the function as [[nodiscard]] and modify all callers to
check that the function succeeded.
2022-03-19 22:55:58 +00:00
Kp 3b5b69cb97 Improve error reporting for hmp_open / hmp2mid
Rework the error paths to return path-specific status codes so that the
caller can report exactly which step caused an HMP file to be rejected.
On error, print this reason numerically and, if the reason was a PhysFS
error, also print the PhysFS error code numerically and symbolically.
2022-03-19 22:55:58 +00:00
Kp d34f7b2ad9 Remove unnecessary tests for current_music_type
If the type is not None, an earlier statement will have already
returned.  Thus, the type can be assumed to be None if these test
statements are reached.
2022-03-19 22:55:58 +00:00
Kp d09d30e173 Make mix_play_file only skip hmp for dot-less filenames
Previously, if the filename had no dots, then mix_play_file would refuse
to play it at all.  This was excessive, as only the check for hmp needs
a filename with a dot in it.  Change the logic so that a dot-less file
still is assumed not to be an hmp, but instead of returning, will fall
through and try the other load types.
2022-03-19 22:55:58 +00:00
Kp c4cc119898 Set music type inside load_mus_file
Return the type for compatibility, but set the music type immediately.
Change callers to return without using a switch to set the music type
based on the returned value.  This allows the callers to exit early on a
successful load.

Remove the `switch` in the caller, since now every path that can set
`current_music_type` will either (a) set it to None because the load
failed or (b) set it to non-None and return before reaching the
`switch`.
2022-03-19 22:55:58 +00:00
Kp f8cf0b10c2 Set music type inside load_mus_data
Return the type for compatibility, but set the music type immediately.
Change callers to return without using a switch to set the music type
based on the returned value.  This allows the callers to exit early on a
successful load.
2022-03-19 22:55:58 +00:00
Kp f12abb938e Factor out setting mixer parameters
- Centralize the default value for the hook function.
- Move some static functions to the anonymous namespace.
- Define functions for setting the mixer parameters to ADLMIDI mode and
  SDL_mixer mode, so that these modes can be set from more places.
2022-03-19 22:55:58 +00:00
Kp 21aae1a352 Tighten symbol visibility for xrange
Switch to using protected inheritance, and expose the two base fields
that are needed outside the class.
2022-03-05 17:23:51 +00:00
Kp dc59b0b2cb Split out xrange init_begin ascending/descending paths
AlumiuN reports that mingw32-w64-gcc-8.1.0 incorrectly reports
`ascending` as unused-but-set.  This is clearly not true.  Reorder the
code to avoid saving `ascending`, and instead use the result of
`detail::get_xrange_ascending` directly.  This also improves the error
message in the DXX_ALWAYS_ERROR_FUNCTION path.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/626>
2022-03-05 17:23:51 +00:00
Kp 9e58992296 Flatten constant_xrange hierarchy 2022-02-27 14:23:53 +00:00
Kp f51755c2e6 Use enum class for MBTN_* constants 2022-02-27 14:23:53 +00:00
Kp 6863dd3581 Reduce lifetime of joy_axis
It is only needed for the duration of kconfig_end_loop.  Move it from
the global Controls to local scope.
2022-02-27 14:23:53 +00:00
Kp 197a9cbd98 Move joystick interpretation to happen after the event loop
If two or more events are delivered in the same loop, the previous
implementation would count joystick motion multiple times.  Fix this by
moving the joystick interpretation to occur once, after all the events
have been processed.
2022-02-27 14:23:53 +00:00
Kp 9464bdf2e4 Use enumerated_array for indexing player input controls 2022-02-27 14:23:53 +00:00
Kp 68268e9a1f Use sidenum_t in more places 2022-02-19 14:52:17 +00:00
Kp 2fe9a16613 Use dedicated type for mask of segment side numbers 2022-02-19 14:52:17 +00:00
Kp 8c037b7c26 Split player start generation
Move some of the logic to a separate function to enable use of `return`
instead of a `break` from a composite loop.
2022-02-19 14:52:17 +00:00
Kp b1278b8e39 Flatten type hierarchy for enumerated_iterator
Pass adjust_iterator_dereference_type directly, instead of passing
iterator_dereference_type and letting enumerated_iterator compute
adjust_iterator_dereference_type.
2022-02-19 14:52:17 +00:00
Kp 72064c62e7 Add unit tests for enumerate 2022-02-13 19:13:38 +00:00
Kp 17d1c3fb13 Pass range index_type through zip_iterator 2022-02-13 19:13:38 +00:00
Kp 3dd050ef98 Remove unused_ui_userdata 2022-02-13 19:13:38 +00:00
Kp c4985b8606 Move UI_GADGET list setup into constructor 2022-02-13 19:13:38 +00:00
Kp f2832e6248 Simplify _sockaddr IPv4/IPv6 logic
- Use std::integral_constant instead of a static function that returns
  the value
- Remove unused protocol_family
- Replace the enum with a typedef for the one type that the enum was
  used to define
2022-02-12 18:57:12 +00:00
Kp 8be306efa7 Use enum class for cockpit_mode_t 2022-02-12 18:57:12 +00:00
Kp 6b8a0a74c6 Fix some check_header_includes=1 failures 2022-02-12 18:57:12 +00:00
Kp 2be1a8ca85 Split game.h to fwd-game.h 2022-02-12 18:57:12 +00:00
Kp 8d9989024e Split inferno.h to fwd-inferno.h 2022-02-12 18:57:12 +00:00
Kp 504cbcc012 Split powerup.h to fwd-powerup.h 2022-02-12 18:57:12 +00:00
Kp da49df78f7 Split drop_powerup to return either an object id or a success code
If exactly one object will always be needed, use an overload that
returns the object id.  Otherwise, use an overload that only returns
whether at least one object was created.  This simplifies callers that
always request exactly one object.
2022-02-06 16:12:31 +00:00
Kp 04f0507942 Fix memory corruption if spit_powerup fails to drop a weapon
If spit_powerup fails, it returns object_none.  object_none is not a
valid index for use by map_objnum_local_to_remote.
2022-02-06 16:12:31 +00:00
Kp d5e520bc7b Fix failure to send robot creation message if one creation fails
If at least two robots would be dropped, and a drop failed, then
object_create_robot_egg would report failure to the caller.  Callers
that check the return code treat any failure as total failure, but that
is not guaranteed to be true.  If the game successfully dropped one
robot and failed when dropping a second, then the caller would receive a
status of failure.

Fix this by returning a status of whether at least one object was
created.
2022-02-06 16:12:31 +00:00
Kp 4a85b55865 Factor out drop_player_eggs creation of vulcan/gauss weapons 2022-02-06 16:12:31 +00:00
Kp 1ad3377a83 Pass context to start_boss_death_sequence 2022-02-05 13:30:56 +00:00
Kp 29d6072f60 Pass context to drop_stolen_items 2022-02-05 13:30:56 +00:00
Kp 60c5fc5dc4 Pass object& to multi_drop_robot_powerups 2022-02-05 13:30:56 +00:00
Kp 6cc788e1cd Pass object_base& to object_create_robot_egg 2022-02-05 13:30:56 +00:00
Kp f55aed4b9b Pass object& to ai_door_is_openable 2022-02-05 13:30:56 +00:00
Kp 2440a271da Improve vulcan/gauss pickup rules
- Change D1X to use D2X rules regarding Vulcan cannon pickup.  The D1X
  rules were confusing at best, and seem outright wrong in some ways.
  - When a Vulcan cannon was picked up, it was treated as containing not
    less than VULCAN_WEAPON_AMMO_AMOUNT rounds, regardless of what it
    actually contained.  D2X respected the actual contained count, even
    when running in D1X emulation mode.
  - In D1X single player, if the Vulcan cannon was not picked up, then
    it could be treated as Vulcan ammo.  If at least 1 unit of
    ammunition was added to the player, the entire powerup would be
    consumed, regardless of how much ammunition remained.
  - In D2X single player, if the Vulcan cannon was not picked up, then
    ammunition would be taken from it, but the powerup would only be
    consumed if all its ammunition was taken.
  - In D1X multiplayer, a player who already had a Vulcan cannon could
    not get anything from touching a new cannon, and the cannon would
    not be changed.
  - In D2X multiplayer, a player who already had a Vulcan cannon could
    take ammunition from the cannon, but the cannon could not be drained
    below VULCAN_AMMO_AMOUNT.  If the cannon had VULCAN_AMMO_AMOUNT or
    less, then the player could not take ammunition.  If the cannon had
    more, the player could drain it to that level.
  - Replace all that with a simplified version of the D2X rules:
    - If the player does not have the cannon, the cannon is picked up
      and removed from the mine.  The player takes as much of its
      ammunition as possible.  If the cannon was well stocked, and the
      player was nearly full, some ammunition will be lost.  This is
      unfortunate, but the game has always had this rule, and changing
      it would require dropping one or more Vulcan Ammo packs to
      represent the untaken ammunition.
    - If the player already had that cannon, then the player takes as
      much ammunition as the cannon has, while not exceeding the
      ammunition cap.  Other players, if any, are updated about how much
      ammunition remains in the cannon.  The cannon remains in the mine.
- Backport to D1X the network message for updating the contained
  ammunition in a vulcan cannon.  zico added the basic feature in
  7684ce92, but only applied it to D2X.  With the change to let D1X
  multiplayer take ammunition from the cannon, D1X now needs the same
  feature.
- Remove the special case to delete an empty cannon.  Instead, let the
  cannon remain in the mine without ammunition.  This allows a player in
  single player mode to leave behind a backup cannon, which could be
  useful if the player is killed and wishes to rearm before returning to
  the death site.  Similarly, under the new rule that players in
  multiplayer can drain the cannon down to 0 ammunition, this removal
  allows the cannon to remain behind for someone else to take, rather
  than allowing it to be deleted by a player who already had an instance
  of it.
2022-02-05 13:30:56 +00:00
Kp 636e1b6d5e Use enumerated_array for unique_side::uvls 2022-01-15 20:39:10 +00:00
Kp 075495aa8b Use enumerated_array for d_level_unique_automap_state::Automap_visited 2022-01-15 20:39:10 +00:00
Kp a7c9a04c20 Use enumerated_array for shared_segment::children 2022-01-15 20:39:10 +00:00
Kp dc2e86760e Use enumerated_array for Side_opposite 2022-01-15 20:39:10 +00:00
Kp 4a6a4c4646 Use enumerated_array for unique_segment::sides 2022-01-15 20:39:10 +00:00
Kp 1c57e1032d Use enumerated_array for shared_segment::sides 2022-01-15 20:39:10 +00:00
Kp 2659400a97 Use sidenum_t for trigger::side 2022-01-15 20:39:10 +00:00
Kp 2d890131fb Disable packing on old trigger structures
It is not necessary, and causes problems when trying to take a reference
to a member.
2022-01-09 15:25:42 +00:00
Kp f47a2c9f0d Convert Side_to_verts to enumerated_array<..., sidenum_t> 2022-01-09 15:25:42 +00:00
Kp c79df55d3e Return segment/side from med_find_closest_threshold_segment_side 2022-01-09 15:25:42 +00:00
Kp 53f098dc5e Return segment/side from med_find_adjacent_segment_side 2022-01-09 15:25:42 +00:00
Kp fbe3bbd0fa Use enum sidenum_t in more places 2022-01-09 15:25:42 +00:00
Kp fedb48613c Move object_rw to namespace dsx
It depends on types in dsx.
2022-01-09 15:25:42 +00:00
Kp 78d4a36bb4 Explicitly require support for C++11 constructor inheritance
Parts of the code already used the C++11 syntax, so compilers without it
were already unsupported.  Expand the remaining uses to the standard
syntax.
2022-01-09 15:25:42 +00:00
Kp d2478d0708 Require support for C++17 attribute [[fallthrough]] 2022-01-09 15:25:42 +00:00
Kp 0f53ce0f06 Factor out get_xrange_direction
clang chokes on use of a `constexpr bool` that is initialized separately
from its definition.  gcc allows this.  Move the value computation into
a constexpr helper function, so that the variable can be defined and
initialized in the same statement.
2022-01-09 15:25:42 +00:00
Kp 6cdc181218 Use enum class for segment_relative_vertnum 2022-01-09 15:25:42 +00:00
Kp 932419ff17 Combine Two_sides_to_edge, Edge_between_sides
These track the same data, but were static and defined separately.
Delete Edge_between_sides and redirect uses to Two_sides_to_edge.
2022-01-09 15:25:42 +00:00
Kp b8a8a61ff8 Simplify multiplayer powerup creation
Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
2022-01-09 15:25:42 +00:00
Kp 94cfeede5c Validate control center trigger sides on load 2022-01-09 15:25:42 +00:00
Kp 078a9affa0 Make MAX_SIDES_PER_SEGMENT an iterable range
Iterating over it returns each side number in turn.  This allows
converting many loops of the form:

```
	for (int i = 0; i < MAX_SIDES_PER_SEGMENT; ++i)
```

to the compact form:

```
	for (const auto i : MAX_SIDES_PER_SEGMENT)
```

The compact form brings the usual benefit of range-based for: delegating
iteration to the compiler prevents the loop body from skipping a step,
and makes clear in the code that this is the case.
2022-01-09 15:25:42 +00:00
Kp 3004dd16e5 Convert some bare integers to sidenum_t 2022-01-09 15:25:42 +00:00
Kp d6b4106d36 Tighten index handling for Ai_transition_table
Avoid undefined accesses when a robot has an invalid awareness type.
2022-01-08 17:48:09 +00:00
Kp 648bbac0b1 Convert ai_local::achieved_state to ai_static_state 2022-01-08 17:48:09 +00:00
Kp d1ac265c2c Convert ai_local::goal_state to ai_static_state 2022-01-08 17:48:09 +00:00
Kp 37f3c10dd4 Convert ai_static::CURRENT_STATE to ai_static_state 2022-01-08 17:48:09 +00:00
Kp c3937f391f Convert ai_static::GOAL_STATE to enum 2022-01-08 17:48:09 +00:00
Kp 9fdf6005df Convert ai_static::GOALSIDE to sidenum_t 2022-01-08 17:48:09 +00:00
Kp c6d98df9fb Move CURRENT_GUN out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 5128b84122 Move CURRENT_STATE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 39e9673f54 Move GOAL_STATE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp c10855939b Move PATH_DIR out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 1f00d716de Move SUBMODE/SUB_FLAGS out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp db90f0df62 Move GOALSIDE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp ae44e0226e Move CLOAKED out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp db7b528177 Move SKIP_AI_COUNT out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 197ed13d42 Move REMOTE_OWNER out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 7015e3e93c Move REMOTE_SLOT_NUM out of ai_static::flags
Some flags merit a type other than int8_t.  Begin moving flags out to
distinct variables with their own type.

Add static_assert checks that the ABI relevant structures do not change.
2022-01-08 17:48:09 +00:00
Kp b4341e69a5 Remove unnecessary definitions of get_static_size
These exist only to be declared, and never called.
2022-01-07 04:26:22 +00:00
Kp 941190ff32 Explicitly default d_fname copy constructor
clang warns that an implicit copy constructor is deprecated in the
presence of an explicitly defaulted copy-assignment operator.

Add an explicitly defaulted default constructor too, since the
explicitly defaulted copy constructor suppresses generation of an
implicit default constructor, and the default constructor is needed.
2022-01-07 04:26:22 +00:00
Kp 634d72760f Remove unused-but-set variable common/misc/hmp.cpp: d
Also delete a now useless loop, which existed solely to update the value
of `d`.
2022-01-07 04:26:22 +00:00
Kp 223c59c5d4 Inline out object_number_array
Its main purpose is to pre-initialize the underlying std::array.  This
can be done without a separate type.
2022-01-07 04:26:22 +00:00
Kp f84783b95d Use enum class for dlindexnum_t 2022-01-07 04:26:22 +00:00
Kreeblah 522acbf398
Updated enums and added define to silence deprecation warnings 2021-12-22 13:45:35 -08:00
Kp 14891bd5af Merge branch kreeblah/macos-sign-app into master
Requested-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/611>
2021-12-18 19:29:31 +00:00
Kp 411e113689 Show current zsh version if it is too low 2021-12-18 03:24:43 +00:00
Kp 4c2fdb7cd7 Use helper functions to always print script name on messages
For errors, also include the string `error: ` and redirect the text to
stderr.
2021-12-18 03:23:37 +00:00
Kp 58e15eaf5c Fix spelling errors in codesign comment 2021-12-18 03:22:51 +00:00
Kreeblah d39d043692
Switch password auth to use an environment variable, to avoid printing it in the SConstruct logs 2021-12-14 21:01:28 -08:00
Kreeblah 8fe7aab673
Add comments about how the notarization process works 2021-12-13 21:18:19 -08:00
Kreeblah 18d19dac16
Removed extraneous double quotes 2021-12-12 16:49:27 -08:00
Kreeblah 9115019fbe
Added comments to shell script 2021-12-12 16:38:53 -08:00
Kreeblah b696a63190
Updated to pass in binary name instead of using glob 2021-12-12 16:04:31 -08:00
Kreeblah f97d553013
Updated messages 2021-12-12 15:53:41 -08:00
Kreeblah 8d0aa0c6a8
Initial changes from feedback 2021-12-12 15:45:28 -08:00
Kreeblah 065ec3c4db
Remove unusd function 2021-12-11 16:01:47 -08:00
Kreeblah 0e735f2197
Added more status messages 2021-12-11 15:59:20 -08:00
Kreeblah 2c5e299140
Fixed message location 2021-12-11 15:56:59 -08:00
Kreeblah 4786427f79
Added signing/notarization script 2021-12-11 15:55:34 -08:00
Kp 328046d1ba Use xrange for texture merge loops 2021-12-01 03:15:21 +00:00
Kp b6a26ddc8c Fix high score background truncation
Commit 4d6affd74d ("Fix SDL-only briefing crash") added a hack to
prevent a crash when the briefing window is automatically resized.
However, a logic error in that hack causes some subcanvases that were
not wrong to be truncated.  Change the logic to fix those subcanvases,
such as the one used for rendering a background in the High Scores
window.  The new logic still avoids the crash in in SDL-only mode.

Fixes: 4d6affd74d ("Fix SDL-only briefing crash")
2021-12-01 03:08:27 +00:00
Kp f99ba91998 Pass user $PATH to Command() for dylibbundler
On some systems, such as the Apple M1 (ARM-based Macs),
dylibbundler is in $PATH, but not in a directory found by the limited
path that SCons uses for Command() invocations.  This causes the SConf
test to succeed (because it uses the full $PATH), but the Command() to
fail (because it uses a reduced path).  Fix this by using the user's
$PATH, if defined, for this Command() invocation.

Along the way, rework tool_bundle.py to use SCons' Node() objects in
place of direct path manipulation.  This lets SCons produce better error
messages in some cases.

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/pull/610>
2021-11-08 01:53:05 +00:00
Kp 2fbddf7a5a Use enum class for tmapinfo_flags 2021-11-01 03:37:20 +00:00
Kp 795b0e9111 Use enum class for station_number 2021-11-01 03:37:20 +00:00
Kp 3e02f99bcd Use enum class for materialization_center_number 2021-11-01 03:37:20 +00:00
Kp eea806bcc9 Pass underlying index_type through zip()
If std::common_type<range::index_type>... finds a common index_type
among all the zipped ranges, pass that common type through as
zip<...>::index_type.  Otherwise, set zip<...>::index_type to void.

This allows enumerate(zip(...))) to report a better index_type.
2021-11-01 03:37:20 +00:00
Kp 4d6affd74d Fix SDL-only briefing crash
Trim the bitmap's current width and height to be not more than its
parent.  Otherwise, an automatic screen resize, such as triggered when
playing the robot briefings in Descent 2, will give the window a new
smaller bm_data, but continue to use the old dimensions.  This then
causes load_briefing_screen -> gr_bitmap_scale_to -> scale_line to write
off the end of the smaller bm_data, causing memory corruption and
eventually a crash.
2021-11-01 03:37:20 +00:00
Kp 5eaa53d220 Fix SDL-only build 2021-11-01 03:37:20 +00:00
Kp 1596fad557 Change c_tmap_scanline_shaded argument to gr_fade_level 2021-11-01 03:37:20 +00:00
Kp 7ac96996d3 Change type of pixptr to const color_palette_index* 2021-11-01 03:37:20 +00:00
Kp 494ded9e04 Expand cur_tmap_ macros inline
These date to when there was a choice.  Now, there is no choice.  The
target functions are always in C.
2021-11-01 03:37:20 +00:00
Kp 29b619db99 Pass random generator to pick_random_point_in_seg 2021-11-01 03:37:20 +00:00
Kp 3da988708e Change Side_opposite value_type to sidenum_t 2021-11-01 03:37:20 +00:00
Kp 6467929025 Consolidate Side_to_verts and Side_to_verts_int
They have been the same variable since
a8c3a7f10b ("Alias Side_to_verts to
Side_to_verts_int").
2021-11-01 03:37:20 +00:00
Kp 9fc7a14777 Fix LTO build of Descent 2
enum game_mode_flags must be visible in common code, which does not
define DXX_BUILD_DESCENT_II.  To avoid One Definition Rule errors,
game_mode_flags must have the same definition in all files.
Fortunately, the DXX_BUILD_DESCENT_II definition is a superset of the
common definition, so the preprocessor guards can be replaced with
advisory comments.

Fixes: 2b718da343 ("Use enum class for Game_mode, Newdemo_game_mode")
2021-11-01 03:37:20 +00:00
Kp ba01b2bdc1 Convert some math functions to fixang
The value was always truncated internally anyway.  Move the truncation
to the call boundary, since most callers started with a fixang.
2021-11-01 03:37:20 +00:00
Kp 3862edfb6c Use enum class for segment_special 2021-11-01 03:37:19 +00:00
Kp 12a0f8e8e0 Use enum class for wall_state 2021-11-01 03:37:19 +00:00
Kp 76e2f2c6d9 Use enum class for wall_flags 2021-11-01 03:37:19 +00:00
Kp f64ed06a9d Use enum class for wall flag constants 2021-11-01 03:37:19 +00:00
Kp a6f2db2502 Use enum class for player ranking 2021-11-01 03:37:19 +00:00
Kp 8ddfbd17e0 Use enum class for show_kill_list_mode 2021-11-01 03:37:19 +00:00
Kp d22632ac48 Use enum class for msgsend_state 2021-11-01 03:37:19 +00:00
Kp 7cb34fda0c Use enum class for network_game_type 2021-11-01 03:37:19 +00:00
Kp eb7cedc35d Expand macro Current_mission_longname 2021-11-01 03:37:19 +00:00
Kp e69b7bd730 Expand macro Briefing_text_filename 2021-11-01 03:37:19 +00:00
Kp bcc8118dd5 Expand macro Ending_text_filename 2021-11-01 03:37:19 +00:00
Kp 3d878ce04d Expand macro Last_level 2021-11-01 03:37:19 +00:00
Kp e36c4a17ab Expand macro Last_secret_level 2021-11-01 03:37:19 +00:00
Kp 692c09bb7e Expand macro N_secret_levels 2021-11-01 03:37:19 +00:00
Kp 013ef0ded7 Expand macro Secret_level_table 2021-11-01 03:37:19 +00:00
Kp d10406c107 Expand macro Level_names 2021-11-01 03:37:19 +00:00
Kp 72cdb9b0cc Expand macro Secret_level_names 2021-11-01 03:37:19 +00:00
Kp c64d97307c Pass level counts to allocate_levels
Avoid reading them from a global.
2021-11-01 03:37:19 +00:00
Kp 0c34a48418 Move Last_level_path_created to LevelUniqueObjectState.Level_path_created
Change it from the level number on which the path was created to a
true/false flag.  The previous logic only tested whether the number was
equal to the current level number.

This also fixes a bug where the action was not available on the first
secret level, since that level is `-1`, and the value was set to `-1` to
indicate that it should be enabled.
2021-11-01 03:37:19 +00:00
Kp 0fcaa76fd1 Move Next_level_num to local scope
It does not need to be a global.  For each function that uses it, it is
assigned earlier in that same function.
2021-11-01 03:37:19 +00:00
Kp 1a44112907 Remove objnum_local_to_remote wrapper
Always use the form that returns both fields.
2021-11-01 03:37:19 +00:00
Kp 57780e0450 Move window_is_visible,window_set_visible to be window methods
Shrink w_visible to uint8_t.  Move it to pack better.
2021-11-01 03:37:18 +00:00
Kp 8eafbe6197 Shrink window::w_modal to uint8_t 2021-11-01 03:37:18 +00:00