Commit graph

264 commits

Author SHA1 Message Date
Kp e3faab0899 Use alias template per_player_array for arrays that are MAX_PLAYERS long
This removes the need to repeat MAX_PLAYERS in every usage, and prepares
for a future change to use enumerated_array instead of std::array.
2022-09-24 17:47:53 +00:00
Kp e0300e1e30 Pass std::span to dispatch_table::send_data 2022-09-24 17:47:51 +00:00
Kp b8ed30235c Remove Multi_is_guided; handle setup directly
`Multi_is_guided` is only enabled in one place.  One code path set up
Guided_missile[] for the local player, and a different path handled
network players.  Remove `Multi_is_guided` and rearrange such that a
single site handles both local and network players.
2022-09-24 17:47:51 +00:00
Kp eb8a7d8186 Use std::span for multi::send_data_direct 2022-09-11 17:00:44 +00:00
Kp d32fc7acab Use enum class for kick_player_reason 2022-09-11 17:00:44 +00:00
Tylor 6fee36638d Feat: Pitch unlocker 2022-08-21 16:16:40 -05:00
Kp 202e3309a7 Pass std::span to multi_recv_escort_goal 2022-07-30 17:42:59 +00:00
Kp a44f80fd64 Flatten call chain to net_udp_send_data 2022-07-23 20:58:10 +00:00
Kp e6c510d467 Use vector read/write helpers in network messages 2022-07-23 20:58:10 +00:00
Kp 2536b6c1bc Pass player orientation matrix to multi_send_fire
The caller has the player object, and can provide the orientation matrix
from it.  Use that instead of letting multi_send_fire recompute the
object in order to get the matrix.
2022-07-23 20:58:10 +00:00
Kp 851edbbd3c Use enum class for player connected status 2022-07-16 15:26:12 +00:00
Kp dccebd9783 Flatten call chain to net_udp_send_mdata_direct 2022-07-16 15:26:12 +00:00
Kp b737524415 Use enum class for next_level_request_secret_flag
Instead of passing a bare `int` named `secret_flag`, define it as an
`enum class : uint8_t` to name the two special values.

Rework the passing of this value, to deal with some confusing
inconsistencies when reading the code.

Before this change:
In D1:
- Multiplayer will always go to the secret level, regardless of which
  exit door the player used.
In D2:
- Flying through a D1 secret exit in multiplayer shows the on-HUD error
  "Secret Level Teleporter disabled in multiplayer!", and does not exit
  the level.  This is at best confusing, and at worst dangerous, since
  D1 secret exits are only available during the countdown, so the player
  has little time to realize that the normal exit must be used instead.
- Like D1, multiplayer will request to go to the secret level regardless
  of the exit used.  Unlike D1, the caller ignores the flag and always
  advances to the next regular level.

After this change:
- No observable differences for the player in-game.  The questionable D2
  secret exit handling for D1 is retained.
- The code makes clearer that secret exits do not work in D2
  multiplayer, by way of `#if defined(DXX_BUILD_DESCENT_I)` guarding the
  existence of the parameter and all updates to it.
2022-07-16 15:26:12 +00:00
Kp 066b172963 Use enum class for Network_status 2022-07-09 13:39:29 +00:00
Kp c7bbc415f5 Remove obsolete MULTI_FIRE field nfires
As of 8f8989e049, this field is always
sent as `1`.  Remove it, and update position offsets.
2022-07-09 13:39:29 +00:00
Kp 2135328dab Use enum class for multiplayer_data_priority 2022-07-09 13:39:29 +00:00
Kp 6215ef8e06 Pass LevelSharedRobotInfoState to various functions that need it 2022-07-09 13:39:29 +00:00
Kp e25b476de7 Use enum for segnum_t
Add checked conversions for sites which load from external integers.
2022-07-02 18:10:45 +00:00
Kp e45ff2da5e Use named enum types for netflag and netgrant 2022-07-02 18:10:45 +00:00
Kp 346906ae9f Simplify UPID_QUIT_JOINING
The host only needs to check the source address.  Remove the check on
the callsign, and shrink the message accordingly.
2022-06-05 17:44:53 +00:00
Kp 86a32dd0ff Change enum sidenum_t to enum class sidenum_t 2022-06-05 17:44:52 +00:00
Kp 8f8989e049 Propagate do_laser_firing nfires as 1
Every caller passes `1`, so remove the parameter and always use `1`.
For backward compatibility with the previous network protocol, continue
to send a `1` in the network message.
2022-04-17 22:27:19 +00:00
Kp f2832e6248 Simplify _sockaddr IPv4/IPv6 logic
- Use std::integral_constant instead of a static function that returns
  the value
