Commit graph

9703 commits

Author SHA1 Message Date
Kp 73d92bb509 Make wclip::num_frames uint16_t 2017-06-17 23:05:16 +00:00
Kp bca7823423 Use range_for+partial_range in paging_touch_model 2017-06-17 23:05:15 +00:00
Kp 57b67078da Exclude valptridx.tcc from PCH
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.
2017-06-10 03:31:04 +00:00
Kp ab98ba6677 Indent medlisp_update_screen test to silence -Wmisleading-indentation
This commit makes only whitespace changes.
2017-06-10 03:31:04 +00:00
Kp c25041fb41 Use array<> for editor Views 2017-06-10 03:31:04 +00:00
Kp 73057ad8ec Suppress unhelpful gcc-7 warnings for now
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.
2017-06-10 03:31:04 +00:00
Kp 4e578df4c6 Validate range for d1 bmread ab_load 2017-06-10 03:31:04 +00:00
Kp 8a038de506 Tighten Marker_viewer_num validation 2017-06-10 03:31:03 +00:00
Kp 0e57e9bbf7 Expand macro to fix gcc-7 portability warning
gcc-7 warns:

    similar/main/mglobal.cpp:119:5: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
     #if DXX_VALPTRIDX_ENABLE_FULL_TEMPLATE_INSTANTIATION

Fix this by using the long form of the definition.
2017-06-10 03:31:03 +00:00
Kp 5b12f28564 Add workaround for unwanted gcc-6 "used but never defined" warning
gcc-6 issues a "used but never defined" warning for functions which are
declared, never defined, and used only in contexts which are later
deleted by the optimizer.  If the function were actually used, the link
would fail.  Switch to a complicated mechanism to define the function
while keeping it out of line so that __attribute__((__error__)) is
triggered as intended.
2017-06-10 03:31:03 +00:00
Kp 2a8e7dc3b1 Simplify game log timestamp 2017-06-10 03:31:03 +00:00
Kp 7b16571cb2 Rename countarray method count -> size 2017-06-10 03:31:03 +00:00
Kp a03291b036 Rename countarray method size -> max_size 2017-06-10 03:31:03 +00:00
Kp 430f7832aa Move valptridx factories into array_managed_type 2017-06-10 03:31:03 +00:00
Kp 599ac9dee0 Always qualify valptridx type/factory
Previously, valptridx used PREFIX for allow-invalid+mutable, c#PREFIX
for allow-invalid+const, v#PREFIX for require-valid+mutable, vc#PREFIX
for require-valid+const.  Convert the types, factories, and all usage
sites to specify a qualifier for all four combinations:

	im#PREFIX -> allow-invalid+mutable
	ic#PREFIX -> allow-invalid+const
	vm#PREFIX -> require-valid+mutable
	vc#PREFIX -> require-valid+const

Changes to common/include/valptridx.h and common/include/fwd-valptridx.h
are manual.  All other changes are generated by:

	git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\(v\?\)\(\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/\1m\2/g'

for the 'm' prefix and:

	git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\([cm]\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/i&/g'

for the 'i' prefix.
2017-06-10 03:31:02 +00:00
Kp f455d5b8a6 Reorder valptridx macro structure 2017-06-10 03:31:02 +00:00
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