Commit graph

2225 commits

Author SHA1 Message Date
Kp 962a37e75e Backport more ranges support for OS X clang
Apple clang is currently version 14, but Apple's libc++ is version 13,
and so lacks even more std::ranges support than previously reported.
Add more stub backports to work around this.
2022-11-06 18:18:57 +00:00
Kp 3d5de92058 Fix OS X clang build
OS X still uses clang-14, which lacks sufficient std::ranges support for
recent Rebirth changes.

- Rewrite uses of std::ranges::SYMBOL to ranges::SYMBOL
- Add a stub header that, on gcc, provides for each SYMBOL a statement
  `using std::ranges::SYMBOL;`, to delegate back to the standard library
  implementation.
- On clang, define a minimal implementation of the required symbols,
  without constraint enforcement.  Compile-testing with gcc will catch
  constraint violations.

Once OS X clang ships a standard library with the required features,
this stub header will be removed and the uses changed back to their full
names.
2022-10-31 00:51:32 +00:00
Kp 862c1f0aab Pass std::span to multi_process_bigdata 2022-10-23 23:00:24 +00:00
Kp f6c45d0f6f Use enum class for multiplayer_command_t 2022-10-23 23:00:24 +00:00
Kp 16698137ea Enable gcc attribute suggestion warnings
Adding `final` can allow gcc to devirtualize a call.  Request compiler
warnings wherever `final` would improve this.  As of this writing, there
are no places where `final` would be helpful and would also be wrong, so
this is enabled everywhere.
2022-10-16 23:20:34 +00:00
Kp 2dd538eb4d Add workaround for i686 where std::size_t is unsigned int
enumerated_bitset expects that typename `E` and `std::size_t` are
distinct types.  On some i686 targets, `std::size_t` is an alias for
`unsigned int`, so setting `E = uint32_t` causes `std::size_t` and `E`
to be the same type.

Add a workaround by using `unsigned int` or `unsigned long`, whichever
one `std::size_t` is not.  This will become unnecessary once
`playernum_t` becomes an `enum class`.

Reported-by: pkubaj <https://github.com/dxx-rebirth/dxx-rebirth/issues/662>
2022-10-09 23:15:21 +00:00
Kp a8ecc000bf Return sentinel from segment_object_range_t 2022-10-09 23:15:21 +00:00
Kp d9c06e25c5 Pass std::ranges::subrange to multi_execute_save_game 2022-10-09 23:15:21 +00:00
Kp 6ca3a1ba99 Define operator<=> for dl_index 2022-10-09 23:15:21 +00:00
Kp 90d3d82d8e Default disable VR side-by-side for OpenGL ES
VR requires glDrawBuffer, which Mesa OpenGL ES does not offer.  Default
VR to disabled for OpenGL ES users.  Users who want to try it anyway can
still set use_stereo_render=1 in the SCons environment.
2022-10-09 23:15:20 +00:00
Kp bb0711001f Make xrange_endpoint value mutable
The concept std::ranges::range<T> requires that std::ranges::end(T) be
well-formed.  An input with a `const` qualified member fails this test,
and causes std::ranges::range<T> to reject an otherwise satisfiable
range.
2022-10-09 23:15:20 +00:00
Kp bde7c9b3c4 Return sentinel type from enumerate::end() 2022-10-09 23:15:20 +00:00
Kp dded433d2b Return sentinel type from xrange::end() 2022-10-09 23:15:20 +00:00
Kp b5775f1680 Use std::ranges::begin/end for partial_range
Remove custom adl_begin and rely on std::ranges.
2022-10-09 23:15:20 +00:00
Kp 229766e9cb Use enum class for polygon_simpler_model_index
This type is stored with an off-by-one bias from the regular model
index, so use a distinct enum type to avoid implicit conversions.
2022-10-09 23:15:20 +00:00
Kp 43e1c841f0 Pass polymodel& to polymodel_read 2022-10-09 23:15:20 +00:00
Kp acae546a90 Pass polymodel& to draw_model_picture, draw_polygon_model 2022-10-09 23:15:20 +00:00
Kp 910ac7fd4a Use template alias for per-team arrays 2022-10-09 23:15:20 +00:00
Kp fcb6beb3e8 Add check that d_array<E> is not unsigned int or unsigned long
`std::size_t` is `unsigned int` on i686-pc-linux-gnu, but is `unsigned
long` on x86_64-pc-linux-gnu.  This mismatch allows d_array<E =
std::size_t> to be well-formed on x86_64, but trigger a duplicate
definition of operator[](E) on i686.  Add a requires() check that
forbids both types for E, so that code which would break the i686 build
is also diagnosed in the x86_64 build.
2022-10-09 23:15:20 +00:00
Kp f61db8ae7a Make enumerate() default to std::size_t for index_type
Change from `uint_fast32_t` to `std::size_t` for consistency with how
arrays are typically indexed.

Change the decltype() lookup to use a non-template function for the
fallback case.

Move the remove_reference logic into the caller, to allow fewer
instantiations of `array_index_type`.
2022-10-09 23:15:20 +00:00
Kp 9716d42ea0 Use enum class for pig_hamfile_version 2022-10-09 23:15:20 +00:00
Kp e385ff1c3b Use std::ranges::find_if instead of std::find_if
std::ranges::find_if permits use of a sentinel instead of a full
iterator, and supports std::ranges::find as an alternative to certain
simple uses of std::find_if.

