Commit graph

9872 commits

Author SHA1 Message Date
Kp f73b783095 Generate kconfig udlr relations at build time 2017-12-24 00:28:35 +00:00
Kp 0106833538 Move kconfig ui tables to separate file 2017-12-24 00:28:35 +00:00
Kp c09aab491b Fix max_buttons_per_joystick=0 max_hats_per_joystick!=0 build
Internally, hats are treated as a group of 4 buttons.  Disabling all
buttons while not disabling all hats caused a build error.  Since no one
reported this, this configuration is likely not used.  Make the simple
fix of coercing max_hats_per_joystick to 0 when max_axes_per_joystick is
0.
2017-12-24 00:28:35 +00:00
Kp 44154f155a Fix max_joysticks=0 build
Fixes: 7311712399 ("Compile out joystick key settings when DXX_MAX_JOYSTICKS=0")
2017-12-24 00:28:34 +00:00
Kp 0a95ecc3a6 Mark changed values in kconfig UI 2017-12-15 04:47:30 +00:00
Kp 07895c086a Enforce anarchy-only flag for D1
hengyn45 reports that D1 improperly allows cooperative games on anarchy
only maps.

D1 seems not to have implemented this for a very long time, if ever,
although the code existed in commented out form.  When the trees were
combined, the commented out form was treated as blank, so the
restriction was placed inside a #if-d2 guard.  There is no reason to
make this D2-only.  Remove the guard so that D1 enforces anarchy-only.

Reported-by: hengyn45 <https://forum.dxx-rebirth.com/showthread.php?tid=1017>
2017-12-14 04:41:35 +00:00
Kp 0edf08cfbc do_powerup_frame: reject invalid vclip frametime
vclip::frame_time equal to 0 would cause an infinite loop.
vclip::frame_time less than 0 would cause the loop to run until
underflow, which could be very slow if frame_time is near 0.
2017-12-07 05:45:41 +00:00
Kp 544fc0f893 Add support for increased precision of gamelog timestamps
- Enable display of subsecond (Linux: microseconds; Windows:
  milliseconds) precision on gamelog timestamps.
- Add disabled support for YYYY-MM-DD leaders on gamelog timestamps.
  Activate it by defining DXX_CONSOLE_TIME_FORMAT_YMD to true.
- Add disabled support for capturing caller __FILE__, __LINE__ in calls
  to con_printf, con_puts.  Activate it by defining
  DXX_CONSOLE_SHOW_FILE_LINE to true.  If captured, write those to
  gamelog after the timestamp and before the text.  This feature (and
  only this feature) requires that DXX_HAVE_CXX_BUILTIN_FILE_LINE be
  defined, which is conditional on if the compiler has __builtin_FILE()
  and __builtin_LINE().  If the compiler lacks this support, attempts to
  enable this feature are ignored.