- Remove unused protocol_family
- Replace the enum with a typedef for the one type that the enum was
  used to define
2022-02-12 18:57:12 +00:00
Kp 04f0507942 Fix memory corruption if spit_powerup fails to drop a weapon
If spit_powerup fails, it returns object_none.  object_none is not a
valid index for use by map_objnum_local_to_remote.
2022-02-06 16:12:31 +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 7015e3e93c Move REMOTE_SLOT_NUM out of ai_static::flags
Some flags merit a type other than int8_t.  Begin moving flags out to
distinct variables with their own type.

Add static_assert checks that the ABI relevant structures do not change.
2022-01-08 17:48:09 +00:00
Kp 12a0f8e8e0 Use enum class for wall_state 2021-11-01 03:37:19 +00:00
Kp 76e2f2c6d9 Use enum class for wall_flags 2021-11-01 03:37:19 +00:00
Kp a6f2db2502 Use enum class for player ranking 2021-11-01 03:37:19 +00:00
Kp 8ddfbd17e0 Use enum class for show_kill_list_mode 2021-11-01 03:37:19 +00:00
Kp d22632ac48 Use enum class for msgsend_state 2021-11-01 03:37:19 +00:00
Kp 7cb34fda0c Use enum class for network_game_type 2021-11-01 03:37:19 +00:00
Kp 1a44112907 Remove objnum_local_to_remote wrapper
Always use the form that returns both fields.
2021-11-01 03:37:19 +00:00
Kp 7fc8c736b3 Pass Powerup_info to multi_prep_level_objects, filter_objects_from_level 2021-09-19 10:53:48 +00:00
Kp 983ad86e4b Use enum class for trigger number 2021-09-04 12:17:14 +00:00
Dmitry Grigoryev fbd05a1592 optimize include files (include what you use) 2021-02-06 21:38:50 +01:00
Kp 1afd0eeae2 Move NETFLAG_DOPOWERUP to netgame_info and clarify name 2021-01-25 00:45:07 +00:00
Kp 49944a3fbf Use enum, not integral_constant, for netflag/netgrant constants 2021-01-25 00:45:07 +00:00
Kp 115c38cd77 Remove kmatrix_poll2
After the previous commit, its only purpose is to automatically dismiss
the window after 3 seconds.  Users may be surprised by this, and the
automatic dismissal has limited value.  Remove it and let the user
remain at the cancel dialog until a decision is made.
2020-12-27 22:03:09 +00:00
Kp 834f009dd7 Use enum class for wallnum_t 2020-12-26 21:17:29 +00:00
Kp fc63029833 Move more symbols into namespaces 2020-12-26 21:17:29 +00:00
Kp 1c2fcf86e0 Convert multi_leave_game to dispatch through a vtable 2020-12-20 20:39:07 +00:00
Kp e2c95058db Convert multi_endlevel to dispatch through a vtable 2020-12-20 20:39:07 +00:00
Kp a3eb82cefd Move multi code into namespaces 2020-12-20 20:39:07 +00:00
Kp 5e4047ce2a Convert disconnect_player to dispatch through a vtable 2020-12-20 20:39:07 +00:00
Kp 955ce55661 Convert kick_player to dispatch through a vtable 2020-12-20 20:39:07 +00:00
Kp 2007257064 Convert get_multi_endlevel_poll2 to dispatch through a vtable 2020-12-20 20:39:07 +00:00
Kp 407678dfdf Convert multi_send_endlevel_packet to dispatch through a vtable 2020-12-20 20:39:07 +00:00
Kp ea6504e60b Convert multi_level_sync to dispatch through a vtable 2020-12-20 20:39:07 +00:00
Kp 2f90d7a208 Convert multi_do_protocol_frame to dispatch through a vtable 2020-12-20 20:39:07 +00:00