Commit graph

9932 commits

Author SHA1 Message Date
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
Kp e035fb215a Cache width in libmve decoder 2017-10-14 17:10:31 +00:00
Kp 255655e8e7 Reduce scope of switch.cpp for loop variables 2017-10-14 17:10:31 +00:00
Kp 2e7dce83c6 Use enumerate for gamefont arrays 2017-10-14 17:10:31 +00:00
Kp 22b22a4a70 Use enumerate for verifying Effects 2017-10-14 17:10:31 +00:00
Kp e58956ddeb Simplify digi_audio_stop_all_channels 2017-10-14 17:10:31 +00:00
Kp 4d271f6d5e Simplify wiping Cyberman field 2017-10-14 17:10:30 +00:00
Kp 450d2f727c Use range_for for endlevel array stars 2017-10-14 17:10:30 +00:00
Kp 88832e3679 Use constexpr integral_constant for various magic numbers 2017-10-14 17:10:30 +00:00
Kp 666539b88f Define valptridx factory typedef earlier 2017-10-14 17:10:30 +00:00
Kp 3ad6972a03 Read pkg-config modversion before flags, not after
Reading modversion after flags can cause confusing output if the flags
load successfully, but the modversion call fails.
2017-10-14 17:10:30 +00:00
Kp 12369d2dd8 Add SConstruct modeline to set tabstop=4 2017-10-14 17:10:30 +00:00
Kp 8f4a20e65b Set Environment CXX earlier
SCons tries to probe the compiler designated by CXX before Environment()
returns.  Set CXX in the call to Environment so that it probes the
correct tool.
2017-10-14 17:10:30 +00:00
Kp 49da5bd5f7 Suppress blank builddir from CPPPATH 2017-10-14 17:10:30 +00:00
Kp e9d8c3c784 Only include linker version if linker path is available
If resolving the linker path fails, ld_path is not usable to run an
external program, but DXXProgram tried to use it as such.  Test ld_path
before using it.
2017-10-14 17:10:29 +00:00
Kp b9af2dbedb Only shlex.split pkg-config paths from user
Splitting auto-generated paths is wasteful, but almost always harmless
on Linux.  However, Windows uses backslash as a path separator, which
conflicts with its standard meaning as an escape character.  Using
shlex.split on a generated Windows path strips required backslashes,
causing a later failure to find the command.  Move the shlex.split call
to apply only to user-specified paths.

Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/349>
2017-10-14 17:10:29 +00:00
Kp d0f709381d Fix build break when using Windows as a host platform
ef314159 reports that running SCons on Windows fails with an
AttributeError exception.  `os.uname` is not available on Windows, but
SConstruct assumed it was.  Trap the error and report a machine of
`None`, since this is purely for logging.

Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/348#issuecomment-334657171>
Fixes: 1ed7cec714 ("Tighten __builtin_constant_p check to handle gcc-7")
2017-10-07 00:54:55 +00:00
Kp af863fdef7 Parenthesize SCons message() call to print
When print_function is imported (or Python 3 is used), print without
parentheses is an error.  Historically, SCons has used only Python 2 and
has not enabled print_function.  This may change, so add parentheses to
the one affected site.  None of the print_function features are used, so
this should work in both Python 2 and Python 3.
2017-10-07 00:54:55 +00:00
Kp 8291391b7f Fix D2 emulation of D1 boss teleport handling
Descent 1 bosses could always teleport, but were only placed in large
areas where free teleporting was always permitted.

Descent 2 boss 1 was placed in a confined segment and not permitted to
teleport out of it until it was opened.  This was implemented by a
two-part change relative to Descent 1 rules:

- Descent 1 bosses were always permitted to teleport to any teleport
  destination segment.  Descent 2 bosses were only permitted to teleport
  if the player was visible or the boss had recently been hit.
- When computing the permitted list of teleport destination segments,
  Descent 1 used directly connected accessible segments, then stopped.
  Descent 2 started with this rule, but if the list had at most 1 entry,
  then it would assume this is the confined boss and recompute the list
  with the first wall ignored.  This recomputed list allowed the boss to
  teleport to any segment in the larger arena outside its starting
  segment.

After D2X-Rebirth support for emulating Descent 1 bosses was enhanced in
28bd4c1650, Descent 1 bosses gained the ability to teleport out of a
confining cube early, but only in D2X-Rebirth when emulating Descent 1.
In D1X-Rebirth, when a boss is placed in a confining cube, it can always
teleport, but only to that confining cube.  In D2X-Rebirth, Descent 1
bosses retain the always-teleport rule of Descent 1, but gained the
Descent 2 rule for expanding its search to the surrounding arena.  It
should only use the expanded search when it also abides by the Descent 2
restriction not to teleport before the first wall is opened.  It did not
abide by that rule.  This commit adds that restriction for Descent 1
bosses.

Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/348>
Fixes: 28bd4c1650 ("Enable D1 boss behavior in d2x build. So we get correct boss behavior when emulating D1, and 3rd party mn2s can include D1 bosses.")
2017-10-06 01:59:09 +00:00
Kp 0909b126ac Simplify gr_rle_expand_scanline_generic
Both the `if` and `else` paths had the same loop and post-loop
processing.  The `if` path was a strict subset of the `else` path.  The
`else` path had one setup statement, and was otherwise equal to the `if`
path.  Move the shared statements outside the guarded path.
2017-10-06 01:59:09 +00:00
Kp 8aadb4be5b Use fill_n instead of inline loop to write scanline 2017-10-06 01:59:09 +00:00
Kp c3434e61d3 Enable PF_USES_THRUST when reseting multiplayer flags
Commit b1b5de4 switched from enabling select physics flags to setting
those flags and clearing all others.  Unfortunately, flag PF_USES_THRUST
was omitted from the enabled list, so it was disabled on reset.  It is
required to let player ships move.

