Commit graph

11853 commits

Author SHA1 Message Date
Kp af05991821 Simplify thief retry loop
Instead of forcing one call, then conditionally doing 3 more, make the
loop run for 4 passes, and make the call after the conditional exit,
instead of before.
2022-07-09 13:39:29 +00:00
Kp 37132ab887 Pass LevelSharedRobotInfoState in fvi_query 2022-07-09 13:39:29 +00:00
Kp fac016c104 Split object_create_explosion_sub for with/without damage cases
Some callers create an explosion with damage forced to zero.  Others
create an explosion with damage non-zero.  Only the non-zero case needs
to examine nearby objects.  Split object_create_explosion_sub so that
the zero-damage case can skip that logic, and the arguments required to
implement it.
2022-07-09 13:39:29 +00:00
Kp e5425a00f3 Use forward-declaration header for robot.h 2022-07-09 13:39:29 +00:00
Kp d6c43f56af Use enum class for gun_num_t 2022-07-09 13:39:29 +00:00
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 5d62df856d Pass fvi_query to fvi_sub
Many of the input parameters are available in fvi_query, so pass a
reference to that instead of copying the parameters to the stack
individually.
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 4ef75b2aed Pass state to do_endlevel_flythrough 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 192c5de4f1 Add compile-time option to disable ship wiggling
Ship wiggle is normally enabled for compatibility with the original
game.  However, during development, it can become a nuisance, so add an
option to allow disabling it.
2022-07-02 18:10:45 +00:00
Kp e80c6fb05f Rename font underline to draw_full_width_as_fg_color
This started out as underline, but one of the special drawing modes uses
it to draw an underline-width block across the entire vertical height of
the character.
2022-07-02 18:10:45 +00:00
Kp 55af651200 Pass d_level_unique_object_state context to create_omega_blobs 2022-07-02 18:10:45 +00:00
Kp a40ab08bd0 Remove write-only field fcd_data::csd
This value was written when cache entries were created, but is never
read back.
2022-07-02 18:10:45 +00:00
Kp 3230b23bb9 Rework find_connected_distance cache
- Inline MAX_FCD_CACHE into the definition of Fcd_cache, then rely on
  Fcd_cache.size() later.
- Make Fcd_index unsigned.  As an index, a negative number is invalid.
- Change flush_fcd_cache to update Last_fcd_flush_time, rather than
  requiring callers to do it.  Most callers did not update this.
- Change add_to_fcd_cache to validate and reset Fcd_index before use,
  rather than resetting after increment.  This allows Fcd_index to
  become invalid after a write, but it will be reset to a valid value
  before it is used again.
- Fix original game bug in add_to_fcd_cache that caused the cache
  expiration path to clear the wrong cache entry.
2022-07-02 18:10:45 +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 e51c11587b Change multi_do_kill to skip copying MULTI_KILL_CLIENT opcode
The opcode will be set to MULTI_KILL_HOST before sending, so do not set
it to MULTI_KILL_CLIENT initially.
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 aee963c015 Switch dialect to C++20
Future commits will introduce tests for and uses of C++20 features.
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
Kp d586fe91e4 Parenthesize gauge_key comma expression
C++20 deprecates `array_name[A,B]`.  For this use case, `A` is needed
for its side effects, but is not intended as an index operation.  Add
parentheses to satisfy the deprecation warning, without changing the
meaning of the code.
2022-07-02 18:10:45 +00:00
Kp 78fd6550ea Avoid unnecessary allocation in jukebox_play
If the song originates in an m3u playlist, no temporary buffer is
needed.  Avoid allocating and initializing one, and instead pass the
pointer directly from the CMLevelMusicPath field.
2022-07-02 18:10:45 +00:00
Kp 173d5559d7 Tighten TGA generation code
- Skip reading unused alpha channel in TGA screenshot path.  The alpha
  channel is discarded, so skip even retrieving it from OpenGL.
- Perform the red/blue swap in place, instead of copying into an
  additional buffer.
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 d1ed53ebd9 Initialize IPv4/IPv6 broadcast addresses statically
These were computed by passing hardcoded inputs to a lookup function.
Initialize the structure at compile time instead.
2022-06-19 23:35:18 +00:00
Kp d1968fce82 Move num_active_udp_changed into netgame_list_game_menu 2022-06-19 23:35:18 +00:00
Kp 27f18be3ca Move num_active_udp_games into netgame_list_game_menu 2022-06-19 23:35:18 +00: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 1f263e30ae Update minimum supported tool versions in INSTALL.markdown 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
Arne de Bruijn 0a5ecd77c6 Fix exit briefing animation speed
Undo change in e973dc0 which set the change animation direction delay
for every frame.
2022-06-06 10:15:27 +02:00
Kp 5545b32fee Do not reset_rear_view if dead when crossing exit trigger
Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/637>
Fixes: 8faed77f5f ("Properly record the event of reset_rear_view() while switching levels to make it work right when rewinding as well; Properly record Countdown seconds for each newdemo frame instead of second change to get display showing up right while playback and still preserving backwards compability; Suspend Game_wind when playing endlevel movie while demo playback")
2022-06-05 17:44:53 +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 68453cd86f Remove redundant net_udp_welcome_player checks
This loop is run once before the `if()` test, then again at the top of
both the true and false branches of the `if`.  Remove the runs inside
the conditional, since they should produce the same result as the run
that occurs before the conditional.
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 e66da397a5 Add dummy 'file' key to executable entry in compilation database
clang rejects the entire database if any entry lacks a 'file' key,
regardless of whether the entry is used.

Fixes: bc6d043f5d ("Extend SConstruct compilation_database support to cover Program()")
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 0faa33d3df Harden bm_read_player_ship against invalid model numbers
Eliminate an unnecessary internal copy.  Terminate the search early if
an invalid model number is used.
2022-06-05 17:44:53 +00:00