Commit graph

4906 commits

Author SHA1 Message Date
Kp 86053852dc Fix build of SDL-only gr.cpp 2019-07-07 22:00:02 +00:00
Kp 8d349dd0c1 Include pilot name in window caption 2019-07-07 22:00:02 +00:00
Kp 0c7de10512 Track chosen pilot name outside Players[]
Players need not be defined outside a game, but the pilot's name needs
to be available outside a game.  Therefore, track it outside Players[].
2019-07-07 22:00:02 +00:00
Kp bfeca84bb8 Change object::signature to be a generation counter
This removes the need to walk all objects when creating a new one, since
each object can have a private generation counter, unaware of other
objects.  For compatibility with demos, mix in the object's index when
writing the signature value.
2019-07-07 22:00:02 +00:00
Kp efc071e830 Make init_player_stats_ship static 2019-07-07 22:00:02 +00:00
Kp d750b25073 Avoid copying background to itself
`init_new_page` calls `load_briefing_screen` with the a pointer to
`br->background_name`, which causes a strncpy of the form

```
	strncpy(X, X, N);
```

Valgrind warns for this overlap.  The copy is useless in that case, so
skip it.
2019-07-07 22:00:02 +00:00
Kp 597cb41717 Downgrade PCX failures from Error to CON_URGENT
There is no need to kill the program due to a missing or malformed PCX file.
2019-07-07 22:00:02 +00:00
Kp 3a0cca001f Limit size of PCX files 2019-07-07 22:00:02 +00:00
Kp 75de1c23c1 Reduce ship rocking during countdown
A prior change switched to using the greater, rather than the lesser, of
`16` or `Countdown_seconds_left`, which increased the rotation from the
ship rocking effect.  Switch back to use the lesser value.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/431>
Fixes: 644d6fa513 ("Simplify do_countdown_frame ship rocking effect")
2019-06-28 01:14:36 +00:00
Kp 1eaaff3016 Move Difficulty_level to GameUniqueState 2019-06-27 03:26:20 +00:00
Kp 61755f4d68 Factor out difficulty adjustment to energy usage 2019-06-27 03:26:20 +00:00
Kp ba3d3107bc Backport auto-select of vulcan when energy exhausted
This was added to D2, but is useful in both games.  Apply it in D1, too.
2019-06-27 03:26:20 +00:00
Kp a4f06f1f51 Backport MK's mega/lava fix to D1 2019-06-27 03:26:20 +00:00
Kp cfb481c74a Add experimental support for guidebot in multiplayer
This was requested by a user in early 2018.  However, the proposed
prototype was susceptible to various forms of desynchronization, and was
unsuitable for merging.  No further revisions were proposed, and the
feature languished.  This commit enables the guidebot in cooperative
games and addresses the known synchronization problems, as well as some
other bugs that were uncovered during light testing.  This is classified
as an experimental feature because it has not been heavily tested in
complicated games.

Requested-by: cfeuersaenger <https://github.com/dxx-rebirth/dxx-rebirth/issues/364>
2019-06-27 03:26:20 +00:00
Kp bea95ce1df Reset definedness of per-game globals on new game 2019-06-27 03:26:20 +00:00
Kp 644d6fa513 Simplify do_countdown_frame ship rocking effect 2019-06-27 03:26:20 +00:00
Kp 171ad60262 Fix some type mismatches using player_path_set_orient_and_vel 2019-06-27 03:26:20 +00:00
Kp d03a6c44b8 Register new pilots on menu creation, not activation 2019-06-27 03:26:20 +00:00
Kp f1878254df Simplify automap drawing of other players 2019-06-27 03:26:20 +00:00
Kp aacdaa77fe Use std::find_if in create_buddy_bot
Avoid open-coded for loop.
2019-06-27 03:26:20 +00:00
Kp d5510bfc82 Fix harmless robot ID check warning
`make_nearby_robot_snipe` computed the `robot_info` of every `object` in the
area before checking whether those `object`s were of type `OBJ_ROBOT`.  This
is wrong, but usually harmless since it checked the type before using
the resulting `robot_info`.  Starting in commit 9f26e2211, this triggered
a warning whenever `make_nearby_robot_snipe` checked nearby non-robot
`object`s.