Reported-by: Sottises <https://github.com/dxx-rebirth/dxx-rebirth/issues/347>
Fixes: b1b5de4297 ("Additional safeguard for bug #306")
2017-10-03 01:31:33 +00:00
Kp d4e8a92932 Apply SoundFx control to in-game movies
lukeman3000 asked how to control the volume of the in-game movies.
Prior to this commit, there was no in-game solution to this.  This
change scales movie audio by the SoundFx slider.

Thanks to lukeman3000 for inspiring this change.  Thanks to Ryusei117
for explaining what videos needed to be affected, and for testing an
earlier iteration of the change.

Requested-by: lukeman3000 <https://forum.dxx-rebirth.com/showthread.php?tid=986>
2017-10-01 20:31:34 +00:00
Kp f60c783ef5 Move marker preservation into object lifeleft update 2017-09-30 18:00:15 +00:00
Kp 2665869c24 Mark editor groups broken
Editor groups write `struct segment` to a file in raw form, but had no
code to enforce that this raw form remained stable over time.  Various
changes to `struct segment` have repeatedly changed its internal
structure.  Each change created an incompatible dialect of the editor
group file, and all the dialects share the same version number.

According to
```
git log -p -L'/struct segment {/,/};/:common/main/segment.h' HEAD --not 0.58.1-d1x 0.58.1-d2x --
```
`struct segment` changed layout in:

* d1c6b89f17 ("Move dsx::segment -> dcx::segment")	[D1 only]
* 596ecbb38d ("Rename segment::value to segment::station_idx")	[D1 only]
* 6f10a67c09 ("Move segment::sides to end")
* c53b734abb ("Compute slide segments early")	[D2 only]
* 40e90fea22 ("Move Light_subtracted[] to Segments[].light_subtracted")
* a65d774c83 ("Improve packing of struct segment")
* c70c6c98b3 ("Remove obsolete segment::degenerated flag")

Mark editor groups as broken to avoid making the mess worse.  If anyone
cares about group support, it needs to be rewritten not to depend on the
internal layout of `struct segment`.
2017-09-30 18:00:15 +00:00
Kp 7bae498c45 Cache bitset::operator[] result 2017-09-30 18:00:15 +00:00
Kp 657bd59012 Use array<>+move for draw_model sort_list 2017-09-30 18:00:15 +00:00
Kp 4cfd5f3324 Pass canvas to menubar_init 2017-09-26 04:15:50 +00:00
Kp 6bd653bb16 Drop useless test in render_side
Descent 2, but not Descent 1, had a useless test in render_side:

	type == QUAD ? 0 :
		type == TRI_13 ? 1 :
		0

This is useless since, if type is not QUAD, the second expression will
apply.  If type is QUAD, then the type is not TRI_13, so the second
expression would choose the same result as the first.  The extra
comparison does not save any work, so it is useless.  Remove it.
2017-09-26 04:15:50 +00:00
Kp f2a8be23a9 Prefer dict.get() over try/except KeyError in SConstruct 2017-09-26 04:15:50 +00:00
Kp d7e97ca299 Remove write-only Escort_kill_object
Parallax never implemented Escort_kill_object because it was considered
too much work.  Remove the write-only vestiges of that feature.
2017-09-26 04:15:50 +00:00
Kp bba7e3a153 Move menu_number_bias_wrapper bias into type signature 2017-09-26 04:15:50 +00:00
Kp 1641c87765 Reuse WALL_IS_DOORWAY result in render_side 2017-09-26 04:15:50 +00:00
Lukasz Pawelczyk 9da7ed9e27 Fix build break on OSX
msgbox_error() is defined for both Cocoa and Carbon so the define
should not be used.
2017-09-10 13:27:55 +02:00
Kp 783bd90a72 Make automap PCX optional 2017-09-10 04:28:41 +00:00
Kp 7c0cdd6c51 Fix crash loading Vertigo briefing
Commit 1335af4b51 restructured briefing number parsing, but
unintentionally changed the parser not to drop the newline after a
number.  The briefing parsing code is very sensitive to minor changes,
so this broke parsing some briefing screens, including Vertigo briefing
screens after the first.  After the change, clicking through the Vertigo
briefing aborts on failure to load a PCX file.

