Commit graph

10787 commits

Author SHA1 Message Date
Kp 8cc7be4986 Use std::bitset to track used colors
This reduces memory usage over using std::array<bool> for the same
number of bits.
2020-07-16 02:31:04 +00:00
Kp 6af56a27f2 Remove outdated joystick preprocessor guards
Testing for buttons||hats||axes is equivalent to testing for
joysticks!=0, since SConstruct forces joysticks=0 when
buttons == 0 && hats == 0 && axes == 0.  Remove tests of
buttons||hats||axes when those occur inside a test for joysticks!=0.
2020-07-16 02:31:04 +00:00
Kp 4f26a205ea Increase height of kconfig joystick window
The addition of the binding for a menu key causes the axes to float off
the bottom of the window.  Increase the window height to fix this.
2020-07-09 02:47:18 +00:00
Kp 5735175999 Merge 'refs/pull/516/head' into master 2020-07-09 02:47:18 +00:00
Kp a20551191a Remove useless D1 test for TRIGGER_ONE_SHOT
This block previously was used to clear TRIGGER_ON, but that change was
removed because TRIGGER_ON was a write-only flag.  This block is now
useless, so remove it.  This should also fix an obscure crash reported
by AlumiuN.

AlumiuN proposed adding a test that seg->children[side] is still valid,
but since the logic to execute would be useless even when the test
succeeds, it is simpler to remove this code entirely.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/515>
Suggested-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/pull/518#issue-443277182>
2020-07-07 04:09:44 +00:00
Kp 738e4a740e Remove TRIGGER_FLAG::ON; it is write-only
The game clears it in various cases, but never tests for it.  Remove it.
2020-07-07 04:09:44 +00:00
Kp b814434181 Revert "fix invalid polymodels if words_need_alignment=1"
This reverts commit 60edaa7dce.

This commit was brought in through a merge to obtain a different change,
and was supposed to be suppressed in preference to the change from
dfcb0fcdc.  Revert it here, since reloading the variable suffices to fix
the problem, and this commit forces a reload on all platforms, rather
than only reloading on platforms that need it.
2020-07-07 04:09:44 +00:00
Kp 2e979c954d Merge 'refs/pull/519/head' into master 2020-07-05 23:34:33 +00:00
Kp 569802e00f Convert kconfig array lookups to require correct enumerated type
This ensures that an array is indexed by the appropriate type.  Indexing
a mouse array with a joystick index is undefined behavior, and with this
change, such undefined behavior is now a compilation error.
2020-07-05 23:34:33 +00:00
Kp a27b50a357 Use symbolic names to look up kconfig offsets 2020-07-05 23:34:33 +00:00
Kp caf3a71aa2 Remove plx special case for version 0.56.0
That version was a long time ago.  Assume anyone who has not run a build
newer than 0.56.0 by now will not do so.
2020-07-05 23:34:33 +00:00
Kp 9b9642dcac Only enable joystick axis->button bridge if both axes!=0 and buttons!=0
If axes!=0 and buttons==0 and hats==0, then the build fails because some
button-related functionality is missing.  Move the joystick axis->button
bridge into a conditional to exclude it in this case.

Fixes: 74ef8b02e6 ("Added axis buttons")
2020-07-05 23:34:33 +00:00
Kp be1a539898 Reduce lookups of descent.hog size in briefings 2020-07-05 23:34:33 +00:00
Kp 85f0dcde01 Avoid repeatedly reopening descent.hog during briefings
PHYSFSX_fsize opens the file, reads its length, and closes it.  Calling
PHYSFSX_fsize in a loop is wasteful, since the file size should not
change while the game is playing.
2020-07-05 23:34:33 +00:00
Kp c0daa89ad5 Avoid reopening descent.sng
If !canUseExtensions, then fp is already open to descent.sng.  There is
no need to reopen it just to get its length.
2020-07-05 23:34:33 +00:00
Kp 3f951cf45f Use A.size() or std::size instead of sizeof(A)/sizeof(A[0]) 2020-07-05 23:34:33 +00:00
Kp cd37873f1b Use range-for when aligning polygon model submodel_ptrs 2020-07-05 23:34:33 +00:00
Kp 7e36beb30c Move polymodel alignment code to interp.cpp
This makes the alignment data structure `chunk` private to interp.cpp,
and allows most files to ignore whether DXX_WORDS_NEED_ALIGNMENT is
enabled, thus improving the ccache hit rate.
2020-07-05 23:34:33 +00:00
Kp dfcb0fcdc1 Fix truncated polymodel data on words_need_alignment=1 systems
kajott reports that on Raspberry Pi systems, "Medium Hulk and Heavy Hulk
models were missing their heads".  This impacts all systems with
words_need_alignment=1, and was introduced by logic that tried to
truncate invalid polygon models, which was added because such models
often crashed the game.  The validation logic used the original size of
the polygon model data, which is correct on systems with
words_need_alignment=0, but can be too small on systems with
words_need_alignment=1 if the polygon model was enlarged as part of
aligning it.  Such systems would refuse to read past the original,
shorter, length, and then declare the model to be broken and truncate
it.  Fix this by reloading the length from the polymodel structure after
the alignment logic is applied.

