Commit graph

10659 commits

Author SHA1 Message Date
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
Kp d197ba42c3 Fix mouse-selection in listboxes
Commit d355ef4030 removed a seemingly unnecessary modification of the
global variable grd_curcanv->cv_font, after eliminating all local reads
of it.  However, a non-local read, buried in listbox_mouse, depended on
grd_curcanv->cv_font being set to a MEDIUM font.  After that commit,
grd_curcanv->cv_font retained its prior value, which is not a MEDIUM
font.  This caused listbox_mouse to compute an incorrect height of the
lines in the listbox, which manifested as the game choosing the wrong
line when the mouse is clicked in the listbox.

Fix the problem by explicitly using MEDIUM3_FONT, since that was
usually the value left in grd_curcanv->cv_font prior to that commit.  In
some cases, a different MEDIUM font would be left there, but all the
MEDIUM fonts have the same height, so they are interchangeable for this
purpose.

Reported-by: Q3BFG10K <https://github.com/dxx-rebirth/dxx-rebirth/issues/498>
Fixes: d355ef4030 ("Pass font to various drawing functions")
2020-04-04 19:30:23 +00:00
Kp 23ebf27554 Move digi functions to dcx; use bitset for channels 2020-04-04 19:30:22 +00:00
Kp 3f8aced47d Check for converted sounds before doing any work 2020-04-04 19:30:22 +00:00
Kp 714c13b3c1 Move WallAnims into d_game_shared_state 2020-04-04 19:30:22 +00:00
Kp bcff9e6aaa Simplify wall flag assignment
Move the tests up and keep the flags ready to assign.
2020-04-04 19:30:22 +00:00
Kp 443f4f8c83 Avoid reloading ObjBitmapPtrs[i] 2020-04-04 19:30:22 +00:00
Arne de Bruijn a2b49a9a08 Add PIGGY_PAGE_IN to ogl_cache_polymodel_textures 2020-04-04 12:13:59 +02:00
Kp 0fb82b47f6 SDL2: fix size of letterbox sequences
andrew-strong reported that using SDL2, with the window set to full
screen, but a windowed size less than full screen, caused letterbox
sequences, such as the player ship destroyed sequence, to render in a
subwindow sized to the dimensions game would have when unmaximized, even
if the game window is maximized at the time of the sequence.

tycho suggested a change that resolves this issue, and basic testing
showed no unwanted side effects.

Reported-by: andrew-strong <https://github.com/dxx-rebirth/dxx-rebirth/issues/399>
Suggested-by: tycho <https://github.com/dxx-rebirth/dxx-rebirth/issues/399#issuecomment-583688998>
2020-03-28 17:32:34 +00:00
Kp 2e682e140d Prevent sound stacking when all primary weapons are exhausted
ziplantil reported that in Descent 1, if a player has an empty Vulcan
cannon, and no energy, then attempting to fire a weapon would play the
SOUND_ALREADY_SELECTED clip every frame until the player ceased trying
to fire.  The problem does not impact Descent 2 since Descent 2 does not
play this sound sample when trying to activate a weapon that is already
active.

If the current weapon is already LASER_INDEX, then
select_primary_weapon(LASER_INDEX) simplifies to:

```

	// Pointless, player already using this weapon
	newdemo_record_player_weapon(LASER_INDEX)
	if (Primary_weapon != LASER_INDEX) {
		// skipped, path is false
	}
	else
	{
		if (wait_for_rearm)	// true for this path
			// Bad, plays every frame
			digi_play_sample(SOUND_ALREADY_SELECTED);
	}
	// Pointless, Primary_weapon already is LASER_INDEX
	Primary_weapon = LASER_INDEX;
	if (weapon_name)
	{
		// skipped, path is false
	}

```