Fix this by consuming the newline before returning.  This matches the
previous semantics.

Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/343>
Fixes: 1335af4b51 ("Simplify get_message_num")
2017-09-08 00:56:37 +00:00
Kp 456e239ae3 Use reference for ai_local 2017-09-08 00:56:37 +00:00
Kp 0548384d2a Fix excessive lavafall damage
Like many things in the main game loop, lavafall handling was
historically done on a per-frame basis, then its effects were scaled to
FrameTime to normalize the results.  Ignoring rounding errors, this
produced roughly equivalent damage for high framerate users (who
experienced many but small damage hits) and low framerate users (who
experienced few but large damage hits).  However, the randomized
movement was not scaled to FrameTime, which caused differing results for
high framerate users versus low framerate users.  Commit b36c6f20c7
tried to fix this by forcing scrape_player_on_wall to run at a capped
maximum effective frame rate, then scaling the damage in
check_volatile_wall accordingly, so that high framerate users would
experience fewer damage hits, but the ones they received were larger,
thus maintaining approximately the same damage as before.

Prior to b36c6f20c7, damage was always scaled to FrameTime.  In
b36c6f20c7 and later, damage scaled to max(FrameTime,
DESIGNATED_GAME_FRAMETIME), causing users with a high frame rate (and
thus low FrameTime) to take more damage on each pass.  This damage
increase was balanced by an added hack in scrape_player_on_wall to limit
the frequency of the scrape so that high framerate users would skip some
scrapes, giving them a virtual frame rate appropriate to
DESIGNATED_GAME_FRAMETIME.  However, the damage is only balanced if the
new governor is used consistently.  It is not used consistently, so it
caused a regression for passable lava surfaces.  Scraping on a solid
lava surface goes through scrape_player_on_wall and respects the
governor.  Touching a passable lava surface (only available in Descent
2) bypasses scrape_player_on_wall and jumps directly to
check_volatile_wall, thereby bypassing the governor.  This allows high
framerate users touching a passable lava surface to take many hits (as
they always did), but not receive the full benefit of downward scaling
the damage (as they once did) due to the new max() expression.  Thus,
they are damaged frequently, but still take damage consistent with being
damaged infrequently.

Fix this by moving the hack from scrape_player_on_wall to
check_volatile_wall, so that both solid lava surfaces and passable lava
surfaces respect the governor.  The governor is still an ugly hack that
should not be global, but this is a spot fix for the immediate problem.

Fixes: b36c6f20c7 ("Made scrape_player_on_wall() based on a timer. Due to the player being pushed away from the lava/water surface in every frame in a random vector (wrong, too), player movement per frame was not enough to counter this on FPS rates > ~120 which made damage scaling per frame nonsensical in these situations. Instead, execute scrape results in intevals based on DESIGNATED_GAME_FRAMETIME (or per frame if FrameTime>DESIGNATED_GAME_FRAMETIME) which fixes the issues and generally works much better for the purpose of this function.")
2017-09-08 00:56:37 +00:00
Kp aeedadba89 Unify D1/D2 scrape_player_on_wall 2017-09-08 00:56:37 +00:00
Kp a24490033f Allow players to remove thief at level start
Commit f4b21088a0 ("Track vulcan ammo explicitly") fixed an original
retail bug that prevented the thief from stealing energy weapons,
because the thief could only steal weapons for which the player had ammo
and energy weapons never have ammo.  This went unremarked for several
years, until a recent report of the new semantics as a game-breaking
regression because the thief is now "ridiculously potent".

Address this report, as well as an intermittently raised issue from
various users over time, by adding two new knobs to both the single
player "Gameplay" menu and the multiplayer setup screen: "Remove Thief
at level start" and "Prevent Thief Stealing Energy Weapons".

"Remove Thief" deletes the thief object during level load.  It has no
impact on save games, and changing it after entering a level has no
effect on any thief already in the level.

"Prevent Thief Stealing" is checked at the moment of theft and, when
enabled, prevents stealing primary weapons other than Vulcan/Gauss.
This can be changed at will in single player and is immediately
effective.  In multiplayer, this option can only be changed by the game
host in the pre-game setup.

For both knobs, there is one pair of checkboxes to control this as a
player preference, which applies in single player games.  There is a
second pair of checkboxes in the multiplayer setup, which applies only
to multiplayer games.  Therefore, in multiplayer, the host chooses thief
settings and all clients use the host's choice.  The host may configure
the thief differently in multiplayer from how the host plays in single
player.

For users who wanted to remove the thief, no specific tally has been
kept for who requested it or when.  Now that the code is being updated,
this is thrown in as an easy addition.

Reported-by: MegaDescent <http://forum.dxx-rebirth.com/showthread.php?tid=980> (for the thief stealing energy weapons as a game-breaking regression)
2017-08-26 19:47:52 +00:00
Kp 4ea9ef5b0c Use reference for robot_info 2017-08-26 19:47:51 +00:00