Commit graph

3063 commits

Author SHA1 Message Date
Kp fd0238cb6b Silence gcc-8 -Wcast-function-type in except.cpp
gcc-8 adds a new warning controlled by -Wcast-function-type, which is
implied on by Rebirth's default options.  This new warning rejects
attempts to reinterpret_cast between function pointer types.  While this
might provide some value when the function pointer was derived by taking
the address of a properly declared function provided elsewhere in the
same program, it is wrong when the function pointer is returned by an
external library call, such as GetProcAddress, which always returns a
placeholder type instead of the actual type of the target function.
Switch to using a union with type-punning, which achieves the same
effect as the cast, but does not count as a cast, and therefore does not
provoke the warning.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-07-15 04:43:55 +00:00
Kp f33877d379 Make grs_main_bitmap::grs_main_bitmap() clear the whole structure 2018-07-14 17:23:15 +00:00
Kp 9ea09107d1 Delegate managing SDL_RWops to SDL_mixer when possible
SDL_mixer 2 offers the option to have the library free the SDL_RWops.
Add macros to use this feature when available.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-05 04:03:34 +00:00
Kp d97afc2ad5 Retain directory structure in New Game dialog
User jcotton42 suggested copying a D2X-XL feature: preserving the
directory structure of the user's missions area when showing a New Game
dialog.  This was substantially more trouble than it should have been,
but the result is good.

Previously, the dialog presented all missions at any depth below the
starting point, and sorted them as if they were all in the root
directory.

Now:
- Empty directories are hidden entirely.  There is nothing for the user
  to do in them, so there is no point showing them.
- A directory with exactly one entry has that entry promoted into the
  parent, since there is no ambiguity about what the user would want.
  If the parent in turn has only that one promoted element when the scan
  of the parent finishes, then the element can be promoted up again.
  This continues until the root is reached or until a level has more
  than one entry.  For this purpose, both missions and directories count
  as entries.
- Directory entries are decorated to inform the user how many
  immediate subdirectories are present, how many missions are present
  immediately in the directory, and how many missions total are present,
  counting all subdirectories.  If there are zero immediate
  subdirectories, then the directory count is not shown.  For this
  purpose, directories that were hidden due to a lack of missions are
  not counted.
- Sub-dialog boxes for inner directories use a title that reminds the
  user of the path so far, and recaps the directory/mission statistics.
- On entry to the New Game dialog, if the last played mission is in a
  sub-dialog, appropriate sub-dialogs are opened so that the last played
  mission can be pre-selected.

Currently, there is no in-game override to return to the prior rollup
rules.

Requested-by: jcotton42 <https://github.com/dxx-rebirth/dxx-rebirth/issues/392>
2018-07-03 05:59:40 +00:00
Kp db80a88ad2 Improve error message on failure to load mission 2018-07-03 05:59:39 +00:00
Kp 676cab8921 Adjust d_event_mouse_moved member types for SDL2
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-06-27 03:34:34 +00:00
Kp 60a99f1ea2 Allow longer mission titles in New Game dialog 2018-06-27 03:34:34 +00:00
Kp 30a83eec41 Eliminate some uses of valptridx::operator-> 2018-06-24 05:06:15 +00:00
Kp 6fca290663 Pass object& to read_flying_controls 2018-06-24 05:06:15 +00:00
Kp 0fd7e0e4ce Pass context arrays to WALL_IS_DOORWAY 2018-06-24 05:06:15 +00:00
Kp 3408e3a0cd Switch to shared_segment arguments where possible 2018-06-24 05:06:15 +00:00
Kp 0c3e99f14c Split side uses based on shared vs unique 2018-06-24 05:06:15 +00:00
Kp 2de3a1dd06 Pass unique_segment to objects_in 2018-06-24 05:06:14 +00:00
Kp 4ae88b6594 Pass only shared_segment to compute_segment_center 2018-06-24 05:06:14 +00:00
Kp 6d0d68d188 Split some segment uses based on shared vs unique
Leave `sides` in `shared_segment` to minimize churn.  Parts of it must
move to `unique_segment` before this project finishes.
2018-06-24 05:06:14 +00:00
Kp 144515ff88 Warn users about tracker NAT hole punch feature
The new tracker automatically exposes LAN games to the Internet.  This
surprised one user rather badly, prompting him to think he had been
hacked.  Add a first-host warning explaining the feature and asking the
user to choose whether to enable NAT hole punch.