Rewrite the tests to check for type `OBJ_ROBOT` before reading the
`object`'s id.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/429>
Fixes: 9f26e2211e ("Warn on invalid object ID access")
2019-06-21 02:51:49 +00:00
Kp 0105777b43 Fix highest_level tracking for D1X-Rebirth with First Strike
Commit 9898d13 fixed a crash on long filenames, but also tried to
optimize the Destination Saturn hack.  However, this optimization was
implemented incorrectly, and caused the game to read only the
Destination Saturn highest_level entry when playing the First Strike
campaign, rather than using the greater level of Destination Saturn or
First Strike.

Restore the old logic, but restrict it to D1X.  D2X never used an empty
string for the First Strike campaign, so this logic could not trigger
there, which is also how the bug was missed in initial testing.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/428>
Fixes: 9898d136f1 ("Fix fortification crash loading missions with long filenames")
2019-06-21 02:51:49 +00:00
Kp e671664332 Vary get-behind path for robots 2019-06-20 04:02:27 +00:00
Kp af166735cc Use enum class for player visibility 2019-06-20 04:02:27 +00:00
Kp 5ab50520b7 Remove unused vec_to_player in D1 ai_follow_path
Only Descent 2 uses this field.
2019-06-20 04:02:27 +00:00
Kp 72f04b9828 Remove exploding wall assertion
In multiplayer, the host sends a destroy message for both sides of the
wall.  `do_exploding_wall_frame` processes both, but
`num_exploding_walls` is only decreased by 1, causing an assertion
failure at the end.  Remove the assertion, since the wall does not
explode instantly on join, despite being marked as WALL_EXPLODING.
2019-06-20 04:02:27 +00:00
Kp 4b4479b59a Split copyright/trademark lines to separate con_puts calls
This allows each line to have its own timestamp, which looks more
consistent in gamelog.txt.
2019-06-20 04:02:27 +00:00
Kp 459f754da5 Add workaround for PhysFS 3.0 ignoring symlinks to directories
PhysFS 3.0 tests whether archive members are directories, but treats a
symbolic link that points to a directory as distinct from the underlying
directory, even when symlink following is enabled.  As a result, if
$D2X_REBIRTH_HOME/missions is a symlink to a directory, then it is
ignored and no missions are available.  In PhysFS 2.0, the link was
followed and the missions were available.

Add a trailing dot to the path, which already has a trailing slash, to
force PhysFS to consider the underlying directory, not the link.
2019-06-20 04:02:27 +00:00
Kp 7e362f9433 Fix undefined behavior in D1 briefing setup
In one path, load_briefing_screen is called with `br->background_name`
as an input.  This caused a call to `snprintf(a, sizeof(a), "%s", a);`,
which is undefined behavior.  Switch back to the prior style of
unconditionally declaring a local array, performing filename
manipulation in that array, and copying the array back to
`br->background_name` afterward.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/420>
2019-05-30 03:29:24 +00:00
Kp 3a5b4ddd7b Fix clang signed/unsigned mismatch
Fixes: bfcff2cefe ("Fix crash loading guidebot with unreachable goal")
2019-05-28 03:39:23 +00:00
Kp bfcff2cefe Fix crash loading guidebot with unreachable goal
Remove use of object_guidebot_cannot_reach and instead track the
reachability of the object as a separate flag.  This allows the game to
remember when an object was found, but unreachable.  Previously, it
would store only that some unreachable object was found.  Now, it stores
the index of the unreachable object.  This extra information is not used
yet.

Reported-by: Dainslaif <https://github.com/dxx-rebirth/dxx-rebirth/issues/421>
Fixes: c3cead4319 ("Move Escort_goal_index to d_unique_buddy_state")
2019-05-26 00:44:37 +00:00
Kp f79f6ab1cc Make switches invulnerable to blast_nearby_glass
`blast_nearby_glass` calls `check_effect_blowup`, but ignores the result.
If `check_effect_blowup` executes a blow-up effect, and the blown object
is a switch, the return value will instruct the caller to execute the
associated trigger.  Since `blast_nearby_glass` ignores the return
value, it never executes a trigger.  This was originally masked by a bug
that passed undefined data from `blast_nearby_glass` to
`check_effect_blowup`, which usually confused `check_effect_blowup` into
treating the explosion as not originating from the player.  This
confusion then forced an early return when a switch was hit, effectively
accidentally making switches invulnerable to `blast_nearby_glass`.
Commit f6352e7 fixed the data confusion, allowing `check_effect_blowup`
to recognize that the explosion came from a player's weapon.  However,
it did not add handling for the trigger, so now `blast_nearby_glass` can
destroy the switch without activating the trigger.  This is at the least
annoying, and in some levels may make progress impossible.  There are
two ways to resolve this:

- Fix the logic to always execute the switch when the switch is
  destroyed, whether by direct hit or by `blast_nearby_glass`.
- Restore the quirk that switches are invulnerable to
  `blast_nearby_glass`.

Conveniently, the `force_blowup_flag` is set by `blast_nearby_glass` and
clear for all other callers, so it can be used to recognize that the
caller will not handle the switch.  Use this to implement choice 2.

Even with this change, a direct hit by a missile can still destroy a
switch and activate its trigger, since that is handled through
`collide_weapon_and_wall`.  Thus, players can still use the technique of
using a guided missile to activate an otherwise impossible switch.

Fixes: f6352e7957 ("Pass correct object to check_effect_blowup")
Reported-by: wm4 <https://github.com/dxx-rebirth/dxx-rebirth/issues/419>
2019-05-11 20:18:29 +00:00
Kp 48527630dd Remove __attribute__((packed)) on shortpos for gcc-9 support
gcc-9 warns on taking the address of an unaligned member in a packed
structure.  This structure does not need to be packed.  Remove
__attribute__((packed)) and fix the code to implement I/O correctly
without packing.
2019-05-11 20:18:29 +00:00
Kp f8769b9805 Fix gcc-9 -Wstringop-truncation in titles.cpp 2019-05-11 20:18:29 +00:00
Kp 2c91eda5bc Fix various gcc-9 -Wformat-truncation warnings 2019-05-06 00:36:16 +00:00
Kp 57a850fce5 Use enumerate() to iterate some MAX_SIDES_PER_SEGMENT loops 2019-05-04 18:27:37 +00:00
Kp eb39a8087e Use xrange for render loops 2019-05-04 18:27:37 +00:00
Kp a7806dde5d Use xrange for loops with constant numerical start and simple identifier end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*\([0-9]\+\)u\?\s*;\s*\2\s*!=\s*\([A-Za-z_0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\3u, \4))/
2019-05-04 18:27:37 +00:00
Kp 3bd10610fc Use xrange for loops with zero start and simple identifier end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*!=\s*\([A-Za-z_0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\3))/
2019-05-04 18:27:37 +00:00
Kp a74914eb9c Use xrange for loops with constant numerical start and end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*\([0-9]\+\)u\?\s*;\s*\2\s*!=\s*\([0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\3u, \4u))/
2019-05-04 18:27:37 +00:00
Kp 538286e02c Add range helper zip() 2019-05-04 18:27:36 +00:00
Kp 2243cd7f58 Use xrange for loops with zero start and constant numerical end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*\(!=\|<\)\s*\([0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\4u))/
2019-05-04 18:27:36 +00:00
Kp 15ac8a5ac6 Add utility xrange for range-based loops with precomputed bounds
Utility xrange, inspired by the Python2 feature of the same name,
provides an object that returns successive values from [start, end).  It
is useful when the end index is known in advance, and is particularly
helpful when that index is expensive to recompute.
2019-05-04 18:27:36 +00:00
Kp b5ddcfdd7b Unify D1/D2 openable_doors_in_segment conditions 2019-05-04 18:27:36 +00:00
Kp 4d8d244bb9 Move spreadfire,helix orientation to player_info 2019-05-04 18:27:36 +00:00
Kp 0675e4bcad Factor out exit tunnel loop 2019-04-28 00:53:40 +00:00
Kp 3f31200997 Unify create_path_points D1/D2 check for doorway 2019-04-28 00:53:40 +00:00
Kp fb6323ed42 Use check_untrusted on boss robot messages 2019-04-28 00:53:40 +00:00
Kp 3e25804026 Use NSDMI wherever possible 2019-04-28 00:53:40 +00:00
Kp 0c99a97c63 Factor out player/fireball light emission 2019-04-13 18:00:07 +00:00