Commit graph

12100 commits

Author SHA1 Message Date
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 1365d0796c Use std::span for RunMovie argument subtitles 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 1bda6f4792 Remove dead declaration of g3_check_codes 2022-10-02 19:51:35 +00:00
Kp ad8f970bf6 Pass g3s_point & to free_temp_point
Only one point is freed at a time, so pass by reference.
2022-10-02 19:51:35 +00:00
Kp a8c4aee5f0 Fix compilation of valptridx unit tests
Newer gcc has become more effective at propagating values and now proves
that certain tests will always throw.  This proof triggers a
compile-time error, which is desirable in the main program, but not in
the unit test.  Add an indirection to hide the value from the compiler
so that it is forced to emit runtime code, which can then throw and
catch as intended.
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 98916ca6b7 Remove obsolete ntstring methods 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 53d81e78de Fix SDL2 double-free on failure to load music
Fixes: 0142c02edd ("Use Mix_LoadMUSType_RW for named files, too")
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
Kp e377ac3caf Pass std::span to convert_pattern_array 2022-09-24 17:47:53 +00:00
Kp 0cb9ab58b0 Pass std::span to print_pattern_array 2022-09-24 17:47:53 +00:00
Kp 6de5587a06 Pass std::span to nd_read_string 2022-09-24 17:47:53 +00:00
Kp f91d0c404c Pass std::span to set_briefing_filename 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 8811836e2e Make cstring_tie inherit from array
Switch to `using` the `begin` method instead of defining a wrapper.
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 1b170fe880 Pass std::span to print_exit_message 2022-09-24 17:47:53 +00:00
Kp ea5d0136dc Pass std::span to msgbox_warning 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 27ec8f41ba Pass std::span to con_add_buffer_line 2022-09-24 17:47:52 +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 23315ebec2 Fix SDL-only g3_draw_sphere overflow test
PF_OVERFLOW is part of p3_flags, not p3_codes.  Testing p3_codes meant
that the disk would be drawn when CC_OFF_RIGHT was unset.  This seems
unlikely to be what was intended, so fix the mismatch by switching to
use p3_flags instead of switching the symbolic constant.
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 c464ddeae1 Sanitize control center triggers on load
Descent 2: Vertigo level 10 has invalid data in its control center
triggers.  Sanitize invalid data at load to avoid problems in
memory-poisoning builds.
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 9fa97573c4 Move RoboFile to briefing scope 2022-09-24 17:47:52 +00:00
Kp 00c428b4fc Use compiler std::endian instead of union-based punning 2022-09-24 17:47:52 +00:00
Kp af8efbf830 Clear GameSounds, SoundOffset in bulk 2022-09-24 17:47:52 +00:00
Kp 9cad6c0eaa Use std::span for sound_slot samples 2022-09-24 17:47:52 +00:00
Kp ceef174418 Cache strlen call result 2022-09-24 17:47:52 +00:00
Kp f175a4508b Pass std::span to ogl_extensions is_ext_supported
This avoids the need to recompute the string's length later.
2022-09-24 17:47:52 +00:00
Kp 5eb41816f3 Use std::span for CREDITS_FILE 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 e4e8259253 Reduce scope of callback_handler newpath
If select_file_recursive is not called again, then the handler returns
without reading newpath.  Skip defining it if it will not be read.
2022-09-24 17:47:52 +00:00