Commit graph

233 commits

Author SHA1 Message Date
Kp 679d2fc494 Reduce intensity of weapon fire sounds 2021-06-28 03:37:51 +00:00
Kp e1aac6949a Replace __attribute_warn_unused_result with C++17 [[nodiscard]]
This eliminates a configure test, and may help readers understand the
annotation more readily.
2021-06-28 03:37:51 +00:00
Kp 770ae0cea5 Replace __attribute_noreturn with C++11 [[noreturn]]
This eliminates a configure test, and may help readers understand the
annotation more readily.
2021-06-28 03:37:50 +00:00
Dmitry Grigoryev fbd05a1592 optimize include files (include what you use) 2021-02-06 21:38:50 +01:00
Kp baa2823953 Pass player_info to which_bomb
Previously, rendering the preferred bomb type could also change it if
the active type was exhausted.  This is undesirable, since it depends on
the user to have a HUD mode which causes the bomb type to render.
Switch to only change the active type if the user tries to drop a bomb
while the active type is unavailable.  Some call sites already switch
bomb types automatically on depletion.  Those sites will still do so.
2021-01-17 22:23:22 +00:00
Kp 696141eabf Use enum class for weapon_info::bounce 2020-12-20 20:39:07 +00:00
Kp 7de81a7293 Move Afterburner_charge to dsx 2020-09-11 03:08:02 +00:00
Kp 8e81726ac5 Use enum class for laser_level
Remove stored_laser_level, which existed primarily to enforce type
separate.  `enum class` can do that without the need for a separate
class type.
2020-08-24 01:31:28 +00:00
Kp 038c6aef4d Move d_level_unique_object_state to a separate header
This is required to untangle the cross-inclusion of object.h and
morph.h.
2020-08-10 03:45:14 +00:00
Kp 7ad8d8c28b Rename object::movement_type to movement_source
gcc and clang disagree about how to disambiguate when an identifier is
both a typename and a member.  Avoid the disagreement by renaming the
member.
2020-08-10 03:45:13 +00:00
Kp 5245b1c4a3 Rename object::control_type to control_source
gcc and clang disagree about how to disambiguate when an identifier is
both a typename and a member.  Avoid the disagreement by renaming the
member.

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/532>
2020-08-10 03:45:13 +00:00
Kp 1c42f69ff2 Use enum class for object_signature_t 2020-08-10 03:45:13 +00:00
Kp 38cddb0289 Use enum class for object movement_type 2020-08-10 03:45:13 +00:00
Kp 9e2543ecbf Use enum class for object control_type 2020-08-06 03:47:56 +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 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 30091902af Simplify valptridx types where possible
Switch valptridx::ptr to a reference type.
Switch valptridx::ptridx to a reference type or to ::ptr.

Fix up uses of operator-> accordingly.
2019-12-22 05:34:08 +00:00
Kp 28d9358b00 Expand local aliases to their target variables
This makes the code easier to read, at the price of a bit of churn.
2019-12-16 01:56:59 +00:00
Kp 781a7366a9 Whitelist Vertigo smelter's phoenix cannon
Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/458>
Fixes: 2bcc7bb371 ("Only create lasers for known weapon types")
2019-10-21 03:45:29 +00:00
Kp 183f11cc68 Do not charge player for failed primary weapon shots
Defer decreasing energy/vulcan until the object is confirmed to be
created.  This avoids charging the player for a shot that cannot be
created due to object exhaustion.

Defer updating Next_laser_fire_time, so that a player can immediately
try firing again.
2019-09-01 00:20:28 +00:00
Kp b6fd9eafd7 Do not charge player for failed secondary weapon shots
Defer decreasing energy (for flares) or secondary weapon count (for
secondaries) until the object is confirmed to be created.  This avoids
charging the player for a shot that cannot be created due to object
exhaustion.
2019-09-01 00:20:28 +00:00
Kp 653a705e90 Test that guided missile's parent is still a player
If a guided missile is in flight, and its owning player dies, the
player's type is changed to OBJ_GHOST.  The damage that killed the
player should have put the guided missile into autonomous mode, so for
this purpose, return that the missile is not actively guided.

Reported-by: Johnsondr80 <https://github.com/dxx-rebirth/dxx-rebirth/issues/437>
2019-08-21 02:54:08 +00:00
Kp 6fe1c90aef Make D2 emulate D1 homers in D1 missions 2019-08-15 01:34:22 +00:00
Kp 8997f622bd is_proximity_bomb_or_smart_mine*: s/smart/player_smart/g
As documented in zico's commit 38fabd7c49, robot smart mines have a
different ID number than player smart mines.  Rename the test functions
to clarify that they only recognize player smart mines, but not robot
smart mines.

