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.
gcc reports:
```
ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second
```
Fix the ambiguity by using an unsigned integer constant.
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`.
Introduce a helper to obtain both the magnitude of a vector and the
corresponding normalized vector. Use it to capture both values as const
when possible.
Instead of forcing one call, then conditionally doing 3 more, make the
loop run for 4 passes, and make the call after the conditional exit,
instead of before.
splitpath_t is designed for MS-DOS paths, even though Rebirth now runs
on many platforms that never used DOS conventions. Most of the members
of splitpath_t are unused on all platforms. Remove them, and switch to
returning an initialized version of the structure.
Players are not robots, but the show-path cheat tried to pretend they
are, and triggered a BUG warning[1] when looking up robot information
from the player object. Fix this by passing in the robot_info when the
caller is providing a robot, and a named `nullptr` value (as
`create_path_unused_robot_info`) when the caller is providing a
non-robot object.
[1] As below, but repeated many times
```
similar/main/ai.cpp:1905: BUG: object 0x555555858550 has type 4, expected 2
similar/main/ai.cpp:1974: BUG: object 0x555555858550 has type 4, expected 2
```
attempt_to_steal_item_3 always fails if the thief is not in
AIM_THIEF_ATTACK mode. The caller will call attempt_to_steal_item_3
repeatedly in some cases, but the mode does not change during the calls,
so if one fails for this reason, then all will fail for this reason.
Lift the check into the caller so that the loop of repeated calls can be
skipped if the mode check fails.
Use `object &` instead of `vmobjptr_t`. This should generate equivalent
code, but produce smaller debug information and may require less
inlining by the compiler.
If exactly one object will always be needed, use an overload that
returns the object id. Otherwise, use an overload that only returns
whether at least one object was created. This simplifies callers that
always request exactly one object.
Iterating over it returns each side number in turn. This allows
converting many loops of the form:
```
for (int i = 0; i < MAX_SIDES_PER_SEGMENT; ++i)
```
to the compact form:
```
for (const auto i : MAX_SIDES_PER_SEGMENT)
```
The compact form brings the usual benefit of range-based for: delegating
iteration to the compiler prevents the loop body from skipping a step,
and makes clear in the code that this is the case.
Previously, the guidebot menu was given the full screen dimensions and
drew on only part of them, allowing the rest of the screen to be visible
due to not repainting it. Change to make the escort_menu window the
size that the user sees.
Commit d0d7545ec1 ("Unload robot movies on exit") intended to shorten
the lifetime of the loaded data, but failed to save the unique_ptr, so
the lifetime was shortened more than intended. Save the unique_ptr so
that the movies remain loaded.
Also, add a [[nodiscard]] annotation so that the compiler can warn if
this mistake is repeated.
Reported-by: Q3BFG10K <https://github.com/dxx-rebirth/dxx-rebirth/issues/599>
Fixes: d0d7545ec1 ("Unload robot movies on exit")