Commit graph

10896 commits

Author SHA1 Message Date
Kp df9a2bacf1 Handle gcc-10 truncation warnings in net_udp.cpp
gcc-10 warns that the game information text may be truncated, because it
overestimates the maximum possible length of some strings.  Handle the
warning by changing the format string to explicitly truncate these
strings at their maximum legal lengths.
2020-05-17 23:35:25 +00:00
Kp f30b77c116 Handle gcc-10 truncation warning in mission.cpp
gcc-10 warns that if immediate_directories were very large, the sprintf
result would be truncated.  This is true, but a user is extremely
unlikely to have enough directories to trigger this code path.  Handle
the warning by explicitly returning an empty string if truncation would
otherwise occur.  This is not strictly correct, but it can be handled
with very little code, eliminates the warning, and is unlikely to matter
in practice.
2020-05-17 23:35:25 +00:00
Kp a4f2edfaa9 Move LevelSharedVertexState into d_level_shared_segment_state 2020-05-17 23:35:25 +00:00
Kp f577788665 Use C++17 fold expressions to simplify serialization code 2020-05-17 23:35:25 +00:00
Kp 99a03b21ce Simplify serial:process_buffer self-selection filter
Use std::enable_if, so that the second argument becomes part of the
parameter pack instead of requiring explicit handling.
2020-05-17 23:35:25 +00:00
Kp 72c5221e0b Use if constexpr instead of std::enable_if
This reduces the size of the generated debug information, but produces
the same code.
2020-05-17 23:35:25 +00:00
Kp 9ed64013bc Decorate SConf C++ standard tests
Add per-test comments to ease identifying which test is responsible for
a given section.
2020-05-17 23:35:25 +00:00
Kp 6a4a8a62c9 Add unit tests for serialization code 2020-05-17 23:35:25 +00:00
Kp fc46e9a97c Only reduce laser power in D2 mode
As reported in pull #507, the D1 implementation of the reduction was
incorrect and never reduced laser power.  Therefore, when D2 emulates
D1, D2 should emulate the effect of the bug, by not reducing laser
power.
2020-05-06 03:04:45 +00:00
Kp 44c4f0bde0 Move is_laser_weapon_type into #ifdef D2
The preceding commit eliminates the only use of is_laser_weapon_type by
D1 code, so now the function can be moved into a #ifdef D2 block.
2020-05-06 03:04:45 +00:00
AlumiuN 072bb54ff2 Exclude D1 player lasers from the quad laser damage reduction
The code that provides the 0.75x multiplier to laser bolts when they're fired
using the quad laser is present in D1 as in D2, however it is incorrect and
results in it not being applied. As such, it is more accurate to exclude the
multiplier when compiling D1.

Thanks to SaladBadger for the tip.
2020-05-04 20:20:41 +12:00
Kp 2f3a76ab15 Revert laser weapon type checking to 0.58.1
Commit 2bcc7bb371 restricted
Laser_create_new to only create lasers for known weapon types.  This
seemed like a good idea, but broke custom levels that use undocumented
laser types.  It also replaced logic that coerced invalid weapon numbers
into a type 1 laser with logic that prevented firing such weapons at
all.  This rendered robots with unknown or broken weapon data unable to
fire.

Commit 0c30fa7cf3 relaxed the logic to
prevent firing only in editor builds, but allow firing unknown or
invalid weapon types in release builds.  Firing unknown weapon types may
work.  Firing invalid weapon types may cause the game to crash when data
is accessed beyond the end of the defined weapon data.  This caused the
crash reported in issue #506.

Revert to the 0.58.1 rule that invalid weapons are coerced to be a
player level 1 laser.  Add a diagnostic when such a weapon is fired,
since the level author should have requested that weapon explicitly if
that was intended.

