Most callers do not need it, and it is only vaguely related to the
purpose of measuring a particular string. For those callers that need
it, lift it out.
Some targets only ever use GUI warn functions. On those targets:
- initialize `warn_func` to `msgbox_warning` at compile time
- remove the runtime initialize of warn_func in main
On targets which do not call `clear_warn_func`, preprocess out its
declaration and definition.
Taken together, these changes allow some targets not to define
`warn_printf`.
When partial_range is used on a container that defines index_type,
define that same index_type on the partial_range. This allows other
callers, such as enumerate(), to maintain the correct index type.
All the affected symbols are templates, so duplicate instantiations will
not cause duplicate definition errors. Removing the anonymous namespace
wrapper will allow equivalent definitions from different source files to
be folded together, reducing the size of the executable.
Push the computation up, so that invocations that differ only in the
length of their expression strings will resolve to the same template.
Rework unchecked_partial_range not to take expression strings if they
will not be used.
- UO -> index_begin_type
- o -> index_begin
- UL -> index_end_type
- l -> index_end
- I -> range_exception
The original names were picked because `l` was the length of the
subrange. Rename these to more closely follow STL's begin/end
nomenclature.
`I` was used variously for an iterator type and for the exception type
thrown on error. Rename the latter to be descriptive.
gr_find_closest_color did not need it. Remove it. For the others,
resetting the count is sufficient. There is no need to reset the
individual elements.
Add a helper to deduce the enum type of a value, and use an appropriate
std::underlying_type<T> expression for that enum type. This avoids the
need to repeat the type of the enum at the site of each cast, and moves
the casts into the helper to make the callers easier to read.
In gcc-7, expressions on the false path of `if constexpr` are deleted
before they are considered "used", so a variable that is only used on a
deleted path is reported as an unused variable. Add an alternate path
that casts the variable to void so that it is always used.
Prior to this, an xrange always started at the begin term and
incremented by 1 per step until it reached the end term. There was no
support for a step size other than 1. Add support for custom step size.
It is the caller's responsibility to pick a step size that will
eventually lead to (iter != end) evaluating to false.
Add RAII wrappers for unmounting PHYSFS paths. Use them in places that
previously handled unmounting explicitly. Also, use it for descent.hog
/ descent2.hog, which previously were left mounted indefinitely.
Some callers will need access to the computed path. Change the callers
to pass in a buffer for this path, and have PHYSFSX_addRelToSearchPath
fill that buffer directly.
gr_init_bitmap can be passed a pointer to uninitialized memory, and
will save that pointer into the bitmap for the underlying memory to be
initialized later. In gcc-11, this triggers a warning because the
`const` qualifier leads gcc to expect that the memory will only be read
(while uninitialized) and not written.
Reported-by: TheDemonicSurfer <https://github.com/dxx-rebirth/dxx-rebirth/issues/593>
OGL layer used for rendering surfaces, so using left/right viewports absent stereo quad buffers.
Using legacy Descent +/- eye offset method for left/right stereo perspective rendering passes.
These are not necessary for proper compilation, but are included so that
a mismatch between the forward declaration and the definition will be
diagnosed immediately.
PHYSFSX_isNewPath retrieves from PhysFS a list of all paths, then
searches them, and frees them at the end. PhysFS can search its own
list without needing the allocations, so delegate the work to it.
Previously, if the background failed to load, the kmatrix window was
immediately aborted. Change the logic so that a failure to load uses a
blank black background, but still shows the kmatrix window.
Once the loop has determined a vertex is used at least twice, there is
no need to count how many more times it is used. Return immediately
after detecting the second use.
- Make it static
- Remove the update of Num_vertices, since the caller reverses that
update.
- Remove the reversal, since it is no longer needed.
- Remove the test and update of Vertices.count, because the caller
always passes a vertex number that makes the test false.
Every user now uses inheritance and a virtual function override. Make
callback_handler pure virtual, delete its body, and then delete the
member variables that existed only for use in that body. Remove the
constructor parameters that initialized those variables, and update all
derived classes accordingly.
The requirement to call send_creation_events from outside the
constructor makes the presence of a helper function convenient. Rename
ui_create_dialog to window_create, and move it to window.h.
For gcc bug #10138 [1], gcc-11 gained a new way to show a
-Wmaybe-uninitialized warning. When an uninitialized array is passed by
`const T *` to a function, gcc-11 assumes the array is an input to the
function, and warns accordingly. This is often useful, but is incorrect
for the Rebirth partial_range code. In this code, the pointer is only
passed so that the eventual exception can print the memory address of
the affected array. The called function does not dereference the
pointer, and so cannot be influenced by any uninitialized values in the
underlying array.
Change the report function to take the array address in a `uintptr_t`,
and cast it back for printing. This silences the gcc-11 warning, while
preserving the previous semantics in the code.
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10138
clang warns if all of:
- type T is deleted by a pointer T*
- T has a non-virtual destructor
- T has a virtual function
- T is not final
Fix the build by making the relevant types T final, since nothing
inherited from them.