Reported-by: kajott <https://github.com/dxx-rebirth/dxx-rebirth/pull/519>
Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
2020-07-05 23:34:33 +00:00
Kp 316a4740a6 Move words_bigendian into if constexpr
`words_bigendian` is `constexpr`, so move the tests on it behind `if
constexpr` to encourage the compiler to prune unreachable paths.
2020-07-05 23:34:33 +00:00
Kp b948da1a1f Replace uses of enumerate with zip where appropriate
In some places, enumerate was used only to get an index value because
zip was not available.  Switch those sites to use zip directly.
2020-07-05 23:34:33 +00:00
Kp d959eeca8f Use zip in kconfig to allow use of range-based for 2020-07-05 23:34:33 +00:00
Kp 6e4b63e098 Use C++17 std::size instead of custom lengthof
lengthof was added to provide the size of C arrays.  C++17 std::size is
now available, and can serve the same purpose.  Remove the custom
lengthof.

The generated code is the same in both cases, other than the change in
line numbers caused by removal of the #include directives.
2020-07-05 23:34:32 +00:00
Kp bbcd5f5973 Use C++17 std::size instead of a custom equivalent
The custom version was used before C++17 was enabled.  Now that C++17
std::size is available, switch to it.
2020-07-05 23:34:32 +00:00
Kp 27724704d7 Use deduction guides to remove one layer of serial forwarding 2020-07-05 23:34:32 +00:00
Kp 0a1f2ad55e Tighten type for trigger action values 2020-07-05 23:34:32 +00:00
Kp 7a790f6068 Inline gr_set_fontcolor
It is a trivial function.
2020-07-05 23:34:32 +00:00
Kp b39c7c4ed2 Move ogl_swap_buffers_internal to dcx 2020-07-05 23:34:32 +00:00
Kp 90d7e39980 Move inclusion of platform-appropriate GL headers to a separate file
Some files may need to include platform GL headers, but not process all
the Rebirth-specific GL code.
2020-07-05 23:34:32 +00:00
Kp a98ddfbe9b Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers.  Fix up various resulting breaks,
which look like bugs:

- Descent 2 editor mode could modify trigger::flags, but used
  TRIGGER_FLAG_* values, which specify the actions for a Descent 1
  trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
  TRIGGER_ON.  Since the flags were just set to 0, the mask operation is
  useless.  Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON.  This seems
  to be completely wrong.  Change it to remove
  trigger_behavior_flags::disabled.  Descent 1 has no (working) support
  for disabling triggers, so make trigger_turn_all_ON exclusive to
  Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games.  Descent 1
  never reads TRIGGER_ON.  Descent 2 uses this field for trigger
  behavior flags, and TRIGGER_ON is not a behavior flag.
  - For Descent 1 builds, remove the modification of the field.
  - For Descent 2 builds, change it to clear
    trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
Martin Fiedler 9dc5a76497 explicitly disable face culling before drawing lines
Normally, this shouldn't matter, and on almost all
OpenGL drivers out there, it really doesn't, but
the Raspberry Pi 4's "V3D" Mesa driver behaves
differently: It simply won't draw any lines as long
as GL_CULL_FACE is enabled, so we need to disable
it.
2020-07-02 22:07:01 +02:00
Martin Fiedler 60edaa7dce fix invalid polymodels if words_need_alignment=1
If compiled with words_need_alignment=1, the
model data was correctly converted and expanded,
but the old size was still used for validating
and initializing the model.

This caused funky effects on affected platforms,
e.g. some robots missing their heads on Raspberry Pi.
2020-07-02 21:56:11 +02:00
Kp 1ce5054fc0 Merge 'refs/pull/517/head' into master 2020-07-02 03:07:17 +00:00
Martin Fiedler f67026de9a avoid empty savegame descriptions
It's possible to enter empty savegame descriptions,
which is no problem itself, but it looks quite
confusing in the save/load menus: you can't see
the currently selected item, for instance.

This commit replaces an empty description with a
placeholder text ("no title") upon saving.