Reported-by: heftig <https://github.com/dxx-rebirth/dxx-rebirth/issues/506>
Fixes: 2bcc7bb371 ("Only create lasers for known weapon types")
2020-05-02 21:18:43 +00:00
Kp 399aee8d49 Use dedicated type for object render_type
Check conversions.  On invalid input, coerce to RT_NONE and print a
warning.
2020-05-02 21:18:43 +00:00
Kp 6f8ae448c7 Use exception, not Error, for invalid weapon render_type 2020-05-02 21:18:43 +00:00
Kp fa0d57961d Use runtime check for instance_stack overrun
Replace assert with std::array<>::at(), so that an exception will be
thrown if the array bound is exceeded.
2020-05-02 21:18:43 +00:00
Kp 619ac0abff Use structured bindings for enumerate+zip 2020-05-02 21:18:43 +00:00
Kp ea0f4eb02a Use C++17, not C++14
This only changes the version of the standard used.  It does not
introduce use of new functionality.
2020-05-02 21:18:43 +00:00
Kp 755186ada2 Remove use of deprecated std::iterator 2020-05-02 21:18:43 +00:00
Kp 3ce1f2b3ed Require support for C++11 addressof 2020-05-02 21:18:43 +00:00
Kp db7b4b3f88 Refer to <memory> directly, not through "compiler-make_unique.h" 2020-05-02 21:18:43 +00:00
Kp 3add38df3d Require support for C++14 std::make_unique 2020-05-02 21:18:42 +00:00
Kp cc38cdf4b8 Qualify uses of std::make_unique 2020-05-02 21:18:42 +00:00
Kp 8839f538e0 Refer to <array> directly, not through "compiler-array.h" 2020-05-02 21:18:42 +00:00
Kp 3170b11997 Modernize typedefs for std::array types
Use `using x = y;` instead of `typedef y x;`.
2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 9cee93abb1 Require support for C++14 std::exchange 2020-05-02 21:18:42 +00:00
Kp b4d974e5b2 Remove register; it has no effect, and will be deprecated in C++17 2020-05-02 21:18:42 +00:00
Kp ddc25b59b7 Explicitly zero-initialize object structure members
C++17 will require this in order for `object::object()` to be constexpr.
Add it here, before switching over.
2020-05-02 21:18:42 +00:00
Kp e4323bf192 Fix gcc-7 build
The existing test for gcc pr #82541 was insufficient, and allowed using
-Wduplicated-branches with gcc-7 in some cases it should not.  Extend
the test to cover these cases.
2020-05-02 21:18:42 +00:00
Kp f0a47c358b Tell clang that GNU extensions are fine in GNU++14 mode 2020-04-28 04:09:47 +00:00
Kp b2672ae79e Merge 'refs/pull/505/head' into master 2020-04-28 04:09:47 +00:00
Matt Montag 7ec771e89a Fix bug in select_file_handler
newpath is a std::array and does not decay to char* automatically.
Use data() method to get char[], which does decay to char*.

This compile-time issue only affected Mac OS X.
2020-04-26 11:39:03 -07:00
Kp 49138117e4 OSX: log FRAMEWORKPATH, FRAMEWORKS from the construction environment 2020-04-26 17:26:23 +00:00
Kp 03318382d0 Only search for frameworks in directories that exist
mmontag reported that the OS X linker warns when attempting to search a
framework directory that does not exist.  Suppress this warning by
checking for the directory and not adding it to the search path if it
does not exist.

Reported-by: mmontag <https://github.com/dxx-rebirth/dxx-rebirth/issues/503#issuecomment-619457491>
2020-04-26 17:26:23 +00:00
Kp a6590fa496 Update SConstruct test for -Wold-style-cast on OS X
mmontag reports that <HIServices/Processes.h> is no longer available,
and the change from 15b0ec7f42 needs to be
applied to SConstruct as well.

Reported-by: mmontag <https://github.com/dxx-rebirth/dxx-rebirth/issues/503#issuecomment-619463994>
2020-04-26 17:26:23 +00:00
Kp 333d619858 Update tool_bundle.py to parse correctly under Python3
mmontag reports that tool_bundle.py cannot be parsed under Python 3.
Fortunately, the errors are all straightforward, so non-OS X systems can
see the errors when the file is imported.  Normally, the file is only
imported when building for darwin, so non-OS X systems do not see the
problem.

- Add parentheses to print() calls.  This is not consistent with the
  rest of the Rebirth output scheme, but is simple to do.
- Adjust the syntax for raising exceptions.