git grep -l is_proximity_bomb_or_smart_mine | xargs sed -i -e 's/is_proximity_bomb_or_smart_mine/is_proximity_bomb_or_player_smart_mine/g'
2019-08-15 01:34:22 +00:00
Kp ef0e64d421 Move awareness events to d_level_unique_robot_awareness_state 2019-08-06 02:59:40 +00:00
Kp 65555b6eba Require only object_base for object_to_object_visibility 2019-07-27 17:48:03 +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 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 4d8d244bb9 Move spreadfire,helix orientation to player_info 2019-05-04 18:27:36 +00:00
Kp 063bf29225 Enable -Wimplicit-fallthrough=5; fix resulting breaks
This enables using -Wimplicit-fallthrough with ccache+distcc, which
strip the fallthrough comments, but do not strip the attribute
annotationns.
2019-04-04 04:29:03 +00:00
Kp 1008ab397e Move Objects to d_level_unique_object_state 2019-03-03 00:31:08 +00:00
Kp ad6b857cf2 Move most laser_info fields to dcx 2019-02-02 18:36:39 +00:00
Kp e84a65edc6 Move Robot_info into LevelSharedRobotInfoState 2018-12-30 00:43:59 +00:00
Kp 03fe3a6696 Move Polygon_models into LevelSharedPolygonModelState 2018-12-30 00:43:59 +00:00
Kp 040de5b10e Rename ObjectState to LevelUniqueObjectState for consistency 2018-12-30 00:43:57 +00:00
Kp 9360a41816 Move Guided_missile into d_level_object_state 2018-10-08 03:58:48 +00:00
Kp f7ad4d9b1a Pass segments to find_point_seg 2018-09-19 02:13:30 +00:00
Kp c4cb930f8e Pass ObjectState to obj_delete 2018-09-09 01:00:39 +00:00
Kp 30a83eec41 Eliminate some uses of valptridx::operator-> 2018-06-24 05:06:15 +00:00
Kp ad8fd0f871 Pass valptridx factories to obj_relink 2018-03-12 03:43:46 +00:00
Kp 852ab312d5 Remove global Network_laser_track 2018-03-05 01:40:44 +00:00
Kp 5c5ee068ae Allow non-players to use OMEGA_ID weapon
User TRUEpiiiicness reports that valptridx<player>::check_index_range
traps when "The Apocalyptic Factor"[1] level 14 boss fires its Omega-based
weapon.  Code inspection shows that this is expected, since the original
designers assumed OMEGA_ID would only ever be used by players, and coded
various shortcuts accordingly.  No one told the level author this.  The
boss is an interesting concept and not difficult to support, so adjust
the code to handle this situation correctly:

- Check that the shooter is a player before checking its player ID.
  Without this, a robot that happened to have the same ID as the player
  would interpret robot data as player data, likely causing corruption
  when it tried to update the omega cannon charge.  Even if the robot ID
  does not match, this step causes a diagnostic[2] reporting that a
  robot ID is being misused as a player ID.
- Remove the shortcut that assumes the shooter is a player.  Store the
  shooter's actual type.
- Remove the unnecessary and counterproductive path that:
  1. Uses the object pointer to get the player's ID
  2. Uses that player ID to get a player pointer
  3. Uses that player pointer to get an object number
  4. Uses that object number to get an object pointer
  When invariants are maintained, the pointer derived in step 4 is equal
  to the pointer used at the start of step 1.  Use that pointer directly
  instead of rederiving it.  The reported exception was due to step 2,
  which requires that the player ID is in range.  When the shooter is a
  player, this is true.  When the shooter is not a player, it may not
  be true.

[1] http://www.enspiar.com/dmdb/viewMission.php?id=418
```
sha1sum af.hog af.mn2
133c52fb4b4e5fd40bf7b2321789841b727d1d0b  af.hog
0bb5f0dd1803b0fc1aac7c2023eacc97e9ab872b  af.mn2

stat -c '%s %Y %n' af.hog af.mn2
4024838 1094445016 af.hog
566 1013524628 af.mn2
```
[2] `similar/main/laser.cpp:560: BUG: object 0x555556078958 has type 2, expected 4`

Reported-by: TRUEpiiiicness <https://forum.dxx-rebirth.com/showthread.php?tid=1038>
2018-01-29 01:56:40 +00:00
Kp f598542f35 Simplify helix orientation calculation 2017-11-01 02:01:21 +00:00