- Switch to using GetLocalTime on Windows.
2017-12-06 05:14:32 +00:00
Kp 01e1b28d71 Replace useless printf with puts 2017-12-05 05:29:55 +00:00
Kp 9ba159366e Eliminate macro for con_puts
Use a universal reference and type traits to identify which strings can
be measured at compile time.
2017-12-05 05:29:55 +00:00
Kp 7311712399 Compile out joystick key settings when DXX_MAX_JOYSTICKS=0 2017-12-05 05:29:55 +00:00
Kp 35bd791d32 Remove obsolete kconfig TABLE_CREATION code
It generates code different from the current definitions, even when no
logical changes are present.  This code has not been used in at least 2
years, since commit bc7c469ab2 ("Use
array<> for more globals") changed the definitions of some variables
that this code regenerates, and this code still generates the old
definition.  Future changes will cause further deviation.
2017-12-05 05:29:55 +00:00
Kp 1f333868eb Fix proximity bomb failure-to-spin
Commit 7d36df315e restructured
draw_weapon_vclip, but unintentionally broke the spin of proximity bombs
because `modtime` could exceed `play_time * 2`, causing
`draw_vclip_object` to clamp `bitmapnum` to the last frame of the
animation.  Switch from `-=` to `%=` so that modtime is always brought
back in range.

Reported-by: Descender1032 <https://forum.dxx-rebirth.com/showthread.php?tid=1005>
Fixes: 7d36df315e ("Simplify draw_weapon_vclip")
2017-12-02 04:31:26 +00:00
Kp bcb3f6b486 apply_force_damage: check object type before accessing ctype union
When `apply_force_damage` was called to damage a robot, it tested if the
`ctype.laser_info.parent_signature` of the other object matched
`ConsoleObject->signature` and, if so, awarded points to the console
player.  This allowed the player to sometimes get points for ramming a
robot to death, but was buggy.  When the player rams a robot, the player
is the other object, so accessing `ctype.laser_info` is wrong.
Historically, the player's signature was zero and player
`ctype.laser_info.parent_signature` (an inactive and therefore incorrect
branch of the union) happened to be zero, so the test succeeded.  Commit
44753209d6 changed the layout of
`struct player_info` such that
`ConsoleObject->ctype.laser_info.parent_signature` was not zero, causing
the player not to be his own parent.  Prior to this commit, the player
could still wrongly fail the test if the `player_info` member that
aliased `laser_info.parent_signature` was nonzero.  In the commit
preceding the obvious break, `player_info.player_flags` aliased
`laser_info.parent_signature`, so a player with certain flags (such as
invulnerability) would wrongly fail the test.  The exact manifestation
has changed over time as `struct player_info` gained members.

Restructure the test so that a ramming kill always awards points,
without checking ancestry.

Reported-by: Descender1032 <https://forum.dxx-rebirth.com/showthread.php?tid=1006> (no commit identifiers given)
Fixes: 44753209d6 ("Move homing_object_dist to object.ctype.player_info")
2017-12-02 04:31:26 +00:00
Kp e952ebdd4a Restore GOG reference in INSTALL.markdown
GOG.com resumed selling Descent 1 and Descent 2, albeit as separate SKUs
rather than the historical bundled SKU.  Restore the GOG reference in
INSTALL.markdown.

Reported-by: derhass <https://forum.dxx-rebirth.com/showthread.php?tid=1004>
2017-11-25 01:56:51 +00:00
Kp 8ae4ef9eb5 Fix traps due to invalid level data
`Descent 2: Counterstrike` level 9 specifies a control center trigger on
a side with no wall.  This is not valid.  In normal play, wall_toggle
silently ignored this, and newdemo_pop_ctrlcen_triggers had undefined
behavior.  Add a warning in wall_toggle to report levels like this.  Add
handling in newdemo_pop_ctrlcen_triggers to detect and suppress this
bogus data.

`Descent 2: Counterstrike` level 11 specifies a control center trigger
on a side with no child segment.  This is not valid, so
newdemo_pop_ctrlcen_triggers again had undefined behavior.  Add handling
to detect and suppress this bogus data.

Reported-by: Descender1032 <https://forum.dxx-rebirth.com/showthread.php?tid=992>
2017-11-25 01:56:51 +00:00
Kp c60c0352f0 Fix songs_play_file use for sdlmixer=0 2017-11-25 01:56:51 +00:00
Kp 8376504a34 Fix menu.cpp build failure for sdlmixer=0
When sdlmixer=0, opt_sm_mtype1 is not defined, but was used.  Preprocess
out the use.
2017-11-25 01:56:51 +00:00
Kp e53e969d92 Update Gentoo ebuilds
- Add descentX-freedata-1.ebuild to manage the freely downloadable
  music, German briefings, and (for Descent 1 only) higher resolution
  textures.  These can be added/removed without rebuilding the game, so
  they get a separate ebuild.  This prevents reinstalling these
  resources on game upgrades, and permits using these resources with
  live ebuilds.
- Fix $LICENSE to reflect Rebirth 2014 license change.
- Add USE=+joystick.  When unset, SDL joystick support is unnecessary
  and Rebirth is built without joystick support.  This reduces
  code size, which may be important on constrained targets.  When
  USE=joystick is set, SDL joystick support is now required.
- Add blockers for co-installation with <d1x-rebirth-0.59.100,
  <d2x-rebirth-0.59.100, as these install files of the same name and
  would otherwise collide with this package.  Compiling while the older
  version is installed is safe, so this is only an RDEPEND blocker.
- Add USE flags for the various descentX-freedata features, and depend
  on a descentX-freedata with those flags enabled.  When all such flags
  are clear, there is no dependency, since descentX-freedata with USE=-*
  installs no files.
- Add commented out IUSE_RUNTIME to record which USE flags are
  runtime-only.  When Portage implements IUSE_RUNTIME, this definition
  should be uncommented.
- Mirror xdg integration from main Gentoo Portage ebuild for Rebirth.
  Also match layout with that ebuild where possible, to simplify sharing
  changes.  Notable differences remaining:
  - Gentoo Portage ebuild handles freedata assets inline.
  - Gentoo Portage ebuild disallows enabling both music pack USE flags,
    even though the files install to separate names.  Rebirth freedata
    ebuild permits both to be enabled.
  - Gentoo Portage ebuild hard-enables joystick support and
    hard-requires SDL joystick support.  Rebirth ebuild makes it
    optional via USE=joystick.
  - Gentoo Portage ebuild is less strict about SDL_mixer features.
  - Gentoo Portage ebuild has USE=+data to control whether game data is
    a required dependency.  Rebirth ebuild hard-depends on game data
    (but still provides a choice of demo data or retail data).
  - Gentoo Portage ebuild hard-blocks _all_ d1x-rebirth, d2x-rebirth
    package versions.  Rebirth ebuild hard-blocks only such packages
    that would cause a file collision, so that the transition
    meta-packages can be installed.
  - Gentoo Portage ebuild carries two useless patches.
    - $P-flags.patch removes default CXXFLAGS flags, even though
      SConstruct adds them to the left of the user's CXXFLAGS, so that
      user CXXFLAGS override default flags.
    - $P-sharepath.patch changes the sharepath by patching SConstruct.
      Rebirth ebuild changes the sharepath by passing an appropriate
      `sharepath=` argument to the `scons` call.
  - Gentoo Portage ebuild lacks USE=editor and associated build of Descent
    editor mode.
  - Gentoo Portage ebuild does not export PKG_CONFIG.
2017-11-25 01:56:51 +00:00
Kp d42fff397b Fix Windows exception log short stack
The Windows exception handler probes the stack to determine how much can
be safely dumped, up to a fixed maximum number of bytes.  A logic error
caused the probe function to start its stack probe lower than intended,
so the eventual dump code logs fewer pre-exception bytes than intended.
Fix that error so that the dump shows more pre-exception bytes.

Also, log the address of the ud2 instruction, so that the effective load
address of the module can be determined.  Without this, ASLR makes
reading the dumps needlessly difficult.
2017-11-18 04:45:50 +00:00
Kp e5496d3aaf Consume trailing newline for Rebirth.rotate.robot directive 2017-11-18 04:45:50 +00:00
Kp 479ac8761f Add experimental D2 support for D1 style robot briefings 2017-11-13 01:59:49 +00:00
Kp 720e5661d6 Update INSTALL.markdown to reflect dropped support for <gcc-4.9
Using <gcc-4.9 has been unsupported since introduction of `extern
constexpr` variables broke using gcc-4.8.  Update the install
instructions accordingly.

When referencing 4.9, qualify it as 4.9.4 due to gcc bug #66501 [1]
(present in 4.9.2, fixed in 4.9.4).  As discussed in "Socket error upon
hosting or joining a second multiplayer game"
<https://github.com/dxx-rebirth/dxx-rebirth/issues/289>, this bug caused
a strange miscompilation in Rebirth.  Although that specific
miscompilation has been worked around, there is no guarantee that the
code is and will remain free of other constructs that gcc-4.9.2
mishandles due to that bug.  Using 4.9.2 (as Debian Jessie did) mostly
works, but there is no sense encouraging users to use a known buggy
compiler when a fixed version is readily available.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66501
2017-11-11 18:03:08 +00:00
Kp 425b78b8a6 Fix clang build failure on flicker_timer_disabled
clang rejects 0x80000000 as a non-type template argument of type `int`
due to narrowing.  Use `INT32_MIN` instead, which has the same numeric
value, and should be accepted without requiring narrowing.

Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/353>
Fixes: 88832e3679 ("Use constexpr integral_constant for various magic numbers")
2017-11-07 00:44:59 +00:00
Kp ff49e949d4 Fix savegame thumbnail previews
Transposed arguments to fill_n caused rls_stretch_scanline to write
garbage to the preview buffer.

Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/354>
Fixes: 8aadb4be5b ("Use fill_n instead of inline loop to write scanline")
2017-11-06 04:24:16 +00:00
Kp 09963e8b5a Remove write-only Seg_scale 2017-11-05 20:49:09 +00:00
Kp f742e44091 Simplify lighting test 2017-11-05 20:49:09 +00:00
Kp c33f343d0b Return side_none for openable_doors_in_segment failure path 2017-11-05 20:49:09 +00:00
Kp a4ed8d5c9c Hold morph_rate constexpr 2017-11-05 20:49:09 +00:00
Kp 7eadc218a6 Add debugging code to trace global canvas updates 2017-11-05 20:49:09 +00:00
Kp d049f738c8 Convert various gr_set_current_canvas calls to reference form 2017-11-05 20:49:08 +00:00
Kp 4f40b9de18 Assert that a canvas is not referenced when it is destroyed 2017-11-05 20:49:08 +00:00
Kp ca804d5186 Clear canvas to fix missing exit tunnel movie
Global variable `grd_curcanv` is set to a variety of canvases, some of
which are local stack variables.  Use of global variables in this way is
fragile, but works as long as the global is not used beyond the life of
the backing local.

Unfortunately, some existing uses do access the canvas beyond the
lifetime of the backing local.  Playing movies sets the font of the
current canvas.  If the current canvas is an expired stack variable,
setting the font overwrites other stack data.  This data corruption
causes various symptoms, such as inability to play the escape tunnel
movie.

Prior to 03cca2b3dc, the corruption on
playing the endlevel movie had no user-visible effect.  That commit
created a large local variable, which changed stack layout.  Starting
with that commit, the corruption causes the movie to play as all black.

Fix this, and protect against some other data corruption possiblities,
by clearing the global when the local goes out of scope.

Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/345> (only as cutscene failure to play, not as the underlying corruption issue)
2017-11-05 20:49:08 +00:00
Kp 49c0cdae2e Simplify calls to gr_set_default_canvas
Rather than use an inline wrapper and rely on the compiler optimizer to
redirect gr_set_current_canvas(nullptr) to gr_set_default_canvas,
rewrite all relevant calls directly in the source.

git grep -l 'gr_set_current_canvas' | xargs sed -i -e 's:gr_set_current_canvas(\s*NULL\|nullptr\s*);:gr_set_default_canvas();:'
2017-11-05 20:49:08 +00:00
Kp b7641e17eb Hide PF_UVS,PF_LS from OGL build
Only the SDL build uses them.  Preprocess them out of the OGL build.
2017-11-05 20:49:08 +00:00
Kp 6043168d51 Move various SDL-only texture mapping functions to !DXX_USE_OGL
The OGL build compiles, but does not use, various texture mapping
functions.  Move these to be built only for the SDL build.
2017-11-01 02:01:21 +00:00
Kp 87686e5962 Pass fade value to c_tmap_scanline_shaded as a parameter
Writing it to a global so that the called function can immediately read
it back is wasteful.  Pass it as a parameter.
2017-11-01 02:01:21 +00:00
Kp f598542f35 Simplify helix orientation calculation 2017-11-01 02:01:21 +00:00
Kp 5d4d3347e6 Remove unused found_poly 2017-11-01 02:01:20 +00:00
Kp 3fbc710ec5 Move various SDL-only scanline functions to !DXX_USE_OGL
The OGL build compiles, but does not use, various scanline functions.
Move these to be built only for the SDL build.
2017-11-01 02:01:20 +00:00
Kp 92c6196396 Remove long-dead SLEW_ON code
Defining SLEW_ON breaks the build due to use of member variable names
not used since before the D2X import in 2001.

`unifdef -USLEW_ON -m -- similar/main/endlevel.cpp`
2017-11-01 02:01:20 +00:00
Kp 8684cf5571 Remove unused gr_bitblt_dest_step_shift
It is always 0, and has been since it was imported in D2X.
2017-11-01 02:01:20 +00:00
Kp 5e563ca3c0 Remove unused OGL c_tmap_scanline_per
scanline.cpp defined two implementations, one in a `#if 1` and the other
in an else.  Keep the enabled one.  Delete the other.
2017-11-01 02:01:20 +00:00
Kp aa6ca60a03 Remove unused OGL c_tmap_scanline_lin
Keep the SDL c_tmap_scanline_lin, which is used.
2017-11-01 02:01:20 +00:00
Kp 3276590084 Merge branch 'psyke83/rpi' into master
psyke83 reports that Debian distributions for Raspberry Pi now require a
different name for some video libraries.  Merge psyke83's SCons
enhancements to add support for the new names while retaining support
for the old names.
2017-10-26 02:02:50 +00:00
Kp 1eb29c6e71 Set raspberrypi EnumVariable ignorecase=2 to avoid user confusion
ignorecase=1 coerces the user's input only for validation, but retains
the original case for later processing.

ignorecase=2 coerces the user's input for all purposes, and retains the
coerced form for later processing.

Since other code compares the `raspberrypi` variable to specific values
from the whitelist, user input must be mapped to that whitelist both for
SCons validation and for that later code.  With ignorecase=1, a user
could set `raspberrypi=MESA`, which would pass SCons validation, but
then not be treated as equal to `mesa` when computing default values.
With ignorecase=2, `raspberrypi=MESA` will be recorded as `mesa` and
compute the desired default value.

Fixes: 166b1ecd4d ("RPI: update vendor library names & add Mesa VC4 build support")
2017-10-26 01:58:28 +00:00
Kp 8838b46e65 Suppress PhysFS deprecation errors
PhysFS 2.0 only offers PHYSFS_read/PHYSFS_write for I/O.  PhysFS 3.0
deprecates PHYSFS_read / PHYSFS_write and offers PHYSFS_readBytes /
PHYSFS_writeBytes.  Converting Rebirth to use the new API is somewhat
invasive, and would require dropping support for PhysFS 2.0.

For now, for compatibility with PhysFS 2.0, disable the deprecation
errors and continue to use the older functions.

Reported-by: gabeotisbenson <https://github.com/dxx-rebirth/dxx-rebirth/issues/352>
2017-10-22 04:20:35 +00:00
Conn O'Griofa 166b1ecd4d RPI: update vendor library names & add Mesa VC4 build support
Vendor library has new names to avoid conflicts with Mesa. Update
raspberrypi argument to use new libraries and support Mesa VC4 driver.

* raspberrypi=1 will build against the (newly named) vendor libraries
* raspberrypi=mesa will target building against the VC4 driver.

Both will select GLES by default, but you can target GL for the VC4 driver
via "raspberrypi=mesa opengles=0"
2017-10-22 02:50:13 +00:00
Kp 8d80300e0a Remove obsolete D1 hostage editor code
This code was part of a feature abandoned before retail.  It cannot be
usefully used in campaigns.  Remove it to reduce code size and simplify
later changes.
2017-10-14 17:10:31 +00:00
Kp 96bc6f2047 Use enumerate for medrobot AI mode boxes 2017-10-14 17:10:31 +00:00