Commit graph

10690 commits

Author SHA1 Message Date
Kp 219a3fcd11 Move laser_info::get_last_hitobj out of line
It is only used in two places, neither of which are hot paths.  Move it
out of line so that other files do not need to parse it.
2019-12-16 01:56:59 +00:00
Kp 28d9358b00 Expand local aliases to their target variables
This makes the code easier to read, at the price of a bit of churn.
2019-12-16 01:56:59 +00:00
Kp 148fe47d82 Split checked/unchecked valptridx converting constructor logic
This allows the caller to omit filename/line information for calls that
will never need it.
2019-12-16 01:56:59 +00:00
Kp 5950485a6c Fix ptridx move constructor delegating to ptr copy constructor
Fix a bug where the ptridx converting move constructor delegated to the
ptr converting copy constructor, since the ptr copy constructor had
filename/line arguments, the ptr move constructor did not, and the
ptridx move constructor always passed filename/line.
2019-12-16 01:56:59 +00:00
ziplantil 341c622e69 that verbose one is no longer needed 2019-12-12 17:42:53 +02:00
ziplantil ed88836e9d make sure there is enough space to load exit data 2019-12-12 17:34:42 +02:00
ziplantil cb2b844af3 do not free extra models when loading exit stuff on D2 2019-12-12 17:25:11 +02:00
Kp ca383c1fe7 Fix Win32 build of scores.cpp
Fixes: 0b8f32d744 ("Set player name in Players[] at single-player game start")
2019-11-19 02:42:24 +00:00
Kp 5f0e99b472 Update installation documentation
- Recommend Python 3.  Python2 will be end of life soon.
- Recommend PhysFS 3.
- Update link for SCons to current version.
-- Remove the obsolete note disclaiming Python3 support.
- Remove the obsolete note disclaiming SDL2 support.  SDL2 works well
  now.
- Recommend libpng, since SConstruct will try to use it in the default
  configuration.
- Note the presence of Linux packaging files for Arch, RPM systems, and
  Gentoo.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/473>
2019-11-18 05:05:56 +00:00
Kp b399794a53 Remove test for unconverted characters after a superx= line
Historically, Descent ignored any trailing unconverted characters.  The
logic in Descent 1 was tightened in 3368390f37, and then the logic in
Descent 2 was made to mirror Descent 1 in 19699037ce.  Restore the lax
parsing logic in both games.

Reported-by: InsanityBringer <https://github.com/dxx-rebirth/dxx-rebirth/issues/464> (issue 5)
Fixes: 3368390f37 ("Check for valid SuperX number") (for Descent 1)
Fixes: 19699037ce ("Move d2x-rebirth/main/bmread.cpp -> similar/main/bmread.cpp") (for Descent 2)
2019-11-18 00:22:34 +00:00
Kp abb000177a Move bm_read_reactor object type check into if(D1)
In Descent 2, `type` is initialized at declaration time, then never
rewritten.  At the end of the function, `Error` is called if `type` has
not been rewritten.  Originally, `type` was hard reset to
`OL_CONTROL_CENTER`, but this reinitialization was removed when
`ObjType` and related data were removed from Descent 2.

Reported-by: InsanityBringer <https://github.com/dxx-rebirth/dxx-rebirth/issues/464> (issue 3)
Fixes: ea7ba7ae87 ("remove ObjType, ObjId, ObjStrength and OL_ constants; use "object" instead of "robot" in some places; draw and place reactors with correct modelnum")
2019-11-18 00:22:34 +00:00
Kp adf12be0be Clear bm_load_sub:fname before use
Later writes do not guarantee null termination.  Clear the entire buffer
first, since it is small.

