Commit graph

6248 commits

Author SHA1 Message Date
Kp 57de180a2e Pass std::ranges::subrange to PHYSFSX_checkMatchingExtension 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 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 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 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 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 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 fbc184500d Use explicitly defaulted operator== for vms_vector 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 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 cd3c88f4b6 Avoid copying level filename unnecessarily 2022-10-09 23:15:19 +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 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
Kp 90879d0796 Pass std::span to con_scrub_markup 2022-10-02 19:51:36 +00:00
Kp 3379078f04 Pass std::span to PHYSFSX_puts 2022-10-02 19:51:36 +00:00
Kp f3fae646f9 Pass std::span to warning_puts 2022-10-02 19:51:36 +00:00
Kp 53c1550254 Remove special case for 0 argument err_printf
Fix the remaining sites that were redirected by this.  Remove the
redirection macro.
2022-10-02 19:51:36 +00:00
Kp 0409e75278 Pass std::span to err_puts 2022-10-02 19:51:36 +00:00
Kp e0123dead5 Remove special case for 0 argument PHYSFSX_printf
Fix the remaining sites that were redirected by this.  Remove the
redirection macro.
2022-10-02 19:51:36 +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 f3d4dff941 Use enum class for clipping_code
Adjust code_window_point to use the same masks as clipping_code.
Previously, it had top and bottom swapped.  However, since its output
was only ever compared for equality to 0, this transposition should not
affect the observable behavior.
2022-10-02 19:51:35 +00:00
Kp 1808b6badd Use enum class for projection_flag 2022-10-02 19:51:35 +00:00
Kp e499dd55f7 Use std::span for piggy_write_pigfile argument filename 2022-10-02 19:51:35 +00:00
Kp aaac0e69fa Use std::span for piggy_new_pigfile argument pigname 2022-10-02 19:51:35 +00:00
Kp 1101b02f84 Use std::span for PlayMovie argument subtitles 2022-10-02 19:51:35 +00:00
Kp 73bcfb6d63 Simplify ogl_ubitblt_i GL array initialization
- Avoid zero-filling arrays that can be directly initialized with real
  values.
- Hold color_array const so it can be stored statically.
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 8fe9b8322d Check return value of PHYSFSX_fgets 2022-10-02 19:51:35 +00:00
Kp a55579bb8f Flatten net_udp call chain for ntstring::copy_out 2022-10-02 19:51:35 +00:00
Kp 9fe23b7dce Rework loading weapon reorder values
- Document the logic for resetting the values to default
- For D1: load the untrusted values directly into an array, instead of
  loading them to temporaries and then copying the temporaries to the
  array.
- For D2: optimize the read by loading 22 bytes in a single step,
  instead of loading single bytes 22 times.
2022-10-02 19:51:35 +00:00
Kp 4fe8d6dcaf Use std::span for net_udp_prepare_*_game_info 2022-10-02 19:51:35 +00:00
Kp 8c08dcc20f Merge branch 'refs/pull/633/head' into master 2022-10-02 19:50:49 +00:00
Kp 9a8c49ccbf Fix OpenGL ES build on SDL1
The preceding commit breaks OpenGLES + SDL1 support, by referencing
SDL_GL_* constants that are new in SDL2.  Add a preprocessor guard to
skip over the new constants when using SDL1.

Fixes: c90ac3e611 ("Fix OpenGL ES build on SDL2.")
2022-10-02 19:50:32 +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 0ed90715b6 Cache operator[] result in render_compare_context_t 2022-09-24 17:47:53 +00:00