Where possible, use the form that takes a range, rather than the form
that takes two iterators.

Add a declared, but not defined, default constructor for
self_return_iterator to satisfy the standard library's concept
`semiregular`, which insists that sentinels be default-constructible,
even for those functions that never need to do so.

Add a defined, but unused, operator++(postfix) for zip_iterator to
satisfy a standard library concept for `forward_iterator`.
2022-10-09 23:15:20 +00:00
Kp 7c0fb7b12a Use std::span for load_bitmap_replacements argument level_name 2022-10-09 23:15:20 +00:00
Kp 9c4c49fe5e Return std::unique_ptr from d_strdup 2022-10-09 23:15:20 +00:00
Kp 017e786139 Use explicitly defaulted font_scale_proportion::operator== 2022-10-09 23:15:19 +00:00
Kp 32e819a9e7 Remove unnecessary explicit definition of WALL_IS_DOORWAY_result_t::operator!= 2022-10-09 23:15:19 +00:00
Kp beb4cde9cb Remove definition of segment_object_range_t<T>::iterator::operator!= 2022-10-09 23:15:19 +00:00
Kp 49fccd64ad Use explicitly defaulted callsign_t::operator== 2022-10-09 23:15:19 +00:00
Kp 5d412f3c19 Remove unnecessary explicit definition of enumerated_iterator::operator!= 2022-10-09 23:15:19 +00:00
Kp c1a8a3b8e3 Explicitly default xrange_iterator::operator==
Replace operator!= with an implicitly defaulted definition, which will
use the new explicitly defaulted operator==.
2022-10-09 23:15:19 +00:00
Kp 01c07156bd Remove special case for 0 argument HUD_init_message
Fix the one remaining site that was redirected by this.  Remove the
redirection macro, so that the literal and variadic forms can have
differing types for their string field.
2022-10-02 19:51:36 +00:00
Kp aaac0e69fa Use std::span for piggy_new_pigfile argument pigname 2022-10-02 19:51:35 +00:00
Kp eca189e8aa Use enum class for SoundOffset
Change piggy_register_sound to take the sound offset as a parameter,
rather than assuming the caller will set SoundOffset accordingly.

Remove a spurious sound reset in piggy_register_bitmap.  Based on the
duplicated comment, this was probably incorrectly copied from
piggy_register_sound, where it made sense, into piggy_register_bitmap,
where it does not.
2022-10-02 19:51:35 +00:00
Kp 14bf2dc59a Pass std::span to piggy_register_bitmap 2022-10-02 19:51:35 +00:00
Kp f0d118ed42 Use std::span for PHYSFSX_fgets 2022-10-02 19:51:35 +00:00
Kp e3faab0899 Use alias template per_player_array for arrays that are MAX_PLAYERS long
This removes the need to repeat MAX_PLAYERS in every usage, and prepares
for a future change to use enumerated_array instead of std::array.
2022-09-24 17:47:53 +00:00
Kp 9d238eedf8 Pass std::span to callsign_t::copy 2022-09-24 17:47:53 +00:00
Kp 81b77d2f28 Pass std::span to create_bfs_list 2022-09-24 17:47:53 +00:00
Kp 294a78a1aa Pass std::span to powerup_basic_str 2022-09-24 17:47:53 +00:00
Kp 6d0a5f5783 Pass std::span to location_value_wrapper::prepare_buffer 2022-09-24 17:47:53 +00:00
Kp 56a68f3c63 Pass std::span to con_force_puts 2022-09-24 17:47:53 +00:00
Kp a76f5d9248 Use std::array for location_wrapper::scratch_buffer 2022-09-24 17:47:52 +00:00
Kp ae5e5c699a Use std::array for console_buffer::line 2022-09-24 17:47:52 +00:00
Kp b1da47a34b Compare d1 extra pig in place
Instead of creating a copy, modifying the copy, and comparing to it, use
std::span to pass down the maximum allowed length for comparison.
2022-09-24 17:47:52 +00:00
Kp ad7057be87 Add hack for case mismatch in Vertigo robot movies
PhysFS 3 is case-sensitive for movie filename lookup.  The consequence
of this was first reported in [1].  In [2], @icculus stated this was a
bug in PhysFS 3 that would be fixed in PhysFS 3.0.2.  However, [3] and
[4] assert that the fix was never included.  The existence of [5] seems
to support this.  The original problem was reported in 2019.  As of
2022, user @AlumiuN, running PhysFS 3.0.2, is affected.  Therefore, this
commit adds code to detect the relevant robot movies and adjust the case
in the Rebirth code.

[1]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379
[2]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-389400528
[3]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-462083489
[4]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-477790175
[5]: https://github.com/dxx-rebirth/dxx-rebirth/issues/644
2022-09-24 17:47:52 +00:00
Kp a79ed84112 Use std::span in location_wrapper 2022-09-24 17:47:52 +00:00
Kp 2ecad00e90 Pass std::span to load_palette 2022-09-24 17:47:52 +00:00
Kp 805d71de6b Move Shareware_level_names,Registered_level_names to dumpmine.cpp
They are only used in this file, so move them there and make them
static.
2022-09-24 17:47:52 +00:00
Kp 17a0452001 Use std::span for nm_item_input 2022-09-24 17:47:51 +00:00
Kp e0300e1e30 Pass std::span to dispatch_table::send_data 2022-09-24 17:47:51 +00:00