Reported-by: InsanityBringer <https://github.com/dxx-rebirth/dxx-rebirth/issues/464> (issue 2)
2019-11-18 00:22:34 +00:00
Kp 075b14373a Change Difficulty_level_type from unsigned to signed
Difficulty_level_type is used in arithmetic expressions.  If
Difficulty_level_type is unsigned, then those expressions use unsigned
terms, but some of the expressions were designed to use signed terms and
produce incorrect results when used with unsigned terms.  There is no
strong reason to make Difficulty_level_type unsigned, so switch it to
signed instead of trying to fix every site that uses it.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/471>
Fixes: 1eaaff3016 ("Move Difficulty_level to GameUniqueState")
2019-11-17 23:27:13 +00:00
Kp ba283fb036 Sort mission directories to the top of the list, behind builtin missions
This is an observable change, but hopefully is an improvement overall.
2019-11-17 01:42:09 +00:00
Kp 6f54229f5a Sort missions in subdirectories
Mission sorting is handled in a top-level function after the missions
have been found, so that the special case to promote built-in missions
is only applied at the top level.  Unfortunately, this meant that
subdirectories were not sorted.  Add an explicit sort in a path specific
to subdirectory handling.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/472>
2019-11-17 01:35:08 +00:00
Kp 600dac43d8 Only count a robot as dropped after the object is created
If object creation fails, the counter is not decreased.  This creates an
imbalance by over counting the number of robots in existence.  Avoid
this imbalance by deferring the counter update until after the robot is
created.
2019-11-16 23:14:41 +00:00
Kp c6770c3dde Fix robot accounting when robots drop robots
When a robot drops a robot, the dropped robot is not added to the
level's running accumulated_robots counter, but when the player destroys
that robot, the destruction will be counted.  This imbalance allows the
expression counting the number of not-yet-destroyed robots to underflow,
which then confuses the matcen logic into not creating new robots.

Fix this by incrementing the accumulated_robots count as each dropped
robot is created.

Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/466>
2019-11-16 23:14:41 +00:00
Kp c8c5ed9b86 Merge branch osx-build into master
This change was proposed by an external user as a claimed fix for a
failure to build.  This change has not been tested by the core team.
However, it is a simple change and at worst will break the build.

The change is based in part on advice from recurring contributor
@MaddTheSane.  Neither @MaddTheSane nor @kreatordxx have commented on
the correctness of these changes, though the original author of the
commit, @Sottises, is listed as the origin of the most recent prebuilt
OS X package offered from
<https://www.dxx-rebirth.com/download-dxx-rebirth/>.

Reported-by: Sottises <https://github.com/dxx-rebirth/dxx-rebirth/issues/455>
2019-11-16 22:46:48 +00:00
Kp 93d3793b30 Fix crash entering secret level with music on, and no songs
If music is configured as built-in, and no secret songs are configured,
then BIMSecretSongs is set to a non-null pointer to a zero-element
array.  This triggers a divide-by-zero when the array length is used in
a modulus operation.

Fix this by adding a special case that initializing from an empty vector
calls `reset()`, which causes the underlying unique_ptr to store
`nullptr` instead of `new bim_song_info[0]`.

Reported-by: Daniel-Leontiev <https://github.com/dxx-rebirth/dxx-rebirth/issues/465>
Fixes: c355e207fe ("Refactor song loading")
2019-11-02 04:36:15 +00:00
Kp 2bedba0a2c Only register win32/rbaudio.cpp for Win32/SDL2
Instead of preprocessing out the file for SDL1, skip trying to build it.
2019-10-28 00:45:34 +00:00
Kp f43665917e Merge branch ziplantil/win32-sdl2-cdaudio-sync into master 2019-10-28 00:45:34 +00:00
ziplantil b38f99d7ce modify SConstruct to handle target platform; fix track finish detect code 2019-10-27 14:53:48 +02:00
ziplantil 24fc28c8bd indent fixes, improve comments, other code fixes 2019-10-27 03:11:15 +03:00
ziplantil e664d93ea4 add hack for MCI or CD driver bug (?) 2019-10-27 02:48:20 +03:00
ziplantil 2c5ab8e739 initial version of this, trying to catch MCI events 2019-10-27 02:47:45 +03:00
Kp d2640462cb Backport D2's Dont_start_sound_objects to D1
Descent 2 has a hack, present as far back as I can trace, that
suppresses starting sounds during level load.  The original reason was
not recorded, but this hack has the useful side effect that it avoids
using uninitialized data when set_sound_sources tries to use a Viewer
that has not been reset for the objects of the new level.

