Commit graph

10104 commits

Author SHA1 Message Date
Kp 32561c5d0a Use partial_range for piggy_does_bitmap_exist_slow 2018-08-26 18:10:36 +00:00
Kp 047ddaf9ea Prevent buffer overrun in removeext 2018-08-26 18:10:36 +00:00
Kp 6a96e30495 Merge commit 'Quiet FSRef warnings' into master 2018-08-26 16:14:02 +00:00
C.W. Betts b9c6d59f11 Remove the forcing of null-termination of fullPath on OS X:
CFURLGetFileSystemRepresentation should already null-terminate its buffer.
2018-08-23 22:12:56 -06:00
C.W. Betts 0c48d99d2b Match the coding style of the rest of the document. 2018-08-23 21:29:03 -06:00
C.W. Betts 9cfa12c0fe Use sizeof(fullPath), as suggested by @vLKp. 2018-08-23 21:28:04 -06:00
Kp 6be3c0e13a Fix PCH conditional nesting 2018-08-24 02:58:21 +00:00
Kp bba8a327a0 Remove use of -Wno-implicit-fallthrough 2018-08-24 02:58:21 +00:00
Kp be18f54d06 Simplify SConstruct StaticObject hook
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.
2018-08-24 02:58:21 +00:00
Kp 3f164f494d Unpack LazyObjectConstructor loops
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.
2018-08-24 02:58:21 +00:00
Kp 92cc4bd4ff Handle Python3 bytes vs. str in Git.__compute_extra_version 2018-08-24 02:58:21 +00:00
C.W. Betts 746b61da8d Wrap the gobbler up in a preprocessor guard. 2018-08-22 12:10:33 -06:00
C.W. Betts e2a33dc81f Replace FSRef-dependant calls to CoreFoundation equivalents. 2018-08-21 13:40:25 -06:00
C.W. Betts fdf5a37c35 gobble up -psn command line options.
Should fix #387.
2018-08-21 13:04:21 -06:00
Kp b53be4943c Update memcpy blacklist 2018-08-20 00:34:16 +00:00
Kp 1197f568bc Add CHOST qualifier to CXX, RC 2018-08-20 00:34:15 +00:00
Kp a8d5f83770 Remove reset_walls
Nothing should access the unassigned walls, so there is no need to clear
them.
2018-08-12 21:08:07 +00:00
Kp 36ada21c0c Fold exploding walls into regular walls 2018-08-12 21:08:07 +00:00
Kp dc4fcf8a35 Flip sense of is_door_free 2018-08-12 21:08:07 +00:00
Kp 8257232ecc Pass wclip & to wall_set_tmap_num 2018-08-12 21:08:07 +00:00
Kp b316afc30f Clear exploding walls during init 2018-08-12 21:08:07 +00:00
Kp 8bbdeedeb2 Consolidate stuck object state
Move it to a structure.  Make all the modifiers methods.  Change all
callers of those methods to pass the structure.  This makes the stuck
object handling free of direct access to global game data.
2018-08-04 17:52:57 +00:00
Kp 57334255ac Simplify stuck object cleanup 2018-08-04 17:52:57 +00:00
Kp eff80c2d13 Fix format string warnings for win64 2018-08-03 04:08:12 +00:00
Kp 8eff5802b6 Add explicit check for SDL_JOYSTICK_DISABLED 2018-08-03 04:08:12 +00:00
Kp 524f042659 SDL2: MVE: fix noise from reading undefined sound data
Commit 07245a0bc2 added the SDL_mixer backend for MVE audio.  That
commit set the length of the converted sound equal to the size of the
buffer that SDL requested as a work area.  No one ever touched that
logic, until now.  In SDL1, that choice worked fine.  In SDL2, this
causes garbage to play after the sound, because SDL2 considers the
buffer to be defined only up to the length returned in
`SDL_AudioCVT::cvt_len`.  Bytes beyond that length are undefined[1], and
in practice contain garbage.  Fix the noise by setting the sound length
equal to the length returned by SDL2, so that the undefined bytes are
not treated as sound.  SDL1 also maintains this length value, so no
version-specific logic is required.

[1]: https://wiki.libsdl.org/SDL_ConvertAudio

Reported-by: andrew-strong <https://github.com/dxx-rebirth/dxx-rebirth/issues/398>
2018-08-01 01:18:11 +00:00
Kp 1b8ff6ac77 SDL2-mixer: fix noise from reading undefined sound data
Commit a833d73d44 added the SDL_mixer backend for Rebirth sound.  That
commit set the length of the converted sound equal to the size of the
buffer that SDL requested as a work area.  No one ever touched that
logic, until now.  In SDL1, that choice worked fine.  In SDL2, this
causes garbage to play after the sound, because SDL2 considers the
buffer to be defined only up to the length returned in
`SDL_AudioCVT::cvt_len`.  Bytes beyond that length are undefined[1], and
in practice contain garbage.  Fix the noise by setting the sound length
equal to the length returned by SDL2, so that the undefined bytes are
not treated as sound.  SDL1 also maintains this length value, so no
version-specific logic is required.

[1]: https://wiki.libsdl.org/SDL_ConvertAudio

Reported-by: heftig <https://github.com/dxx-rebirth/dxx-rebirth/issues/396>
2018-07-30 00:49:59 +00:00
Kp 726233e043 Fix sdlmixer=0 build of songs.cpp 2018-07-30 00:49:59 +00:00
Kp 25ab07bcc5 SDL2: set relative mouse mode when grabbing the mouse
Reported-by: heftig <https://github.com/dxx-rebirth/dxx-rebirth/issues/397>
2018-07-29 21:17:09 +00:00
Kp c65020bf04 Fix gcc-8 build of common/arch/sdl/key.cpp
gcc-7 allows `constexpr auto X = std::initializer_list<unsigned>{A1, A2,
...};`.  gcc-8 rejects it:

```
common/arch/sdl/key.cpp:583:105: error: 'const std::initializer_list<const SDL_Scancode>{((const SDL_Scancode*)(&<anonymous>)), 3}' is not a constant expression
  constexpr auto sticky_keys = {SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_NUMLOCKCLEAR};
```

Switch to a macro and a fully anonymous list, which is accepted by both
versions.

Fixes: f491059ed7 ("Enable building with SDL2")
2018-07-29 16:13:15 +00:00
Kp f491059ed7 Enable building with SDL2
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>
2018-07-28 23:22:58 +00:00
Kp 289e984e10 Reduce scope of function-local constants 2018-07-22 04:46:19 +00:00
Kp 75d7eb6dce Skip paging in vclip entries with invalid num_frames
User Nemesis reported an unspecified crash, but never responded to
inquiries to provide more data.  Users Tourmeister and Buff Skeleton
reported a fatal exception thrown while paging in a vclip, with initial
triggering conditions matching the report from Nemesis.  Both
Tourmeister and Buff Skeleton are using v1.0 Descent 2 data.  No one
with more recent data has reported a problem.

Add a try { ... } catch { ... } block to trap the partial_range
exception, log it, and then ignore paging in that vclip.  This should
approximate what 0.58.1 did, assuming that the crash is due to a
negative `num_frames`.  If the crash is due to a large positive
`num_frames`, this change will still prevent the previously reported
crash, but may only move the crash elsewhere.  Various other subsystems
react badly to using a vclip that has not been paged in.

This change is tested not to break an otherwise working game.  It is not
tested to confirm that it produces a working game for users who
experienced a crash without it.

Reported-by: Tourmeister <https://forum.dxx-rebirth.com/showthread.php?tid=943&pid=12159#pid12159>
Reported-by: Buff Skeleton <https://forum.dxx-rebirth.com/showthread.php?tid=943&pid=12290#pid12290>
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/371>
2018-07-18 04:39:28 +00:00
Kp 19699037ce Move d2x-rebirth/main/bmread.cpp -> similar/main/bmread.cpp 2018-07-18 04:39:28 +00:00
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 20f1934312 Move Redbook audio behind DXX_USE_SDL_REDBOOK_AUDIO
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>
2018-07-14 17:23:15 +00:00
Kp f33877d379 Make grs_main_bitmap::grs_main_bitmap() clear the whole structure 2018-07-14 17:23:15 +00:00
Kp 5d74fd48b5 Fix player appearance sound truncation
The player appearance sound was tied to the player appearance vclip,
but this is wrong because the vclip has a shorter lifetime than the
sound.  This mistake was previously hidden by the hack that caused
non-permanent sounds to be routed off to a separate queue that lost the
association between object and sound.  Commit 4a98e79 eliminated that
hack because it complicated the work of that commit.  However, without
the hack, object sound effects cannot outlive their host object.

Fix this by binding the sound to the position of the appearance effect,
not to the appearance object.  This works since the appearance effect
cannot move, so there was no value to binding the sound to the object.
This solution could not be used for objects that move and terminate
before their associated sound effect.

Reported-by: Ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88#issuecomment-390054173>
Fixes: 4a98e796ab ("Prevent stacking weapon rotation sounds")
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 1da76dde7d Fix SDL-only build of gauges.cpp
Even when empty and default-constructible, const members must be
explicitly constructed.  Add a default constructor to do this.

Fixes: 893e8cde06 ("Combine hud gauge parameters")
2018-06-30 21:53:55 +00:00
Kp da268c6d21 Preprocess out glmprintf in normal builds
Using sizeof(con_printf A) was a trick to avoid code generation, but it
interacts badly with gcc-6 and the other macros that con_printf
produces.  On >=gcc-6, `DXX_ALWAYS_ERROR_FUNCTION` is a complicated hack
to work around undesirable changes in `__builtin_constant_p`.  That hack
includes introducing a dummy type.  gcc-6 rejects declaring a type
inside a statement expression inside a sizeof.  gcc-7 permits this, so
it went unnoticed.

This particular usage was to prevent future regressions in calls that
had been broken for years without anyone noticing.  As such, reverting
to not checking those calls is unlikely to matter.

Reported-by: Ambaire <https://github.com/dxx-rebirth/dxx-rebirth/issues/393#issuecomment-401565872>
Fixes: 9b17450914 ("Fix up long broken glmprintf support")
2018-06-30 21:53:55 +00:00
Kp 90dfedb5cb Fix gauges.cpp for gcc-5
gcc-5 rejects `V == V::E` where the first V is a variable of type V and
the second V is a scope specifier to indicate the member E in the type
V.  gcc-7 permits this.

Fixes: 5cafec2268 ("Use enum for gauges weapon_type")
2018-06-30 21:53:55 +00:00
Kp 7d4c521382 Fix SConf tests for Windows target
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")
2018-06-30 18:59:53 +00:00
Kp 9dafe85bbf Simplify clamping color values in SDL palette setup 2018-06-29 03:24:36 +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 d20901edba Adjust physfsrwops.cpp 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 d1a4e3b7a1 Update Gentoo ebuild to current stable-0.60.x
_p38 since the target commit is 38 commits after tag 0.60.0-beta2.
2018-06-24 18:05:48 +00:00