Commit graph

11822 commits

Author SHA1 Message Date
Kp 13ca2112fd Avoid repeated valptridx dereferences in polish_path 2022-02-05 13:30:56 +00:00
Kp e15ec1e80d Avoid repeated valptridx dereferences in create_path_points 2022-02-05 13:30:56 +00:00
Kp f55aed4b9b Pass object& to ai_door_is_openable 2022-02-05 13:30:56 +00:00
Kp 2440a271da Improve vulcan/gauss pickup rules
- Change D1X to use D2X rules regarding Vulcan cannon pickup.  The D1X
  rules were confusing at best, and seem outright wrong in some ways.
  - When a Vulcan cannon was picked up, it was treated as containing not
    less than VULCAN_WEAPON_AMMO_AMOUNT rounds, regardless of what it
    actually contained.  D2X respected the actual contained count, even
    when running in D1X emulation mode.
  - In D1X single player, if the Vulcan cannon was not picked up, then
    it could be treated as Vulcan ammo.  If at least 1 unit of
    ammunition was added to the player, the entire powerup would be
    consumed, regardless of how much ammunition remained.
  - In D2X single player, if the Vulcan cannon was not picked up, then
    ammunition would be taken from it, but the powerup would only be
    consumed if all its ammunition was taken.
  - In D1X multiplayer, a player who already had a Vulcan cannon could
    not get anything from touching a new cannon, and the cannon would
    not be changed.
  - In D2X multiplayer, a player who already had a Vulcan cannon could
    take ammunition from the cannon, but the cannon could not be drained
    below VULCAN_AMMO_AMOUNT.  If the cannon had VULCAN_AMMO_AMOUNT or
    less, then the player could not take ammunition.  If the cannon had
    more, the player could drain it to that level.
  - Replace all that with a simplified version of the D2X rules:
    - If the player does not have the cannon, the cannon is picked up
      and removed from the mine.  The player takes as much of its
      ammunition as possible.  If the cannon was well stocked, and the
      player was nearly full, some ammunition will be lost.  This is
      unfortunate, but the game has always had this rule, and changing
      it would require dropping one or more Vulcan Ammo packs to
      represent the untaken ammunition.
    - If the player already had that cannon, then the player takes as
      much ammunition as the cannon has, while not exceeding the
      ammunition cap.  Other players, if any, are updated about how much
      ammunition remains in the cannon.  The cannon remains in the mine.
- Backport to D1X the network message for updating the contained
  ammunition in a vulcan cannon.  zico added the basic feature in
  7684ce92, but only applied it to D2X.  With the change to let D1X
  multiplayer take ammunition from the cannon, D1X now needs the same
  feature.
- Remove the special case to delete an empty cannon.  Instead, let the
  cannon remain in the mine without ammunition.  This allows a player in
  single player mode to leave behind a backup cannon, which could be
  useful if the player is killed and wishes to rearm before returning to
  the death site.  Similarly, under the new rule that players in
  multiplayer can drain the cannon down to 0 ammunition, this removal
  allows the cannon to remain behind for someone else to take, rather
  than allowing it to be deleted by a player who already had an instance
  of it.
2022-02-05 13:30:56 +00:00
Kp 39ca785fbe Remove redundant pick_up_vulcan_ammo call
This is only hit if the call just refused to change the player's
ammunition count, and nothing has changed, so it will just refuse again.
2022-02-05 13:30:56 +00:00
Kp f5684ffda4 Reorder pick_up_vulcan_ammo to keep ammo_count const 2022-02-05 13:30:56 +00:00
Kp 4ae6f52ba9 Simplify respawning anarchy powerups
Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
2022-02-05 13:30:56 +00:00
Kp 7258b7fd59 Merge kreeblah/fix_macos_opengl_test into master 2022-01-30 04:40:54 +00:00
Kp 5f1c4b34ff Fold Darwin GL test using Python ternary expression 2022-01-30 04:38:47 +00:00
Kreeblah 28a6cd26c2
Re-add macOS OpenGL test 2022-01-28 16:46:17 -08:00
Kp 570e373880 Merge branch multi-endgame-discon into master 2022-01-21 03:54:07 +00:00
Arne de Bruijn 7e5b17ff82 Send periodic endlevel packets after last level
Add periodic calls to send_endlevel_packet in kmatrix if
Control_center_destroyed is false.

Needed because after finishing the last level, kmatrix is called from a
different place where Control_center_destroyed is already false.

It looks like this issue was introduced in Rebirth 0.56 with the
split off of the ipx code (febe5d1). That commit removes the call to
multi_endlevel_poll2 from kmatrix_view, which did the same periodic
sends. (Maybe because in D1 Control_center_destroyed was always true
in kmatrix so it was not needed there.)