Descent 1 lacks this hack, so an invalid Viewer is used, which may
trigger a valptridx trap if the undefined data has an invalid segment
number, and could cause memory corruption in builds which do not
validate the segment index.  The valptridx trap:

```
terminate called after throwing an instance of 'valptridx<dcx::segment>::index_range_exception'
  what():  similar/main/digiobj.cpp:389: invalid index used in array subscript: base=(nil) size=9000 index=65021
```

The backtrace leading to the trap:
```
d1x::digi_link_sound_common (viewer=..., so=..., pos=..., forever=<optimized out>, max_volume=<optimized out>, max_distance=..., soundnum=42, segnum=...) at similar/main/digiobj.cpp:389
0x00005555555a4e2d in d1x::digi_link_sound_to_pos2 (vcobjptr=..., max_distance=..., max_volume=32768, forever=1, pos=..., sidenum=4, segnum=..., org_soundnum=121) at similar/main/digiobj.cpp:483
d1x::digi_link_sound_to_pos (soundnum=soundnum@entry=121, segnum=..., sidenum=sidenum@entry=4, pos=..., forever=forever@entry=1, max_volume=32768) at similar/main/digiobj.cpp:490
0x00005555555c140d in d1x::set_sound_sources (vcsegptridx=..., vcvertptr=...) at similar/main/gameseq.cpp:817
d1x::LoadLevel (level_num=<optimized out>, page_in_textures=1) at similar/main/gameseq.cpp:1022
0x00005555555c2654 in d1x::StartNewLevelSub (level_num=-1, page_in_textures=<optimized out>) at similar/main/gameseq.cpp:1865
```

Backport this hack into Descent 1.  Ultimately, the hack should go away
and data should be loaded in an order that does not access undefined
memory.

Reported-by: Spacecpp <https://github.com/dxx-rebirth/dxx-rebirth/issues/463>
2019-10-26 23:13:14 +00:00
Christian Beckhäuser 2cf0085b1d Removed SDL and SDLmain as default libs for Win32/MinGW, fixing SDL2 build on Windows (SDL1.2 build is not broken by this change). 2019-10-24 09:54:00 +02:00
Kp 15b0ec7f42 Fix externally reported Mac OS X build break
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSGeometry.h:10:9: fatal error:
	  'CoreGraphics/CGBase.h' file not found
    #import <CoreGraphics/CGBase.h>
	    ^~~~~~~~~~~~~~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSGeometry.h:10:9: note: did not
	  find header 'CGBase.h' in framework 'CoreGraphics' (loaded from
	  '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks')
    similar/misc/physfsx.cpp:20:10: fatal error: 'HIServices/Processes.h' file not found
    #include <HIServices/Processes.h>

Since this is an OS X problem, this has only been tested by the original
reporter.

Reported-by: Sottises <https://github.com/dxx-rebirth/dxx-rebirth/issues/455>
Suggested-by: MaddTheSane <https://github.com/dxx-rebirth/dxx-rebirth/issues/455#issuecomment-536164089> # SConstruct part
2019-10-23 03:02:16 +00:00
Kp d056611989 Fix mglobal.cpp build in clang-9
clang-9 reports:

```
similar/main/mglobal.cpp:210:44: error: 'report_error_uses_exception' is a protected member of 'valptridx_specialized_type_parameters<unsigned char, 90, valptridx_untyped_utilities::report_error_style::exception, valptridx_untyped_utilities::report_error_style::exception>'
template <typename T, bool = valptridx<T>::report_error_uses_exception::value>
                                           ^
similar/main/mglobal.cpp:229:16: note: in instantiation of default argument for 'instantiation_guard<dcx::active_door>' required here
template class instantiation_guard<dcx::active_door>::type::index_range_exception;
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/include/fwd-valptridx.h:42:2: note: constrained by protected inheritance here
    protected valptridx_specialized_types<managed_type>::type
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/include/cpp-valptridx.h:175:8: note: member is declared here
    using report_error_uses_exception = std::integral_constant<bool,
```

