Commit graph

9687 commits

Author SHA1 Message Date
Kp 79e4e0a628 Raise MAX_POINTS_PER_POLY to 64
Past releases had a debug-only assertion that 25 was sufficient, but
then dynamically allocated enough storage for larger models as needed.
Commit 22a34809ee ("Move interpreter g3s_lrgb onto stack") added a
hard limit of 25, but did not detect attempts to exceed this.  Custom
models that exceeded 25 would cause a stack buffer overwrite and likely
crash.  Raise the limit to 64 and add sanity checking to refuse to
render models that exceed MAX_POINTS_PER_POLY.

Fixes: 22a34809ee ("Move interpreter g3s_lrgb onto stack")
2017-06-07 02:44:55 +00:00
Kp d077b32201 Disable newdemo strftime -Wformat-nonliteral warning
Disable gcc's -Wformat-nonliteral for this one call since unchecked
format strings are (1) under the user's control, (2) unable to cause
problems, and (3) very difficult to fully support with the warning
enabled.

Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/338>
2017-06-07 02:44:54 +00:00
Kp b0cb681ae7 Add gcc-7 /*-fallthrough*/ comments for obvious cases
For switch cases where existing comments or code flow logic obviously
intended to fall through, add a gcc-7 /*-fallthrough*/ comment to
silence warnings about this.  Some cases which are less obvious are not
converted, so the code does not yet compile clean with
-Wimplicit-fallthrough.

Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/338>
2017-06-07 02:44:54 +00:00
Kp c159b831f4 Fix gcc-7 strict-aliasing warning in countarray
Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/338>
2017-06-07 02:44:54 +00:00
Kp e4ce907c1d Reduce scope of explicit instantiations 2017-06-07 02:44:54 +00:00
Kp 967edd7ccc Fix make_range for use on non-const lvalue 2017-06-07 02:44:54 +00:00
Kp 1ed7cec714 Tighten __builtin_constant_p check to handle gcc-7
Compile time sanity checks are built on gcc's __builtin_constant_p.
This intrinsic is useful for optimization and for some simple forms of
compile-time checks (such as the infamous open(2) missing mode), but
upstream does not guarantee that it will work reliably for more
complicated checks.  Starting in gcc-7.1, __builtin_constant_p returns
an incorrect result of true for the vm_vec_sub expression

    `(a.x == b.x && a.y == b.y && a.z == b.z)`

even when the blamed sites clearly cannot prove that the inputs are
equal.  The useful result would be to return true if, and only if, the
inputs were provably identical; inputs which might be identical at
runtime, or might not, would return false.  Based on a bug filed with
gcc and the developer comments there, it appears many projects have
assumed this intrinsic is usable in this way, but the gcc developers do
not guarantee that it can be used this way.  Additionally, they believe
affected projects are rare and were wrong to use this intrinsic, so they
have no plans to fix this regression.

For more details, see gcc bug #72785
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785>.  For some more
pointed commentary on this change in gcc, see Linus' kernel commit
474c90156c8dcc2fa815e6716cc9394d7930cb9c
<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=474c90156c8dcc2fa815e6716cc9394d7930cb9c>.

Update the SConf test to include the reproducer shown by Markus
Trippelsdorf in gcc bug #72785, comment #0.  This reproducer compiles
cleanly on <gcc-7, causing no change in semantics on older compilers.
Affected versions of gcc-7 will miscompile this reproducer into a link
error, causing SConf to record that the compiler does not optimize
__builtin_constant_p.  This is pessimistic, since even affected versions
of gcc-7 can handle some simple uses of __builtin_constant_p correctly.

This is a quick fix to get gcc-7 users working.  Upstream seems
disinclined to revert to the more useful semantics of <gcc-7 or to
introduce an alternative intrinsic with more helpful semantics.  As a
minor enhancement for Rebirth, it would be nice to probe the limits of
gcc-7's handling of __builtin_constant_p so that cases it handles
correctly could be enabled for gcc-7 users, while still blacklisting the
more complicated checks that gcc-7 miscompiles.

Thanks to Markus Trippelsdorf for providing a minimal reproducer to
detect the affected gcc versions.

Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/337>
2017-06-03 17:11:12 +00:00
Kp 32daf8e8c3 Handle unaligned stack during Win32 hexdump logging
The dump logger probes for the end of the stack, then rounds down to the
nearest paragraph boundary to simplify the logic in the hexdump routine.
The termination condition in the hexdump code assumed that there would
exist an integer N such that (`start` + (16 * N) == `end`).  Since `end`
is rounded to a multiple of 16, this held if and only if `start` is also
a multiple of 16.  In practice, this tended to happen, but it was not
guaranteed by the code.  If it ever failed to happen, then the hexdump
routine would not terminate and would instead perform an invalid read
beyond the edge of the stack.

