Commit graph

5196 commits

Author SHA1 Message Date
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 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 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
Kp 1ce5054fc0 Merge 'refs/pull/517/head' into master 2020-07-02 03:07:17 +00:00
AlumiuN 4425f07e9d Prevent the destruction of one-sided prison doors from causing a crash 2020-06-30 21:40:09 +12: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 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 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
Kp 665713f315 Remove static inline declarations from fwd-partial_range.h
A declaration is useful if it declares an external function.  A static
inline declaration, if not followed by the definition later in the same
translation unit, will not be useful.  Remove such declarations, and
rely on using the definition as a declaration for those files that
actually call partial_range() or similar functions.
2020-06-10 02:25:32 +00:00
Kp 81819c5183 Check range for digi_mixer_find_channel
Avoid walking off the end if digi_mixer_max_channels is too large.
2020-06-10 02:25:32 +00:00
Kp 5c30b467bb Move jukebox_load, jukebox_hook_next to dcx 2020-05-31 23:04:25 +00:00
Kp 81119f0445 Use enum class for LevelMusicPlayOrder 2020-05-31 23:04:25 +00:00
Kp 2e1e142767 Factor out sound_function_table_t where possible
Move it to namespace dcx when this does not cause a dcx->dsx dependency.
2020-05-31 23:04:25 +00:00
Kp d06ad449b8 Always ignore from_hog_only
This fixes PCX loading in the non-editor build.  PCX loading broke in
3114874713 because it switched from PHYSFSX_openReadBuffered to a call
which did not handle the presence of the marker byte in the filename.

The from_hog_only flag has not been properly supported since the
introduction of PHYSFSX_openReadBuffered in
8b323e7214.  Editor builds ignored it on
purpose, and non-editor builds pretended to respect it, only to then
ignore it down inside PHYSFSX_openReadBuffered.  For consistency with
code paths that do not use PHYSFSX_openReadBuffered, disable the bypass
in PHYSFSX_openReadBuffered and remove the code in show_title_screen
that applied the flag.

Reported-by: Jayman2000 <https://github.com/dxx-rebirth/dxx-rebirth/issues/510>
Fixes: 3114874713 ("Delegate PCX loading to SDL_image")
2020-05-28 03:21:22 +00:00
Kp b08620292d Fix input handling in automap
The automap code keeps a mostly-private secondary copy of control_info.
The change to reset control_info before the event loop reset the main
copy of control_info for the automap, not the copy that the automap
actually used.  Fix this by passing the desired control_info to relevant
functions instead of always using the global variable Controls.

Fixes: c621a970c6 ("Reset kconfig counters once, before the event loop")
2020-05-28 03:21:22 +00:00
Kp c621a970c6 Reset kconfig counters once, before the event loop 2020-05-27 03:07:17 +00:00
Kp 954a235d13 Discard decoded cockpit buffer when no longer needed 2020-05-27 03:07:17 +00:00
Kp 5dbdc65ee6 Fix D2 crash on blank line in bitmaps.tbl
Reported-by: InsanityBringer <https://github.com/dxx-rebirth/dxx-rebirth/issues/464#issuecomment-632443732>
2020-05-22 02:40:26 +00:00
Kp 7b52b1fe1d Move grs_bitmap::avg_color into #if !DXX_USE_OGL
This field is used in the SDL build for rendering.  In the GL build, its
only purpose is for the editor to write it to a PIG file.  Change that
one use to compute the value as needed.  Move all other references
behind a preprocessor test for !DXX_USE_OGL.  This shrinks the size of
grs_bitmap by 1 pointer, since the compiler added padding after
avg_color up to the size of the next aligned pointer.
2020-05-22 02:40:26 +00:00
Kp 09eff19a66 Use stack arrays for texture mapping temporaries
The maximum length is small enough that stack arrays can easily handle
the largest values, and this avoids several heap allocations on a hot
path.
2020-05-22 02:40:26 +00:00
Kp 3d0f333b34 Unify object texture setup
Move the load of &GameBitmaps to the common loop used for paging in.
Add range checks on the loops.
2020-05-22 02:40:26 +00:00
Kp c1181b7be5 Move texture_list out of global scope 2020-05-22 02:40:26 +00:00
Kp 3d3db16c6f Move Canvas_width,Canvas_height to local scope 2020-05-22 02:40:26 +00:00
Kp f413017317 Delegate bald_guy_load PCX to SDL image 2020-05-17 23:35:26 +00:00
Kp 83a9b32dc7 Simplify bald_guy_load
Close the file sooner.  Use std::transform with a reverse_iterator to
decode and transpose the blob.
2020-05-17 23:35:26 +00:00
Kp 3114874713 Delegate PCX loading to SDL_image
This adds a new dependency, but most systems likely already have
SDL_image installed.  Use of SDL_image can be disabled, but this is
discouraged, because various in-game interfaces assume the use of the
original background.

The old implementation automatically corrected for filename case.  The
new implementation expects that the supplied filename can be passed to
PYHSFS_openRead as-is.  All known uses in-game have been corrected to
satisfy this requirement.  If the new stricter match requirement becomes
a problem, a variant of PHYSFSRWOPS_openRead that adjusts filename case
could be created for use here.

- Update install instructions
- Update ebuild
- Update Arch PKGBUILD
2020-05-17 23:35:26 +00:00
Kp 71ca1a7553 Do not abort on failure to load PCX
Using assert to check for conditions that can be caused by improper
configuration is wrong.  If the load failed, return.
2020-05-17 23:35:26 +00:00
Kp 16ae2e7b8e Correct case of map PCX files 2020-05-17 23:35:26 +00:00
Kp 699c9bc283 Fix check_header_includes=1 build 2020-05-17 23:35:25 +00:00
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 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 619ac0abff Use structured bindings for enumerate+zip 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 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