Skipping the call avoids two pointless statements, one bad statement,
and nothing useful.  Therefore, the simplest fix for the problem is to
call select_primary_weapon(LASER_INDEX) only if the primary weapon is
not currently LASER_INDEX.

Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/499>
2020-03-28 17:09:28 +00:00
Kp af8adaef1b Defer digi_mixer_start_sound work until it is needed
If no channel is available, the mix parameters are unused.  Move their
construction to occur after a channel for the sound is found.
2020-03-28 16:55:43 +00:00
Kp b19496ca72 Set digi_mixer channel callback once at startup
The callback is never changed, so it does not need to be reset on every
new sound.
2020-03-28 16:54:28 +00:00
Kp 6a27ae3544 Prevent copying RAIIMix_Chunk
No code tried to copy it, but if a copy was created, it would cause a
double-free later.  Prevent copying to avoid introduction of a
double-free bug.
2020-03-28 16:51:43 +00:00
Kp 7478eab4c9 Remove references to DXX forum
The forum vanished several months ago and now points to a server with a
bad certificate.  Stop directing people to that hostname.
2020-03-25 02:31:10 +00:00
Kp ed4cb636b7 Fix memory leak when deleting listbox items 2020-03-14 03:41:30 +00:00
Kp a645fd2eba Allocate morph_data vectors dynamically
This greatly reduces the size of morph_data for most uses.
2020-02-26 05:07:34 +00:00
Kp 85a9034137 Move morph_data::morph_deltas into a trailing allocation
Initially, this just makes the code more complicated.  In the end, it
will allow choosing the array size dynamically.
2020-02-26 05:07:34 +00:00
Kp 73612f6667 Move morph_data::morph_vecs into a trailing allocation
Initially, this just makes the code more complicated.  In the end, it
will allow choosing the array size dynamically.
2020-02-26 05:07:34 +00:00
Kp 74f8fd0d4d Move morph_data::morph_times into a trailing allocation
Initially, this just makes the code more complicated.  In the end, it
will allow choosing the array size dynamically.
2020-02-26 05:07:34 +00:00
Kp 00df407381 Use a custom allocation for morph_data
This will enable shrinking the morph arrays to allocate only what is
needed.
2020-02-26 05:07:34 +00:00
Kp ce7cf4f7ef Rename gauges span to avoid conflict with C++20 type of the same name 2020-02-26 05:07:34 +00:00
Kp 5a08c40878 Use zip for morph update_points 2020-02-26 05:07:34 +00:00
Kp 27a96d0337 Simplify partial_range check for unsigned offset/length 2020-02-26 05:07:34 +00:00
Kp 4ec6a13bfa Zip morph polymodel sequences 2020-02-26 05:07:34 +00:00
Kp 9db512a9d6 Simplify Descent2 briefing removal of carriage returns
Read the entire buffer at once, then remove the carriage returns and set
a null terminator.  This reduces the number of calls to PHYSFS_read from
len to 1.
2020-02-26 05:07:34 +00:00
Kp d4c48d80b5 Fix some failures in check_header_includes=1 builds 2020-02-26 05:07:34 +00:00
Kp 707df7b9de Move some newdemo functions into namespace dsx 2020-02-26 05:07:34 +00:00
Kp fd134851d1 Pass context to morph_start 2020-02-26 05:07:34 +00:00
Kp d876874475 Factor out morph model header parsing 2020-02-26 05:07:34 +00:00
Kp aaaf212dca Add unit test for zip iterator 2020-02-26 05:07:34 +00:00
Kp 94401b4085 Pass LevelUniqueMorphObjectState to find_morph_data 2020-02-26 05:07:34 +00:00
Kp 40726aa580 Mark xrange as returning unowned storage
It returns integers by value, not by reference.
2020-02-26 05:07:34 +00:00
Kp c088f15384 Use std::fill to overwrite poisoned ranges
gcc can replace std::fill with memset when the code would be a loop
writing byte values.
2020-02-11 04:48:14 +00:00
Kp 8997b5c801 Fix check_header_includes for Python 3 2020-02-11 04:48:14 +00:00
Kp 3f7149a346 Simplify text decoding 2020-02-11 04:48:14 +00:00
Kp 88087fbbab Move Text_string to dsx 2020-02-11 04:48:14 +00:00
Kp bcf06623a5 Disable morph processing in demo files
It reads uninitialized values, so it was barely functional before
morph_data became a dynamic allocation, and it is broken now.  Disable
it to avoid crashing the game.  The demo code should have initialized
the morph_data structure properly, but does not.

Reported-by: tycho <https://github.com/dxx-rebirth/dxx-rebirth/issues/496>
Fixes: cac5f1da56 ("Move morph_data into dynamic allocations")
2020-02-06 03:22:45 +00:00
Kp f1c6177338 Poison morph_data on allocation
Require the caller to provide sane values later.
2020-02-06 03:22:45 +00:00