PHYSFS_init is not guaranteed to succeed. Using PHYSFS functions after
PHYSFS_init fails is likely to fail badly. On Windows, failure may take
the form of a crash in ntdll. Avoid this by exiting gracefully.
Creating an attribute on UserBuildSettings during SConf breaks
clean/help, which do not run configure tests. Remove that and add a
method to return the value the attribute would have had.
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/412>
Fixes: 1be414217c ("Add build time flag to choose whether to enable ADL MIDI support")
User jammer1 reports that Python under MSYS2[1] reports a `sys.platform`
of `msys`. For the limited purposes Rebirth requires, this platform can
be treated as if it were `win32`. Add a mapping to apply this change
automatically, so that users do not need to set it on the command line.
Reported-by: jammer1 <https://github.com/dxx-rebirth/dxx-rebirth/issues/405>
[1]: http://www.msys2.org/
enable_build_failure_summary=1 assumed that the command to display was a
list. For internal pseudo-commands, such as write_pch_inclusion_file,
the command was a string, so calling ' '.join() was incorrect. When the
output is not a list, pass it through unchanged.
Add macro cf_assert ("control flow" assert) to hint to gcc that certain
conditions are impossible. Use it to avoid generating range checks for
situations that never happen. If the event did happen, the only
consequence would be truncated UI text, rather than a correctness
problem.
The prior design was meant to allow the hook to be called instead of the
normal function, with the hook chaining to the normal function and then
performing other work as needed. This flexibility is unnecessary, and
complicates improvements elsewhere. Replace it with a hook that is
called with the result of the regular StaticObject call.
Use of the comprehensions makes the code less readable and harder to
modify. The performance benefit, if any, is in the noise. Switch to
an unpacked form.
This commit enables Rebirth to build with SDL2, but the result is not
perfect.
- SDL2 removed some sticky key support. Rebirth may behave differently
now in this area.
- SDL2 removed some key-repeat related support. Rebirth may behave
differently now in this area.
- SDL2 gained the ability to make a window fullscreen by sizing it to
the desktop instead of by changing the desktop resolution. Rebirth
uses this, and it mostly works.
- Resizing while in the automap does not notify the automap code, so
the view is wrong until the player switches out of automap mode and
back in.
- SDL2 changed how to enumerate available resolutions. Since
fitting the window to the desktop is generally more useful than
fitting the desktop to the window, I chose to drop support for
enumerating resolutions instead of porting to the new API. Users can
now enter an arbitrary window dimension and Rebirth will make an
attempt to use it.
- It might be useful to cap the window dimension at the desktop
dimension, but that is not done yet.
- Entering fullscreen mode through the Controls->Graphics submenu
failed to notify the relevant subsystems, causing the rendered
content not to rescale. For now, compile out the option to toggle
full screen through that menu. Toggling through Alt+Enter works
properly.
Despite these quirks, this is a substantial improvement over the prior
commit, where SDL2 cannot be used at all. The remaining issues can be
resolved in future work.
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
Currently, DXX_USE_SDL_REDBOOK_AUDIO is an alias for !SDL2. However,
this patch enables interested users to readily patch out Redbook even
for SDL1.
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
On Windows, SDL headers define `main` to `SDL_main` in addition to doing
it through `pkg-config`. The countering `#undef` must occur after the
headers are included. Commit 2a82207 changed the `#undef` to occur too
early. Linux works fine, but Windows broke.
Move the `#undef` back down. Switch to named format parameters to make
it easier to maintain.
Fixes: 2a82207e91 ("Add unit tests for valptridx parameter validation")
For the benefit of users less familiar with how setup is handled, add a
hook triggered by $DXX_SCONS_DEBUG_USER_SETTINGS to log initialization
of `user_settings` so that users can trace which values combined to
produce the observed results.
Per comment from kreator, some Apple systems now ship without a working
print screen key. It makes no sense to provide print screen support
bound to a key which does not exist. Add `screenshot=none` and activate
it on OS X to remove the unreachable screenshot support.
This is safely ignored when the constructor cannot satisfy `constexpr`.
Without this modifier, forwarding to `constexpr` constructors is not
`constexpr`, which causes build failures.
clang-5 with `sconf_cxx11_inherit_constructor=force-failure`:
```
similar/main/gauges.cpp:553:61: error: constexpr constructor's 1st parameter type 'const (anonymous namespace)::hud_x_scale_float' (aka 'const hud_scale_float<'x'>') is not a literal type
similar/main/gauges.cpp:432:7: note: 'hud_scale_float<'x'>' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors
```
Fixes: 893e8cde06 ("Combine hud gauge parameters")
Replace magic strings with sentinel objects, so that mistakes are
reported as missing variables, rather than being legal at parse time and
incorrect at runtime.
If user_settings.sharepath is configured to be blank in SConstruct, omit
the C preprocessor macro SHAREPATH instead of defining it to expand to
an empty string. Adjust the C++ code that uses the macro SHAREPATH to
handle its absence:
- Clearer output in help text
- Skip adding blank SHAREPATH to the PhysFS search path.
As a nice side effect, this enables SHAREPATH on Windows, which could be
helpful for builds shipped with an installer that places game files in a
well-known location (such as "C:\Games\Descent"). Previously,
!defined(__unix__) systems did not add SHAREPATH to the PhysFS search
path, even when one was defined.
- Remove the one test that clang-5 still fails.
- Require all remaining tests to pass using only C++11 native
static_assert.
- Remove preprocessor-based alternative static_assert implementations.
gcc-8 adds calls to static_assert with a comma inside its first
argument in the implementation of std::vector. This is legal within the
standard, but conflicts with Rebirth's use of static_assert as a
two argument preprocessor macro. The macro is not substantially useful,
and was only present to compensate for the clang limitation removed in
the previous commit. Remove the macro.
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
Python 2 permitted defining __new__, then deleting it once it had been
used. Python 3 does not directly reject that pattern, but instead
always fails with an error about wrong number of arguments to object().
Switch to a simple classmethod that is explicitly invoked by the first
__init__().
In Python 3, filter returns an object that can be iterated to get the
filtered content. However, there is no way to reset the object, so it
is useless for persistence. Spend the one iteration copying the data
into a tuple, which can be iterated multiple times.
Python 3 `dict.keys()` returns an object that cannot be added to other
instances of itself. Pass the returned objects as a tuple, then let the
callee use itertools.chain to combine them during iteration.
Python 3 removed `dict.keys` and `dict.items`, then renamed
`dict.iterkeys` and `dict.iteritems` to `dict.keys` and `dict.items`,
respectively. The iteration semantics are preferable here, so add shims
to use the iteration API under a version-appropriate name.
Change PreservedEnvironment.__getitem__ back to a class method, instead
of an instance variable. Python 3 refuses to search the instance
dictionary for __getitem__, so the optimization of copying
`self.flags.__getitem__` to `self.__getitem__` breaks in Python 3.
Python 3 changed the rules for list comprehensions, so the comprehension
can no longer see a class-scope variable without a class qualifier. The
class qualifier is not legal until the class is finished. Work around
this limitation by expanding the use inline.
OpenBSD 6 uses `openbsd6` as its sys.platform. Strip trailing numbers,
then remove the hack for converting `linux2` into `linux`. This should
prevent compatibility problems when OpenBSD 7 is used.
Commit 265af2b9e5 added an extra test for whether the header could be
preprocessed, but reused the string shown when an empty test program is
compiled. This can confuse users since the same message is shown twice.
Differentiate the messages.
Fixes: 265af2b9e5 ("Extend SConf diagnostics for failed system headers")
gcc-4.9 warns (and due to -Werror, errors) for `png_time pt{}` because
the members are not explicitly initialized. This code is compiled, but
never run, so the explicit initialization is unnecessary. Later
versions of gcc accept both versions of this code without complaint.
Fixes: 131c1b9f4d ("Add support for PNG screenshots")
This is a longstanding cosmetic issue. Appending a tuple to a list
retains the tuple structure, which is then printed later. Append it as
a list so that it is flattened.
OpenBSD clang does not handle `-print-prog-name=as` in a useful manner.
Since this query is purely diagnostic, add an undocumented knob to
suppress the query.
thfrwn reports that OpenBSD (almost) works as-is, except that its
Python `sys.platform` is not in the allowed values list. Add it to the
list. By happy accident, unhandled `host_platform` is treated as
`'linux'` and `'linux'` produces the right result for OpenBSD.
Requested-by: thfrwn <https://github.com/dxx-rebirth/dxx-rebirth/pull/359>