Little endian systems stored sound as a `uint32_t`, but sent only the
lowest byte. Store only that byte, since the destination was unaligned
and was the last field in the message.
LTO allows the compiler to prove variable values that non-LTO mode
cannot prove. The workaround for the gcc-7 __builtin_constant_p
quirk incorrectly caused LTO on older gcc to report __builtin_constant_p
as unsupported. Fix this by adding a stub asm() statement to hide the
value of the input parameter from the compiler.
Fixes: 1ed7cec714 ("Tighten __builtin_constant_p check to handle gcc-7")
On Windows, the hook function blocks until the user dismisses the
message box. Print the message before opening the message box so that
it is available on the console, if one exists.
Players keep reporting errors that trace to the game rejecting invalid
data from user-made maps. In this case, asymmetric connectivity in
_Descent Vignettes_[1] level _Stalactite Volcano_ (level 15 in Descent,
level 14 in Descent 2) caused an exception when trying to render part of
the first big room.
The debug build shipped with function `check_segment_connections` to
detect some types of connectivity errors. Expose this function to
release builds, and call it for user-made maps. It already checked for
asymmetric segment links. Extend that to hotfix those links by breaking
the asymmetric connection. Log an URGENT class message when this
happens, so that users are aware that the level was modified at load.
Move the `NDEBUG` guards into `check_segment_connections` so that
non-debug builds check only for segment symmetry, but do not check for
normals and face count errors.
[1] http://www.enspiar.com/dmdb/viewMission.php?id=724
```
sha1sum vignette.hog vignette.msn
3cd659e6dd5927b41157dfb7d1dd87d90e781f01 vignette.hog
1f7d140ffab11816364040dd6da71a1568393a16 vignette.msn
stat -c '%s %Y %n' vignette.hog vignette.msn
5717889 1251643308 vignette.hog
956 1250212930 vignette.msn
```
Reported-by: MegaDescent <http://forum.dxx-rebirth.com/showthread.php?tid=970>
Revert to the user's chosen resolution, not to 0x0, which would then be
coerced to the minimum resolution. When the text says revert, it should
revert, not just pick a size.
Change the "OK" label to say "Revert to NxM" for the resolution it is
reverting to.
Tighten input validation so that a blank width or blank height produce
the correct error message, rather than being coerced to 0, then
rejecting 0 as too small.
Early implementations of integer_sequence used a naive implementation
that required one level of template depth per additional integer in the
sequence. Rebirth uses a private alternate implementation named
make_tree_index_sequence that requires only log(N) steps for an
N-element index_sequence. Recent versions of gcc ship a log(N) version
of integer_sequence. Probe for that version and, if found, use it
instead of the private implementation, on the theory that the compiler
writers did at least as good a job as I did, and possibly better if they
were able to leverage compiler implementation details.
- Add wrappers for PHYSFS_read and its convenience functions. Poison
the memory before calling PHYSFS, so that any uninitialized bytes
(likely caused by a short read) are reported if the caller tries to
access the value anyway.
- Add SConstruct options to enable wrapping, so that users do not need
to enumerate the wrapped functions manually.
- Fix link failure when using LTO+wrappers.
d2x::segment has all members of d1x::segment, as well as two new members
exclusive to d2x::segment. Structure layout is such that d1x::segment
requires the same size allocation, and places anonymous pad members in
the locations that become named members in d2x::segment. Thus, reusing
d2x::segment for d1x::segment does not change the size of the structure
nor the offsets of any members used. This reuse may enable some
functions to be better shared by the dsx project.
Future work will introduce uses of d1x/d2x in the other game when the
types can be usefully shared. Extend the anti-nesting guards to cover
mistakes that might arise when referring to the namespaces by their
real name, rather than the alias name dsx.
Instead of blacklisting two specific bad N_save_pof_names values, ignore
all N_save_pof_names that would overrun the Save_pof_names array.
This allows Rebirth to load broken levels such as "Hazard Zone"[1]. In
the case of Hazard Zone, the POF count is simply missing, so the first
two characters of the first POF name were taken as a count. This led to
a massive overrun of the Save_pof_names array.
[1]:
```
sha1sum hazard.msn hazard.rdl
25abe7ba1aca91f0bd09551e65cfadeabfcb73df hazard.msn
f5e6761b674b595550b27733fd83eeb2eff5e8f8 hazard.rdl
```
`value` is generic and unclear. It is always meant to be used as an
index into the Station array, so rename it `station_idx` to show this.
Define and consistently use `station_none` to represent that no station
is assigned.
Using precompiled headers includes vers_id.h into
similar/main/newdemo.cpp. gcc-4.9 reports a conflict between vers_id.h
`extern const char g_descent_build_datetime[21]` and newdemo.cpp macro
generated `extern const char g_descent_build_datetime[]`. The size is
only needed in the definition, so remove it from the declaration to
align with the macro-generated extern.
Delete stub "compiler-type_traits.h" header. Redirect all uses to the
standard <type_traits> header.
git grep -wlz 'compiler-type_traits.h' -- '*.cpp' '*.h' | xargs -0 perl -p -i <<EOF
BEGIN {
$i = 0;
}
if (($i == 1 && $_ eq "\n") || ($i < 2 && /^#include "/)) {
# First blank line or first user-include after a system-include.
# Print, then never again for this file.
print "#include <type_traits>\n";
$i = 2;
} elsif ($i == 0) {
$i = 1 if (/^#include </);
} elsif ($_ eq "#include \"compiler-type_traits.h\"\n") {
# Remove this line if found.
$_ = '';
}
# Reset state machine when moving to next file.
$i = 0 if eof;
EOF
All supported compilers have an acceptable <type_traits>. Commit
4cb3d46148 ("Move <type_traits> test to Cxx11RequiredFeature") made
<type_traits> support mandatory in August and no one has objected.
Remove the indirection and use namespace std directly for type_traits
members.
Early unification efforts missed this one because it was in gamemine.c
for Descent 1, but segment.c for Descent 2. Move it to gamemine.cpp for
both, so that it can be static for both games.
It is not meant to be included in every file. Starting in gcc-7, static
functions declared in valptridx.tcc generate -Wunused-function warnings
if the including file does not instantiate any templates that use the
static function. Avoid these warnings by including the tcc only in a
file that is guaranteed to instantiate templates that use these
functions.
gcc-7 warning -Wformat-truncation would be good to fix, but the compiler
does not offer an acceptable solution yet.
gcc-7 warning -Wimplicit-fallthrough requires more analysis of the
diagnosed sites to identify which, if any, require a resolution other
than suppressing the warning.