Modify the hexdump routine to round `start` to a multiple of 16 so that
the termination condition works as intended.  This has the useful side
effect that hex dumps now always start paragraph aligned.  When the
stack was not paragraph aligned, this change will cause the hexdump to
show bytes below the stack pointer at the time of the fault.  However,
the stack requirements of the handler itself ensure that these bytes
will be valid.
2017-06-03 17:11:12 +00:00
Kp fc53137237 Extend SDL test to check for OpenGL mismatch
When Rebirth is configured to use OpenGL, it cannot start with an SDL
that lacks OpenGL support.  Detect this mismatch at build time.  Require
the user to resolve the conflict by disabling Rebirth OpenGL or by
enabling SDL OpenGL.
2017-06-03 17:11:11 +00:00
Kp 806c76ce02 Fix label truncation when strlen(hats) + 1 < strlen(buttons)
Hat labels reserve an extra character for the arrow, which partially
masked this error.  When used buttons requires more characters than (1
+ used hats), the buffer had insufficient space and the label was
truncated.
2017-05-13 04:19:39 +00:00
Kp 139ad58c72 Restore dropped hoard test
Commit 829e95b dropped a test for game_mode_hoard when computing light.
Since hoard orbs are in a union which overlaps the score in mission
mode, this caused a bug where a player in mission mode with non-zero
score would pulse light like a player carrying orbs in hoard mode.

Restore the test for hoard mode.

Fixes: 829e95b6f8 ("Separate hoard/proximity tracking")
2017-04-30 16:25:19 +00:00
Kp 26cb93d24f Preserve killer_objnum when a dead player takes additional damage 2017-04-30 16:25:19 +00:00
Kp 4f6c8575f2 Cache canvas in listbox_create_structure 2017-04-30 16:25:19 +00:00
Kp 8d2bc05624 Cache canvas in listbox_draw 2017-04-30 16:25:19 +00:00
Kp c2d45720c3 Pass canvas to check_face 2017-04-30 16:25:18 +00:00
Kp c12095dc4f Remove global canvas set in find_seg_side_face 2017-04-30 16:25:18 +00:00
Kp 601562b54b Pass canvas to render_segment 2017-04-30 16:25:18 +00:00
Kp 20b44fa856 Pass canvas to render_side 2017-04-30 16:25:18 +00:00
Kp 1b1cd54fb6 Pass canvas to check_render_face 2017-04-30 16:25:18 +00:00
Kp ab8859562e Pass canvas to do_render_object 2017-04-30 16:25:18 +00:00
Kp 4b4cb3a588 Pass canvas to outline_seg_side 2017-04-30 16:25:18 +00:00
Kp c4cff0df11 Fix missed canvas updates in scores_handler 2017-04-30 16:25:17 +00:00
Kp c8f93b7a5a Remove canvas juggling in state_callback 2017-04-30 16:25:17 +00:00
Kp 231ee1425f Remove canvas juggling in state_save_all_sub 2017-04-30 16:25:17 +00:00
Kp 53207b2ad0 Fix missed canvas updates in briefing_process_char 2017-04-30 16:25:17 +00:00
Kp 9558ca4eba Pass canvas to load_briefing_screen 2017-04-30 16:25:17 +00:00
Kp 22db18c10c Cache canvas in briefing_handler EVENT_WINDOW_DRAW 2017-04-30 16:25:17 +00:00
Kp 7aa764f975 Pass canvas to show_briefing_bitmap 2017-04-30 16:25:16 +00:00
Kp e425488329 Pass canvas to show_animated_bitmap 2017-04-30 16:25:16 +00:00
Kp af55ba08cc Pass grs_canvas &to draw_object_picture 2017-04-30 16:25:16 +00:00
Kp 1a1e669bc6 Pass vms_angvec &to draw_model_picture 2017-04-30 16:25:16 +00:00
Kp 2bd7344bff Remove canvas juggling in show_spinning_robot_frame 2017-04-30 16:25:16 +00:00
Kp 79a4a19711 Pass player to init_player_stats_level 2017-04-30 16:25:16 +00:00
Kp bd82516983 Pass player position to teleport_boss 2017-04-30 16:25:15 +00:00
Kp 57bf5d6e41 Validate segment walls on load 2017-04-22 21:23:56 +00:00
Kp 9478d1e6a5 Add custom terminate handler on Windows 2017-04-22 21:23:56 +00:00
Kp b98053a34f Fix Windows net_udp.cpp build
The Windows implementation of inet_ntop incorrectly omits the `const`
qualifier on the input address.  This broke the Windows build, since
Rebirth passes a const-qualified input address, as permitted by POSIX.