Reported-by: Tourmeister <https://forum.dxx-rebirth.com/showthread.php?tid=943&pid=12179#pid12179>
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/372>
Fixes: 730879d733 ("... Added support for handling ACKs from tracker and Hole punching between game clients via tracker. ...")
2018-06-21 03:08:36 +00:00
Kp a0fd264133 Tighten checks on create_path_points parameters 2018-06-20 04:16:06 +00:00
Kp 2a82207e91 Add unit tests for valptridx parameter validation 2018-06-17 05:04:38 +00:00
Kp 2f4524d3c2 Add screenshot=none to disable screenshot support
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.
2018-06-16 04:13:37 +00:00
Kp 39edf53496 Check for freed canvas in release builds 2018-06-14 02:39:15 +00:00
Kp 5526de4c10 Simplify case insensitive lookups 2018-06-13 02:02:58 +00:00
Kp f51b7b6b20 Enforce separation of font X/Y scaling 2018-06-08 04:04:05 +00:00
Kp bde498894a Disallow operator=(T &&) && in valptridx
GCC std::remove_if overwrites removed elements using:

	*dstiter = move(*srciter);

This is fine for normal containers, but produces incorrect results when
*dstiter returns a proxy object instead of a reference.  In that case,
the proxy object is move-assigned from the source, then goes out of
scope.  If the move assignment did not write to underlying storage, as
valptridx proxy objects do not, then incorrect results occur.  This
broke ActiveDoor handling (fixed in 4a01fab66d98[1]) and has been a trap
waiting to recur.  Apply reference-qualifiers to valptridx objects so
that move-assignment requires an lvalue for the left-hand side.  This
permits normal use of move-assignment, but forces a compile error if
std::remove_if or similar are used on valptridx proxy objects.

[1]: 4a01fab66d
2018-06-08 04:04:05 +00:00
Kp f0157490dc Fix check_header_includes=1 build 2018-06-06 04:53:45 +00:00
Kp 93789f0666 Use valptridx for Dl_indices 2018-06-06 04:53:45 +00:00
Kp 1c1d92b399 Move valptridx factory iterator out to be generally available 2018-06-06 04:53:45 +00:00
Kp fda1eb851e Pass fonts to LINE_SPACING 2018-05-19 23:21:42 +00:00
Kp 3049476e11 Change LINE_SPACING to a static inline function 2018-05-19 23:21:42 +00:00
Kp 08446f0ab6 Pass font to gr_string,gr_printf 2018-05-19 23:21:42 +00:00
Kp 4a98e796ab Prevent stacking weapon rotation sounds
digi_play_sample_once is supposed to cancel prior instances of the
sound, but that functionality was lost in
21082c6db2.  As a result, the sound can be
stacked up to the limit of the engine.  Even when the functionality
existed, its implementation was wrong.

- Change these sounds to be attached to the player generating them.
- Pass the cancellation flag to other players when sending a sound.
- Send the full value of `volume`, rather than truncating it.
- Implement cancellation by killing and restarting the earlier version of a cancelled sound.
- Delete an ugly hack that prevented the patched logic from ever running.
- Fix an ancient quirk in digi_mixer that caused it to report all sounds as not playing, which then caused digi_sync_sounds to instantly cancel the new sound.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88>
Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88#issuecomment-269597361>
Fixes: 21082c6db2 ("Added own channel management to SDL_mixer sound interface since the builtin channel management of this lib cannot handle our needs; Little code cleanup")
2018-05-13 03:14:34 +00:00
Kp e63bbe8c52 Set d_event type at construction 2018-05-12 18:24:19 +00:00
Kp fe52ddb7b6 Remove stringified enum name from WINDOW_SEND_EVENT
Future work is simpler without this, and the stringified name is only
visible in debug output, which is in turn rarely used due to its
verbosity and lack of filtering controls.
2018-05-12 18:24:19 +00:00
Kp 6ab28cb8cb Use enum for Difficulty_level 2018-05-12 18:24:19 +00:00
Kp ccc2a288f1 Simplify HUD_SCALE_X_AR, HUD_SCALE_Y_AR 2018-05-12 18:24:19 +00:00
Kp 3749ee2b74 Fix cvar -Wrestrict in gcc-8
Per C99, this code was always wrong.  The results of `snprintf` are
undefined if the target string array and one of the supplied input
arguments refer to the same buffer.  In practice, this particular usage
happened to work by wastefully copying a string onto itself, then adding
more content at the end.  Switch to appending properly, which also fixes
the gcc-8 -Wrestrict warning.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 6a8930cef0 Remove unnecessary inclusions of compiler-static_assert.h
Various files included compiler-static_assert.h to use the compatibility
macros for compilers that lacked a working C++11 static_assert.
However, some source files used static_assert without this inclusion,
and no one ever reported problems.  From this, assume that no one uses a
compiler which lacks C++11 static_assert.  Remove the inclusions that
were only for the compatibility macro.  Keep the inclusions that use the
assert_equal helper.
2018-05-05 22:33:55 +00:00
Kp 457022db48 Require C++11 static_assert
- 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>
2018-05-05 22:33:55 +00:00
Kp 23a899cf0e Adjust valptridx for clang static_assert limitation
valptridx contains `static_assert` statements of the form:

	static_assert(var.m, "");

