Commit Graph

12210 Commits

Author SHA1 Message Date
Kp dac2fa22d7 Use std::ranges::subrange for choose_drop_segment
The full functionality of partial_range is not necessary.
2022-10-09 23:15:20 +00:00
Kp b16c5f7a7c Use std::ranges::subrange for sort_seg_children
The full functionality of partial_range is not necessary.
2022-10-09 23:15:20 +00:00
Kp 1f8a54a334 Define cstring_tie::end()
std::ranges::range<T> requires that T provide a reasonable `end()`.
cstring_tie did not provide one since it uses private inheritance of
`std::array`.  However, it can provide a reasonable one, so define that
here.
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 921a17ebce Use requires() expression for partial_range range_index_type()
A requires() expression is easier to read than the corresponding
template parameter expression.
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 22abc6d4d8 Assert size of serialized weapon_info structure
These are read from a packed binary file shipped with the game, so their
size must not change.  If the size does change, later fields will be
loaded from the wrong offset, causing the in-memory values to be
incorrect.
2022-10-09 23:15:20 +00:00
Kp d5d103bc93 Simplify bm_read_weapon last_model_num handling
The existing handling always wrote to slot 0, but did so in a convoluted
way.  The variable names suggest this was not intended, but no one has
ever reported it as broken, and some otherwise valid data files may
depend on this quirk.
2022-10-09 23:15:20 +00:00
Kp 6ecbd6533a Simplify bm_read_robot last_model_num handling
The existing handling always wrote to slot 0, but did so in a convoluted
way.  The variable names suggest this was not intended, but no one has
ever reported it as broken, and some otherwise valid data files may
depend on this quirk.
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 f754b2d33a Avoid unnecessarily copying player name for display
If the player's name is presented without decoration, then it can be
rendered directly from the callsign buffer.  It only needs to be copied
to a temporary buffer if it will be decorated to reflect use of automap
or in-game messaging.
2022-10-09 23:15:20 +00:00
Kp 0ebcc64ac5 Test whether change_filename_extension succeeded before using its output 2022-10-09 23:15:20 +00:00
Kp b0ebe3b82c Tighten change_filename_extension handling of overflow 2022-10-09 23:15:20 +00:00
Kp a9142bb65a Use std::span for change_filename_extension arguments 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 1d475d106c Use std::span for init_subtitles argument `filename` 2022-10-09 23:15:20 +00:00
Kp 38adcc7729 Simplify change_filename_extension
The called function skipped over a leading dot in the extension.  Remove
that logic and change all callers not to supply a leading dot.
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 d74dbeb79d Add constexpr to SConf operator== test
This allows using static_assert instead of a runtime comparison.
2022-10-09 23:15:20 +00:00
Kp fbc184500d Use explicitly defaulted operator== for vms_vector 2022-10-09 23:15:19 +00:00
Kp 017e786139 Use explicitly defaulted font_scale_proportion::operator== 2022-10-09 23:15:19 +00:00
Kp c638a1f237 Make valptridx comparison operators constexpr 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 37701cf61f Remove unnecessary explicit definition of weapon_index::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 1a42696a2b Remove unnecessary explicit definition of valptridx<T>::ptridx::operator!= 2022-10-09 23:15:19 +00:00
Kp a4fe31c972 Remove unnecessary explicit definition of valptridx<T>::idx::operator!= 2022-10-09 23:15:19 +00:00
Kp f40b7ba315 Use explicitly defaulted rgb_t::operator== 2022-10-09 23:15:19 +00:00
Kp dd1aed76c5 Remove unnecessary explicit definition of null_sentinel_iterator::operator!= 2022-10-09 23:15:19 +00:00
Kp d443151f84 Remove unnecessary explicit definition of ntstring::operator!= 2022-10-09 23:15:19 +00:00
Kp 4279e56948 Remove unnecessary explicit definition of screen_mode::operator!= 2022-10-09 23:15:19 +00:00
Kp 0b62b62619 Remove unnecessary explicit definition of tmap_drawer_type::operator!= 2022-10-09 23:15:19 +00:00
Kp 428fad33c3 Fix clang-14 operator== ambiguity
clang-14 fails with:

```
similar/main/net_udp.cpp:4381:11: error: use of overloaded operator '!=' is ambiguous (with operand types 'exact_type<dcx::player>' and 'exact_type<const dcx::player>')
            if (&i != &self)
                ~~ ^  ~~~~~
common/include/pack.h:28:17: note: candidate function
    constexpr bool operator==(const T *rhs) const { return p == rhs; }
                   ^
common/include/pack.h:28:17: note: candidate function (with reversed parameter order)
1 error generated.
```

gcc handles the old form without error.
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 cd3c88f4b6 Avoid copying level filename unnecessarily 2022-10-09 23:15:19 +00:00
Kp d84de58d9b Add more special handling for Haiku OS
Haiku does not accept `-pthread`, and puts its network functions in a
separate library.  Add a special HaikuPlatformSettings to handle these
quirks.

Reported-by: LambdaCalculus37 <https://github.com/dxx-rebirth/dxx-rebirth/issues/641>
2022-10-02 19:51:36 +00:00
Kp fc4157f56f Fix MacOS clang build of similar/2d/font.cpp
clang-14 on OSX, but not clang-14 on x86_64-pc-linux-gnu, fails
class template argument deduction when given:

```
	char *c1 = initializer();
	const char *c2 = c1 + 1;
	std::span{c1, c2};
```

clang correctly refuses to match this to `std::span(pointer, pointer)`,
but fails to find the constructor `std::span(iterator, sentinel)`.

Work around this by changing the type of the sentinel from
`const uint8_t *` to `color_palette_index *` (an alias of `uint8_t *`).

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/664>
2022-10-02 19:51:36 +00:00
Kp f5258f95b1 Simplify partial_range check_range_index_type_vs_provided_index_type 2022-10-02 19:51:36 +00:00
Kp 5b7fb9c402 Reduce use of quotes for passing vers_id defines
Windows shells interpret quoting differently from Linux shells, causing
some of the generated strings to have ugly escape sequences in them.
Switch to passing the defined values as lists of character codes, so
that no quoting is needed.  This makes the command line uglier, but
produces more readable strings in the generated program.
2022-10-02 19:51:36 +00:00