endlevel wants to freeze the console player's last in-mine position.
Instead of copying the position out and back, refactor the flow to let
endlevel skip the update of the position.
Only the console player's last position needs to be remembered across
frames. Copy the console player's position out before processsing
object movement. For all other objects, retain a temporary for use by
the position recovery code.
Special macros are used to pass information to
`generate-kconfig-udlr.py`. Provide default definitions for these
macros in `kconfig.ui-table.cpp`, and override them in the one build
where they need to be special. This enables `kconfig.ui-table.cpp` to
build cleanly when invoked from the command line in the compilation
database.
Various functions need to access both `shared_segment` and
`unique_segment` data. Using `segment &` for this blocks eliminating
the `segment` type. Add `susegment` and type aliases to it.
`susegment` records a reference to a `shared_segment` and a
`unique_segment` together, so that users cannot accidentally mismatch
`shared_segment` #1 with `unique_segment` #2 when passing references
down to a function which needs both `shared_segment` and
`unique_segment`.
Inserting the compile command for vers_id.cpp into a compilation
database does not quote a string with embedded whitespace, although this
string is correctly quoted when used to invoke a shell. Remove
whitespace from the character whitelist, so that it is always escaped.
gcc considers strong_typedef to be POD both with and without the
explicit default. clang considers it to be POD only if the constructor
is explicitly defaulted.
For correctness, valptridx::ptridx instances must not be sliced down to
their component ::ptr or ::idx base classes. Previously, this was done
with a dummy template parameter to ensure that a bare ::idx had a
different type than the idx base of a ::ptridx. This extra distinction
complicates analysis of the code, and is not needed when the code is
already correct. Add the ability to build without slice checking.
obj_rw is a packed structure, so configurations where reset_hitobj takes
its parameter by reference (or where its parameter requires passing
through a constructor that takes its input by reference) fail because
gcc refuses to bind a reference to a member of a packed structure. Copy
the member variable into a local, which gcc will bind.
In some configurations, gcc (but not clang) instantiate
valptridx<segment>::array_managed_type too eagerly, then fail if the
sizeof(segment) is unknown. Include segment.h so that the size is
available.
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.
- 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>
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)
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")
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")
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>
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.
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>
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>
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")
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>
/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
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`.