Add a `using` statement to switch `report_error_uses_exception` to
`public` access.  Nothing else uses it, and there is no design purpose
served by keeping it `protected`.
2019-10-23 02:58:41 +00:00
Kp 781a7366a9 Whitelist Vertigo smelter's phoenix cannon
Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/458>
Fixes: 2bcc7bb371 ("Only create lasers for known weapon types")
2019-10-21 03:45:29 +00:00
Kp fc81a56e68 Add workaround for clang header search limitation
clang searches for its installed headers relative to the path of the
program calling it, which doesn't work when the caller is a custom
program running from directory other than the system clang installation
directory.  Add a hook to the compilation database support to let the
user inject extra flags into the database, which can be used to add
`-isystem $PATH_TO_INSTALLED_CLANG_HEADERS` to the recorded commands, so
that when the clang library loads the compilation database, it finds the
headers.
2019-10-21 03:45:29 +00:00
Kp 9d22103d45 Prevent markers spinning in marker-camera-enabled games
Commit 0df57f5b0f changed markers' movement type from MT_NONE to
MT_SPINNING, since retail code assigned a spin rate, suggesting markers
were meant to spin.  However, in some anarchy games, markers are used as
player-positioned cameras.  Spinning the cameras makes them hard to use.
Resolve this by preventing markers from spinning in such games.

Fixes: 0df57f5b0f ("Fix retail bug that prevented marker spinning")
Reported-by: flpduarte <https://github.com/dxx-rebirth/dxx-rebirth/issues/456>
2019-10-02 02:06:00 +00:00
Kp 950b365b0a Merge psyke83:gcc8_rpifix into master
psyke83 reports that Raspbian Buster with gcc 8.3.0 rejects the
`-isystem=dir` form.  The `=dir` form does not work on any gcc I can
test, so conditionally keeping it for other systems does not seem
worthwhile.

Requested-by: psyke83 <https://github.com/dxx-rebirth/dxx-rebirth/pull/453>
2019-09-29 22:04:02 +00:00
Kp 61021d58ce Merge psyke83:rpi_mesa_gl into master 2019-09-18 02:26:03 +00:00
Kp b438f0f704 Fix TypeError in default_opengles, default_sdl2
Commit 452d58a0b5 switched from passing a list of strings as the
right-hand side of `in` to passing a parenthesized string.  The new form
causes a TypeError if the left hand side is None:

```
>>> None in ('1', '2')
False
>>> None in ('1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'in <string>' requires string as left operand, not NoneType
```

Add a trailing comma to turn the right hand side back into a list of
strings, as it was before the Raspberry Pi commit.

Fixes: 452d58a0b5 ("Update Raspberry Pi Mesa build for Buster & Pi 4B")
2019-09-18 02:19:23 +00:00
Christian Beckhäuser dafdcb8596 Rework of the Descent 2 final boss fade-to-black effect introduced in 5b18219aac4dd535e2803de9310ba26dfa7acc28: In the original game the silent 2 second countdown would lapse before the screen faded to black. In restoration, it would fade to black as the countdown started. This rework fixes this discrepancy. 2019-09-17 21:49:18 +02:00
Conn O'Griofa 452d58a0b5 Update Raspberry Pi Mesa build for Buster & Pi 4B
The new Raspberry Pi 4B revision has a minimum requirement of Raspbian
buster, and uses the Mesa V3D driver by default; in fact, the legacy
Broadcom drivers are no longer compatible with its VideoCore VC6 chip, so
building against Mesa is mandatory for this Pi revision.

Unfortunately, the Debian buster version of the Mesa packages
have intentionally dropped the GLESv1 headers, making building of GLESv1
software impractical (even though the VC4/V3D driver can still run GLESv1
applications).

The OpenGL driver in conjunction with SDL2* runs at full
speed on Raspberry Pi 3B & 4B, so it makes sense to modify the "mesa"
build to this configuration in light of these facts.

* SDL2 is highly desirable due to the availability of the KMSDRM driver, which is
the only way to run dxx-rebirth outside of X (we can no longer use
the dispmanx/rpi driver of SDL1).
2019-09-17 13:45:11 +01:00
Conn O'Griofa b30833196c SConstruct: remove equals sign from RPI -isystem definitions
When targeting Raspberry Pi with legacy drivers, the following error
is observed on Raspbian buster with gcc 8.3.0:

cc1plus: error: =/opt/vc/include: No such file or directory [-Werror=missing-include-dirs]
cc1plus: error: =/opt/vc/include/interface/vcos/pthreads: No such file or directory [-Werror=missing-include-dirs]
cc1plus: error: =/opt/vc/include/interface/vmcs_host/linux: No such file or directory [-Werror=missing-include-dirs]

The error can be resolved by removing the equals sign from these definitions.
2019-09-17 03:33:27 +01:00
Kp 427f45fdd7 Update Arch PKGBUILD
- Quote variables.
- Use https:// where possible.
- Combine mkdir calls.
- Fix broken links to GOG game pages.
2019-09-14 20:54:08 +00:00
Christian Beckhäuser 5b18219aac Restored fade to black after defeating the final Descent 2 boss which was lost along with software rendering screen fade effects. New implementation is done in similar way as the fade to white after regular countown reaches 0 while trying to restore the original effect as faithfully as possible (except that it doesn't pause the game during the effect). 2019-09-12 14:54:55 +02:00
Christian Beckhäuser b97091cf70 Added Arch PKGBUILDs 2019-09-12 13:29:17 +02:00
Kp 95abeb0d64 Fix SConf for Windows/SDL2
On all platforms, libSDL redefined `main` in a way that interfered with
SConf tests.  On some platforms, but not on Linux, libSDL2 does not
redefine `main`.  Based on a remark in the SDL2 migration guide, and the
apparent success (on Linux) after removing the `#undef`, I removed use
of `#undef` when building for SDL2.  As privately reported by zico,
libSDL2 on Windows still redefines `main`, so it still needs an explicit
`#undef` to let the SConf tests build correctly.  For platforms where
`#undef` is not needed, it is harmless.  Add this `#undef`
unconditionally, and update the inline comment.

Fixes: f491059ed7 ("Enable building with SDL2")
Reported-by: zicodxx <private>
2019-09-05 01:55:41 +00:00
Kp d6b2ab51a7 Merge branch 'Daivuk:axis_buttons' into master
Requested-by: Daivuk <https://github.com/dxx-rebirth/dxx-rebirth/pull/452>
2019-09-01 18:15:26 +00:00
daivuk 74ef8b02e6 Added axis buttons
Each axis can act as two buttons in both ways.
For example, a player might map slide left and slide right to J1 -A1 and J1 +A1 as button presses instead of the slide L/R axis.

This is mostly to fix XBox 360 Controller Left and Right triggers. But it can work on every axis if the player wishes to bind them.
2019-09-01 13:11:14 -04:00
Kp 183f11cc68 Do not charge player for failed primary weapon shots
Defer decreasing energy/vulcan until the object is confirmed to be
created.  This avoids charging the player for a shot that cannot be
created due to object exhaustion.

Defer updating Next_laser_fire_time, so that a player can immediately
try firing again.
2019-09-01 00:20:28 +00:00
Kp b6fd9eafd7 Do not charge player for failed secondary weapon shots
Defer decreasing energy (for flares) or secondary weapon count (for
secondaries) until the object is confirmed to be created.  This avoids
charging the player for a shot that cannot be created due to object
exhaustion.
2019-09-01 00:20:28 +00:00
Kp 275c4297fe Write back Final_boss_countdown_time on every update
Otherwise, unless FrameTime exceeds Final_boss_countdown_time in a
single frame, the time never advances and the level never ends.

Fixes: 215252b8ca ("Fold Final_boss_is_dead into Final_boss_countdown_time")
2019-09-01 00:20:28 +00:00
Kp 33c893e3e2 Make del+shift+b do fatal damage to every robot it explodes
Run through more of the normal death logic for the robots, instead of
simply deleting them from existence.
2019-09-01 00:20:28 +00:00
Kp 29c3551fa9 Fix crash loading endlevel data with no exit side
Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/450>
2019-08-31 17:31:51 +00:00
Kp 6629711b59 Import RPM spec file 2019-08-29 02:40:32 +00:00