where `var` is a non-`constexpr` reference and `m` is a `static
constexpr` member of a base type of `var`.  gcc recognizes that a
`static constexpr` member is a constant expression and permits this.
clang rejects this, presumably because `var` is not a `constexpr`
variable.  In the almost 3 years since this was added, clang has not
improved to permit this usage.  Rather than continuing to suppress
static_assert in clang, rewrite this expression to be less clear, but be
compatible with clang.
2018-05-05 22:33:55 +00:00
Kp d269c878b3 Add operator++,operator-- to base_bytebuffer_t
gcc-8 has special cases in its std::advance that require the target to
support `operator++` and `operator--`.  These are easy to support, so
add them.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 381bfeeb5d Eliminate casts in byteutil_unaligned_copy
gcc-8 warns that static_cast<dt &>(d) is useless.  In general, it is
useless.  It is present to force a compile error in cases when `d` is
not convertible to `dt &`.  Switch to a compound statement that declares
a local reference to `d` of type `dt &`.  This achieves the same
checking effect, but does not provoke the -Wuseless-cast warning.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 80ee9f9249 Merge pull request #376 "Update SDLMain.m" to github/master
Reviewed-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/pull/376#issuecomment-383352781>
2018-04-23 05:09:52 +00:00
derhass 38815ba10b change SYNC_GL_AUTO mode to disable GL sync if VSync is turned off
Users with disabled VSync might not expect any forced waiting on the GPU,
and the GL sync methods were intented to fix issues with VSync only,
so the new heuristic for SYNC_GL_AUTO is to enable GL sync only if
VSync is enabled, too.

Users can still request to use a specific GL sync method via the
-gl_syncmethod switch, independent of the VSync setting.

[Kp: folded `else { if () }` into `else if ()` to avoid moving
`ogl_have_ARB_sync` lines.  Original change visible at
<https://github.com/dxx-rebirth/dxx-rebirth/pull/381>.]
2018-04-23 04:57:48 +00:00
derhass 8e43a845b3 handle multiplayer network packets during SYNC_GL_FENCE_SLEEP wait loop
This mirrors the logic from calc_frame_time(). When VSync is enabled,
waiting for the previous frame to complete might induce long wait periods,
up to the complete frame time, so we should also handle multiplayer there.

For the other sync modes, the GL calls will simply block, so we can't do
anything about that (except going multithreaded, but that's a totally
different can of worms). Note that even without sync, the SwapBuffers()
call in gr_flip() may also block if VSync is on (and enough frames are
queued up), so the issue is not the GL sync code itself.

SYNC_GL_FENCE_SLEEP is now probably the nicest mode for multiplayer
with VSsync, as it is the only one which has the potential to continue
handling multiplayer packets during the wait for VBlank time.
2018-04-22 18:14:34 +02:00
C.W. Betts c4417aafb1 Update SDLMain.m:
10.9 changed how applications were launched, making the old method of detecting a Finder launch fail.
2018-04-16 16:19:36 -06:00
Kp 8096af91da Add support for shuffling powerups in anarchy games 2018-04-12 04:19:35 +00:00
Kp 90d2a61c1d Simplify visited_segment_mask_t 2018-04-09 00:58:28 +00:00
Kp f869a16e35 Move Debris_object_count into d_level_object_state 2018-04-02 03:39:51 +00:00
Kp 813d73eedd Pass vms_matrix &to vms_matrix_from_quaternion 2018-03-31 21:53:01 +00:00
Kp 45f59c384b Pass vms_matrix &to vms_quaternion_from_matrix 2018-03-31 21:53:01 +00:00
Kp 18af84a0ab Remove __attribute__((packed)) from quaternionpos
Packed structures cannot be passed by reference, may fail on
alignment-strict architectures, and are bad for performance even on
alignment-tolerant architectures.  Using them for anything other than an
abstract layout declaration is a mistake.  Remove
__attribute__((packed)).
2018-03-31 21:53:01 +00:00