This is particularly useful when controlling
the game only with a joystick, where entering
a proper description isn't possible.
2020-06-30 21:46:06 +02:00
Martin Fiedler aa972c2b93 improved joystick button to keyboard command mapping
Instead of parsing the button name string,
an explicit button-to-key mapping table
is now built and used.

Also fixes a few minor inconsistencies
that were introduced in c24864b1.
2020-06-30 21:18:49 +02:00
AlumiuN 4425f07e9d Prevent the destruction of one-sided prison doors from causing a crash 2020-06-30 21:40:09 +12:00
Martin Fiedler 853a0c41e1 added joystick binding for showing ingame menu
A new configurable joystick button binding is
introduced that opens the ingame menu, i.e. the
menu that appears when pressing the Escape key.

Fortunately, there was still enough space left
in the button binding maps for both games. The
configuration screen, however, needed to be
extended by a row to make room for the new
binding on d2x.

One known issue: When using an old player
configuration file, the menu button bindings
are initially set to J1 B1, because the unused
slots in DefaultKeySettings used to be
initialized that way. There's not much we can
do about that; the player needs to remove
these bogus assignments by hand. We can (and
do) prevent that from happening again, though,
by initializing new player files with correct
unmapped buttons.
2020-06-29 23:16:04 +02:00
Martin Fiedler c24864b180 make menus controllable with joystick
In most menus, keyboard commands are synthesized
from controller buttons, leveraging the existing
axis-to-button translation.

Menu controls are currently fixed:
- button 0 (A) is confirm (Enter)
- button 1 (B) is cancel (Esc)
- button 2 (X) is switch (Space)
- button 3 (Y) is delete (Delete)
- axes 0 and 1 (main analog pad) maps to cursor keys
- all hats (D-pads) map to cursor keys

Title screens and credits can be confirmed
with any joystick button or axis motion too.
2020-06-28 17:08:26 +02:00
Kp 321c272920 Update snapshot ebuild 2020-06-27 17:37:50 +00:00
Kp aba40babb4 Switch pkg_postinst to call xdg_pkg_postinst
EAPI=7 disallows use of `default`.  According to chewi[1], an explicit
call of xdg_pkg_postinst is important.  Add that in place of default.

[1]: https://github.com/dxx-rebirth/dxx-rebirth/issues/502#issuecomment-644112338
2020-06-27 17:37:50 +00:00
Kp e5cae0f699 Remove unused g3_uninit_polygon_model 2020-06-22 00:36:45 +00:00
Kp 096a678ff7 Ignore effects with frame_time=0
If the effect is not ignored, then the game enters an infinite loop
because ec.time_left never increases.

Reported-by: murphy83 <https://github.com/dxx-rebirth/dxx-rebirth/issues/513>
2020-06-19 01:46:54 +00:00
Kp 6ffd62ff7c Update snapshot ebuild 2020-06-15 00:21:35 +00:00
Kp 0c2fcf691f Fix redundancy in package name
${SDL_version} already starts with the string "sdl", so specifying it
again in the package name is incorrect.

Reported-by: dr-diem <https://github.com/dxx-rebirth/dxx-rebirth/issues/502#issuecomment-643828214>
2020-06-15 00:21:35 +00:00
Kp 3a9bdbfa6e Use __slots__ for cached_property
Remove the redundant storage of the method's name, since it is only read
once in the getter.
2020-06-15 00:21:35 +00:00
Kp 8814776780 Use stack arrays for polygon texture mapping temporaries
Similar to 09eff19a66, _g3_draw_poly can
store the control information on the stack to avoid an allocation, since
the total size is bounded and relatively small.
2020-06-10 02:25:33 +00:00
Kp e25ecbb10c Increase multiplayer protocol version number
Cross-play between development builds from different commits is never
guaranteed.  Increase the protocol version number to force everyone to
sync up.  Github user D2Lovin reported that mixing users from two
snapshot builds behaved poorly, but went silent when prompted for more
information.  This bump will force users to synchronize, which is a good
idea on principle.

Related: https://github.com/dxx-rebirth/dxx-rebirth/issues/509
2020-06-10 02:25:33 +00:00
Kp c9508f3dda Use stack arrays for texture mapping temporaries #2
Similar to 09eff19a66, _g3_draw_tmap_2 can
store the control information on the stack to avoid an allocation, since
the total size is bounded and relatively small.
2020-06-10 02:25:33 +00:00
Kp 79e7143254 Reset autosave timer on game load 2020-06-10 02:25:33 +00:00
Kp 46d72a29c0 Retire compiler-begin.h
This was once a compatibility shim, but compiler support for std::begin
has been required since 5e434cbe95 and no
issues have been reported.  Flatten the include tree by removing this
header and using the STL names directly.
2020-06-10 02:25:32 +00:00