Reported-by: mmontag <https://github.com/dxx-rebirth/dxx-rebirth/issues/503#issuecomment-619463994>
2020-04-26 17:26:23 +00:00
Kp 95ebb67ad0 Add release note about savegame format change
zicodxx reported in issue #449 that savegames created in a new build,
then loaded in an older one, may behave incorrectly in the old build.
This cannot be fixed in the new build without reverting the logic change
which caused it.  Support for old builds has always been best effort, so
this will not be fixed.  Add a release note about it.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/449>
2020-04-26 17:26:23 +00:00
Kp 705f15161f Simplify argument error reporting 2020-04-26 17:26:23 +00:00
Kp df19889f61 Prefer NSDMI over simple default constructors
This protects against mistakes if more constructors are added, and makes
the code easier to read.
2020-04-26 17:26:23 +00:00
Kp a431f23817 Use enumerated constant for save slot indexes 2020-04-26 17:26:23 +00:00
Kp 0b070880a7 Use C++11 user-defined literals to dispatch valptridx error style
Switch valptridx error style dispatching from using macro pasting to
using C++11 user-defined literals.  This makes the code a bit easier to
read, and removes the need for a C99-conforming preprocessor here, which
should help anyone trying to port to Microsoft Visual Studio.

The new implementation also fixes a limitation of the previous
implementation.  Before, an override that referenced an invalid name
could be silently ignored.  Now, incorrect overrides cause an attempt to
use an undefined instantiation, which fails with a compilation error.
2020-04-26 17:26:23 +00:00
Kp b396445efa Require support for std::index_sequence, std::make_index_sequence
The minimum supported compiler versions now provide a depth-efficient
implementation of std::make_index_sequence, which removes the last
reason to carry a private implementation.  In the case of clang, it
appears to have a special compiler intrinsic used to implement its
std::make_index_sequence.

Switch to the compiler-provided version for both gcc and clang.
2020-04-26 17:26:23 +00:00
Kp d2e190ec3d Update snapshot ebuilds
- Remove the d1x, d2x ebuilds.  Gentoo uses the dxx name now, so the old
  placeholder ebuilds are no longer needed.
- Update the dxx snapshot ebuild to a current commit.
- Resynchronize the dxx snapshot ebuild from the dxx live ebuild.
  - This adds support for USE=valgrind and for USE=data.
- Add a helper script to generate snapshot ebuilds for arbitrary
  commits.
2020-04-19 20:47:07 +00:00
Kp 3b1f33c0c3 Make ebuild dependency on game data configurable via USE=data 2020-04-19 20:47:07 +00:00
Kp 238f529ff4 Clean generated PCH headers
Initialize PCHManager on the clean path, so that the generated headers
are reported to the SCons core.
2020-04-19 20:47:07 +00:00
Kp 5fa8c06914 Add experimental support for autosaves
Set autosave interval to 10 minutes, unless specified in the player's
configuration file.  Players can change the autosave to 0 minutes to
disable it.
2020-04-19 20:47:07 +00:00
Kp ddce1b00d5 Ignore Manifest files in the Gentoo ebuild area 2020-04-19 20:47:07 +00:00
Kp 7d3f4333be Require support for C++14 template variables 2020-04-19 20:47:07 +00:00
Kp f9b90d4e8c Raise minimum required gcc version to gcc-7
gcc-4.9 support is now difficult to test due to system libraries linking
to newer symbols.  gcc-4.9 is unsupported upstream, as are gcc-5 and
gcc-6.  Raise the minimum required gcc version to the minimum version
supported upstream.

Debian Jessie shipped gcc-4.9.2, and support for this target was the
primary motivator for retaining gcc-4.9 support.  Jessie ended regular
support in June 2018, and will end Long Term Support in June 2020.  It
seems unlikely that Jessie would receive a snapshot build of Rebirth in
the months it has left.

Debian Stretch shipped gcc-6, but is currently considered "oldstable"
and has been superseded by Debian Buster.  Further, Debian Stretch
provides a package for gcc-7, so Stretch users can still build Rebirth
using only packages available from the package manager.
2020-04-19 20:47:07 +00:00
Kp a1b3a86cba Use std::chrono::duration for ThisLevelTime, PlayTimeAllowed
Store PlayTimeAllowed in ticks since it is frequently accessed for logic
tests, but only rarely accessed for display.
2020-04-19 20:47:07 +00:00