Some Windows cross-compilers, such as mingw32, lack a definition of
inet_ntop entirely.  For such environments, fall back to inet_ntoa and
disallow building with IPv6.

Rework the formatting and add a Windows-specific test for whether
inet_ntop is available.  As inet_ntop is specified by POSIX, assume all
modern non-Windows platforms support it.
2017-04-22 21:23:56 +00:00
Kp edc3b93c9b Switch valptridx array_size error reporting to %lu
x86_64-w64-mingw32-g++ -Wformat handling misparses the std::size_t
format string, causing a spurious error.

    common/main/valptridx.tcc: In function 'void untyped_index_mismatch_exception::prepare_report(const char*, unsigned int, const void*, long int, const void*, const void*, char (&)[229], std::size_t)':
    common/main/valptridx.tcc:36:182: error: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'std::size_t {aka long long unsigned int}' [-Werror=format=]

This occurs even though the processed text uses %I64u (which is correct
for a `long long unsigned int`), not %u as shown in the error message.

    static void prepare_report(const char *const filename, const unsigned lineno, const void *const array_base, const long supplied_index, const void *const expected_pointer, const void *const actual_pointer, char (&buf)[report_buffer_size], const std::size_t array_size)
    {
	snprintf(buf, sizeof(buf), "%s:%u: " "pointer/index mismatch:" " base=%p size=%" "I64u" " index=%li expected=%p actual=%p", filename, lineno, array_base, array_size, supplied_index, expected_pointer, actual_pointer);
    }

In practice, all such sizes will fit in `unsigned int` because they are
the dimension of an array of large structures.  Switch all platforms to
use `unsigned long`, which works everywhere and is at least as big as
`unsigned int`.  Using `unsigned long` produces the same size as
`std::size_t` on all platforms other than Win64, where `unsigned long`
is only 32 bits due to the strange LLP64 model Microsoft picked.
2017-04-22 21:23:55 +00:00
Kp 2dd4384d9d Move _WIN32_WINNT setup to SConf 2017-04-22 21:23:55 +00:00
Kp 466536b101 Remove abandoned powerup_cap_state
Commit b32298df5a ("Rewrite powerup cap
code to centralize logic") centralized powerup cap code in the
powerup_cap_state class.

Commit 901a554e96 ("New powerup management
code: Addeed functions and packet type to ...") removed all use of
powerup_cap_state, but left the dead implementation present.

Commit 479f5ed584 ("Fix 'format specifies
type 'unsigned short' but the argument has type 'unsigned char''
warning") switched the already dead (but still compiled) code from %hu
to %hhu to fix a warning on OS X.  Although the commit was written by
Chris, it was my suggestion to use %hhu.  I neglected to test Windows
before suggesting it, so the change went in even though Windows does not
accept %hhu; this broke the Windows build.  Fortunately, the code had
been dead for 11 months when the change was made, so the fix for Windows
is to remove the long dead code.
2017-04-22 21:23:55 +00:00
Kp 49cc3aa324 Work around i686-w64-mingw32-g++ compiler crash 2017-04-22 21:23:55 +00:00
Kp 9cfbf44834 Pass object &to toggle_headlight_active 2017-04-22 21:23:55 +00:00
Kp 6c98a3d61b Summarize failed nodes 2017-04-22 21:23:55 +00:00
Kp d0747bd481 Rename user_settings.LDFLAGS to user_settings.LINKFLAGS
SConstruct prefers to refer to linker flags for the main executable as
LINKFLAGS, not LDFLAGS.  Rename the internal storage to eliminate a
special case in accessing it.  Continue to use the environment variable
$LDFLAGS as an initial value, since many tools expect to pass linker
flags through $LDFLAGS.
2017-04-22 21:23:54 +00:00
Kp b5915abdcc Change station/robotmaker consistency check to LevelError 2017-04-15 17:46:44 +00:00
Kp 170d0ac777 Pass canvas &to nm_draw_background 2017-04-08 16:48:20 +00:00
Kp aaf7874235 Remove canvas juggling in nm_draw_background 2017-04-08 16:48:19 +00:00
Kp 94fe1117d7 Remove canvas juggling in save_screen_shot 2017-04-08 16:48:19 +00:00
Kp d827e73de9 Pass canvas &to draw_item 2017-04-08 16:48:19 +00:00
Kp 5d951e4453 Move ogl_sync fence into local scope for before_swap 2017-04-08 16:48:19 +00:00