Commit graph

1674 commits

Author SHA1 Message Date
Kp f0f669e8ab Use sentinel for null_sentinel_iterator end() 2023-02-04 19:21:25 +00:00
Kp 3aef1ee569 Tighten PHYSFSX_counted_list_template reset rules
Prefer move-assignment over use of reset() so that the count cannot go
out of sync from the list.

Shorten lifetime of some lists.
2023-02-04 19:21:25 +00:00
Kp 0d97683cee Construct PHYSFSX_counted_list with the correct count
Remove the method for adjusting the count later, and instead store the
list in a PHYSFSX_uncounted_list until the count is available, then move
it into the PHYSFSX_counted_list along with the count.  This prevents
using a list with its count unset.
2023-02-04 19:21:25 +00:00
Kp a582b4ee82 Remove write-only g3d_interp_outline 2023-02-04 19:21:25 +00:00
Kp c5d15d5c6e Inline the single use of MAX_POLYGON_VECS 2023-01-29 20:42:03 +00:00
Kp bf7ba07e1f Use smallest viable size in valptridx::array_base_count_type 2023-01-29 20:42:03 +00:00
Kp 407ab585a8 Move window existence flag to a mixin, and track using std::shared_ptr
gcc-12 does enough escape analysis to notice that
newmenu::process_until_closed stores the address of a stack local into a
heap-allocated structure, but not enough analysis to notice that the
stack variable always outlives the escaped address.  The compiler then
warns about the address escaping the local scope.  Reworking the calling
code not to do this is somewhat invasive, and gcc seems unlikely to
change behavior.  Switch to a less efficient implementation that does
not provoke a compiler warning:

- Store a shared_ptr<bool> in the object
- In the object's destructor, write through the pointer to clear the
  shared boolean
- In the caller, store a copy of the shared_ptr<bool> as a local, and
  use that copy to monitor the shared boolean

This is similar to a change proposed by JoeNotCharles
<10a2b2d337>,
but differs in its details.  Among other things, this version takes the
opportunity to move the variable out to a mixin, so that only windows
which expect to be tracked can be tracked.  Previously, all windows were
capable of this, even though most never needed it.
2023-01-14 19:05:37 +00:00
Kp 3f1aa85ad6 Make partial_range_t inherit from ranges::subrange
Delegate work to the standard library where possible.
2023-01-14 19:05:37 +00:00
Kp 704bde86bd Move SysNoHogDir to CGameArg
Move DXX_USE_SHAREPATH definition to apply to common files too, since
common files see CGameArg.
2023-01-07 22:17:31 +00:00
Kp 5ce4d49004 Use enum class for sound_sample_rate 2023-01-07 22:17:31 +00:00
Kp b5a609868e Remove inline stub for swap_polygon_model_data
All callers are either in `#if DXX_WORDS_BIGENDIAN` or in
`if constexpr (words_bigendian)`, so there are no callers that use the
`static inline` stub.
2023-01-07 22:17:31 +00:00
Kp 4071cd0cbf Replace range_owns_iterated_storage with ranges::borrowed_range
The standard type imposes some additional requirements that are not
necessary here, but using this concept allows standard containers to be
classified correctly without specific overrides.
2022-12-31 16:21:47 +00:00
Kp e41e72c667 Use #if for DXX_HAVE_CXX_BUILTIN_FILE_LINE 2022-12-18 23:10:39 +00:00
Kp ae4b3b4c87 Make window_send_event a method of window
Switch from using a macro to capture __FILE__,__LINE__ to using
__builtin_FILE(),__builtin_LINE().  Make the event an explicit argument,
instead of assuming it is a variable named `event`.  Move the
implementation out of line.
2022-12-18 23:10:39 +00:00
Kp 4257391a47 Use enum class for polygon_model_index 2022-12-18 18:32:14 +00:00
Kp 3f65ae0ca3 Replace PHYSFSX_read* macros with a template function object
This produces better error messages on misuse.
2022-12-17 13:16:28 +00:00
Kp 5f39ffc2f5 Use enum class for sound_channel 2022-12-17 13:16:28 +00:00
Kp 0c8ab5d70d Remove unnecessary explicit definition of valptridx<T>::ptr::operator!= 2022-12-10 18:09:54 +00:00
Kp 8decd6ec99 Simplify DXX_ALWAYS_ERROR_FUNCTION
Since this should never be invoked, simplify the definition.  The new
version is slightly less informative in case a logic error causes it to
be called, but is far shorter and easier to understand.
2022-12-10 18:09:54 +00:00
Kp ca1e3b1540 Remove unnecessary definition of exact_type<T>::operator!= 2022-11-13 21:17:23 +00:00
Kp 1cb33638c0 Fix -Wuseless-cast on Win32 in PhysFS size checking macro
Win32 aliases `size_t` to `unsigned int`, causing
`static_cast<size_t>(V)` to be a useless cast when `V` has type
`unsigned int`.  Switch to using direct initialization, which is not a
cast and so does not trigger a warning, but does produce the correct
type.  This form disallows narrowing, so inputs that might change in
value as a result of the conversion are an error.  Since this is a
sanity checking macro, that is a useful safety measure.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/678#issue-1437577368>
2022-11-10 02:04:09 +00:00
Kp 562fee9d09 Use #if for DXX_HAVE_CXX_BUILTIN_FILE_LINE 2022-11-10 02:04:09 +00:00
Kp 7effca68f0 Use RAII_SDL_Surface to track SDL-only main canvas surface
The Rebirth main screen grd_curscreen borrows the memory allocated by
SDL_CreateRGBSurface to store its data.  Store the pointer to that
surface inside grd_curscreen and make grd_curscreen responsible for
freeing the surface.
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 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 5fea863a79 Remove obsolete reverse_traversal helper
This is unused as of bd739041f8.

Fixes: bd739041f8 ("Remove special case for SP homing missiles")
2022-10-09 23:15:21 +00:00
Kp 515e0abe11 Pass std::ranges::subrange to PHYSFSX_findFiles 2022-10-09 23:15:21 +00:00
Kp 2c7ed3cfce Pass std::ranges::subrange to PHYSFSX_findabsoluteFiles 2022-10-09 23:15:21 +00:00
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 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 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 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 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 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 c638a1f237 Make valptridx comparison operators constexpr 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 f5258f95b1 Simplify partial_range check_range_index_type_vs_provided_index_type 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 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