Reported-by: snytek <#520>
Fixes: febe5d1 ("Abstracting networking protocols")
2022-01-18 17:03:30 +01:00
Kp e306a6fa99 Rework start_wall_cloak to handle clang inlining limit
clang-13 fails to sufficiently inline this construct, causing it to emit
an unnecessary call to check_null_pointer_conversion on a path where
m_ptr is already guaranteed to be non-nullptr.  That call in turn
causes a linker error, since no other site using valptridx<wall> needs
check_null_pointer_conversion instantiated.  Rather than provide the
instantiation, rework the logic to avoid the need for the dead call.
2022-01-15 20:39:10 +00:00
Kp 36e956cd9f Preprocess out unused-but-set variable d2x-rebirth/libmve/mveplay.cpp total
This variable is only used in a print statement which is itself
commented out.  Move the declaration, assignment, and commented print
into a preprocessor guard.
2022-01-15 20:39:10 +00:00
Kp b8ae2c5e55 Remove unused-but-set variables in ogl_texture_stats 2022-01-15 20:39:10 +00:00
Kp 636e1b6d5e Use enumerated_array for unique_side::uvls 2022-01-15 20:39:10 +00:00
Kp 075495aa8b Use enumerated_array for d_level_unique_automap_state::Automap_visited 2022-01-15 20:39:10 +00:00
Kp a7c9a04c20 Use enumerated_array for shared_segment::children 2022-01-15 20:39:10 +00:00
Kp dc2e86760e Use enumerated_array for Side_opposite 2022-01-15 20:39:10 +00:00
Kp 4a6a4c4646 Use enumerated_array for unique_segment::sides 2022-01-15 20:39:10 +00:00
Kp ab9242fb67 Return side ids from get_side_ids 2022-01-15 20:39:10 +00:00
Kp 1c57e1032d Use enumerated_array for shared_segment::sides 2022-01-15 20:39:10 +00:00
Kp 2659400a97 Use sidenum_t for trigger::side 2022-01-15 20:39:10 +00:00
Kp 2d890131fb Disable packing on old trigger structures
It is not necessary, and causes problems when trying to take a reference
to a member.
2022-01-09 15:25:42 +00:00
Kp f47a2c9f0d Convert Side_to_verts to enumerated_array<..., sidenum_t> 2022-01-09 15:25:42 +00:00
Kp c79df55d3e Return segment/side from med_find_closest_threshold_segment_side 2022-01-09 15:25:42 +00:00
Kp 53f098dc5e Return segment/side from med_find_adjacent_segment_side 2022-01-09 15:25:42 +00:00
Kp fbe3bbd0fa Use enum sidenum_t in more places 2022-01-09 15:25:42 +00:00
Kp 4fe9f10e0c Minimize saved weapon box texture
Only save the piece that will actually be shown, rather than the entire
decoded image.
2022-01-09 15:25:42 +00:00
Kp fedb48613c Move object_rw to namespace dsx
It depends on types in dsx.
2022-01-09 15:25:42 +00:00
Kp 78d4a36bb4 Explicitly require support for C++11 constructor inheritance
Parts of the code already used the C++11 syntax, so compilers without it
were already unsupported.  Expand the remaining uses to the standard
syntax.
2022-01-09 15:25:42 +00:00
Kp d2478d0708 Require support for C++17 attribute [[fallthrough]] 2022-01-09 15:25:42 +00:00
Kp 0f53ce0f06 Factor out get_xrange_direction
clang chokes on use of a `constexpr bool` that is initialized separately
from its definition.  gcc allows this.  Move the value computation into
a constexpr helper function, so that the variable can be defined and
initialized in the same statement.
2022-01-09 15:25:42 +00:00
Kp 6cdc181218 Use enum class for segment_relative_vertnum 2022-01-09 15:25:42 +00:00
Kp f933feeef1 Combine vertex setup steps in med_attach_segment_rotated
This eliminates the need to keep all 4 vertex objects as temporaries,
and simplifies the loop counter.
2022-01-09 15:25:42 +00:00
Kp 932419ff17 Combine Two_sides_to_edge, Edge_between_sides
These track the same data, but were static and defined separately.
Delete Edge_between_sides and redirect uses to Two_sides_to_edge.
2022-01-09 15:25:42 +00:00
Kp b8a8a61ff8 Simplify multiplayer powerup creation
Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
2022-01-09 15:25:42 +00:00
Kp 94cfeede5c Validate control center trigger sides on load 2022-01-09 15:25:42 +00:00
Kp 078a9affa0 Make MAX_SIDES_PER_SEGMENT an iterable range
Iterating over it returns each side number in turn.  This allows
converting many loops of the form:

```
	for (int i = 0; i < MAX_SIDES_PER_SEGMENT; ++i)
```

to the compact form:

```
	for (const auto i : MAX_SIDES_PER_SEGMENT)
```

The compact form brings the usual benefit of range-based for: delegating
iteration to the compiler prevents the loop body from skipping a step,
and makes clear in the code that this is the case.
2022-01-09 15:25:42 +00:00
Kp 3004dd16e5 Convert some bare integers to sidenum_t 2022-01-09 15:25:42 +00:00
Kp d6b4106d36 Tighten index handling for Ai_transition_table
Avoid undefined accesses when a robot has an invalid awareness type.
2022-01-08 17:48:09 +00:00
Kp 648bbac0b1 Convert ai_local::achieved_state to ai_static_state 2022-01-08 17:48:09 +00:00
Kp d1ac265c2c Convert ai_local::goal_state to ai_static_state 2022-01-08 17:48:09 +00:00
Kp 37f3c10dd4 Convert ai_static::CURRENT_STATE to ai_static_state 2022-01-08 17:48:09 +00:00
Kp c3937f391f Convert ai_static::GOAL_STATE to enum 2022-01-08 17:48:09 +00:00
Kp 9fdf6005df Convert ai_static::GOALSIDE to sidenum_t 2022-01-08 17:48:09 +00:00
Kp c6d98df9fb Move CURRENT_GUN out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 5128b84122 Move CURRENT_STATE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 39e9673f54 Move GOAL_STATE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp c10855939b Move PATH_DIR out of ai_static::flags 2022-01-08 17:48:09 +00:00