Commit graph

54 commits

Author SHA1 Message Date
Kp f6c45d0f6f Use enum class for multiplayer_command_t 2022-10-23 23:00:24 +00:00
Kp e0300e1e30 Pass std::span to dispatch_table::send_data 2022-09-24 17:47:51 +00:00
Kp 55bbc5f599 Pass std::span to multi_do_create_robot_powerups 2022-07-30 17:42:59 +00:00
Kp 4ce39a399e Pass std::span to multi_do_boss_create_robot 2022-07-30 17:42:59 +00:00
Kp c575283c5e Pass std::span to multi_do_boss_stop_gate 2022-07-30 17:42:59 +00:00
Kp b820098103 Pass std::span to multi_do_boss_start_gate 2022-07-30 17:42:59 +00:00
Kp 2b4dd444ca Pass std::span to multi_do_boss_cloak 2022-07-30 17:42:59 +00:00
Kp 6ab2068a82 Pass std::span to multi_do_boss_teleport 2022-07-30 17:42:59 +00:00
Kp 202e3309a7 Pass std::span to multi_recv_escort_goal 2022-07-30 17:42:59 +00:00
Kp 980b3080ce Pass std::span to multi_do_robot_fire 2022-07-30 17:42:59 +00:00
Kp fa0f7cef11 Pass std::span to multi_do_release_robot 2022-07-30 17:42:59 +00:00
Kp d4b047bb02 Pass std::span to multi_do_robot_position 2022-07-30 17:42:59 +00:00
Kp 0036b91084 Pass std::span to multi_do_claim_robot 2022-07-30 17:42:59 +00:00
Kp 49f608010a Pass std::span to multi_do_robot_explode 2022-07-30 17:42:59 +00:00
Kp e1269dca35 Pass std::span to multi_do_create_robot 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 f78c3989f9 Remove obsolete multi_send_data overload
All callers now supply a multi_command<>, so remove the pointer-based
overload.
2022-07-23 20:58:10 +00:00
Kp 9cf82a8eb5 Set multi_command code in constructor, not at send time
Rework multi_send_kill to handle the stricter construction requirements
this imposes.
2022-07-16 15:26:12 +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 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 8d3f47d646 Fix hoard orb handling on player death
Descent tracked hoard orbs by borrowing the player's proximity bomb
slot.  Commit 829e95b6f8 moved proximity
bomb tracking to its own slot, but failed to update the player
death/deres logic accordingly.  This caused multiple inconsistencies
when a player was killed in hoard mode:

- The killed player saw the orb drop as expected.
- The killed player _also_ kept the orb in inventory after respawn,
  because the counter was not reset.
- Other players saw no orb drop.

Fix the inappropriate retention by resetting the orb count in
init_player_stats_new_ship.  Fix the inappropriate failure to drop by
adding a new unconditional field to the player death/deres message.  In
hoard games, use it to pass the orb count.  In other games, ignore it.

Fixes: 829e95b6f8 ("Separate hoard/proximity tracking")
Reported-by: snytek <https://github.com/dxx-rebirth/dxx-rebirth/issues/526>
2020-08-01 18:29:01 +00:00
Kp a2560cdfb5 Move Stolen_items into d_thief_unique_state 2019-07-16 04:00:50 +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 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 12b57e84e6 Switch most in-tree http:// links to https://
For each link given as http://, verify that the site is accessible over
https:// and, if so, switch to it.  These domains were converted:

* llvm.org
* clang.llvm.org
* en.cppreference.com
* www.dxx-rebirth.com
* www.libsdl.org
* www.scons.org
2018-09-02 00:57:29 +00:00
Kp 4a98e796ab Prevent stacking weapon rotation sounds
digi_play_sample_once is supposed to cancel prior instances of the
sound, but that functionality was lost in
21082c6db2.  As a result, the sound can be
stacked up to the limit of the engine.  Even when the functionality
existed, its implementation was wrong.

- Change these sounds to be attached to the player generating them.
- Pass the cancellation flag to other players when sending a sound.
- Send the full value of `volume`, rather than truncating it.
- Implement cancellation by killing and restarting the earlier version of a cancelled sound.
- Delete an ugly hack that prevented the patched logic from ever running.
- Fix an ancient quirk in digi_mixer that caused it to report all sounds as not playing, which then caused digi_sync_sounds to instantly cancel the new sound.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88>
Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88#issuecomment-269597361>
Fixes: 21082c6db2 ("Added own channel management to SDL_mixer sound interface since the builtin channel management of this lib cannot handle our needs; Little code cleanup")
2018-05-13 03:14:34 +00:00
Kp 18af84a0ab Remove __attribute__((packed)) from quaternionpos
Packed structures cannot be passed by reference, may fail on
alignment-strict architectures, and are bad for performance even on
alignment-tolerant architectures.  Using them for anything other than an
abstract layout declaration is a mistake.  Remove
__attribute__((packed)).
2018-03-31 21:53:01 +00:00
Kp 1cfc8b3fbd Shrink on-stack multibuf to size of command 2017-08-11 23:43:53 +00:00
Kp 4ff9027b31 Add const-qualifiers to some multi functions 2017-08-11 23:43:53 +00:00
Kp 9421c31b5a Replace "compiler-type_traits.h" with <type_traits>
Delete stub "compiler-type_traits.h" header.  Redirect all uses to the
standard <type_traits> header.

git grep -wlz 'compiler-type_traits.h' -- '*.cpp' '*.h' | xargs -0 perl -p -i <<EOF
    BEGIN {
	    $i = 0;
    }
    if (($i == 1 && $_ eq "\n") || ($i < 2 && /^#include "/)) {
	    # First blank line or first user-include after a system-include.
	    # Print, then never again for this file.
	    print "#include <type_traits>\n";
	    $i = 2;
    } elsif ($i == 0) {
	    $i = 1 if (/^#include </);
    } elsif ($_ eq "#include \"compiler-type_traits.h\"\n") {
	    # Remove this line if found.
	    $_ = '';
    }
    # Reset state machine when moving to next file.
    $i = 0 if eof;
EOF
2017-06-25 20:46:03 +00:00
Kp adcf02e454 Expand tt:: indirection to std::
All supported compilers have an acceptable <type_traits>.  Commit
4cb3d46148 ("Move <type_traits> test to Cxx11RequiredFeature") made
<type_traits> support mandatory in August and no one has objected.
Remove the indirection and use namespace std directly for type_traits
members.
2017-06-25 20:46:03 +00:00
Kp 6c85086a43 Pass vcsegptridx to multi_send_light_specific 2016-12-10 17:51:07 +00:00
Kp 7a0a20d455 Remove secret-level flag in D2 MP message
It is always zero.
2016-11-12 18:10:08 +00:00
Kp 61567eeed0 Move player::KillGoalCount to player_info 2016-11-12 18:10:07 +00:00
Kp 5c872830a1 Remove unused message MULTI_KILL 2016-10-21 02:16:47 +00:00
Kp 4ed57bf70b Simplify multiplayer_command_t truncation check 2016-08-28 22:41:47 +00:00
zico 7684ce92e4 Added packet to notify clients about a changed vulcan ammo count in a weapon powerup in case player collects ammo but leaves the gun itself. 2016-06-06 17:26:59 +02:00
zico 901a554e96 New powerup management code: Addeed functions and packet type to keep track of original and current level inventory as well as player and thief inventories. Calling maybe_drop_net_powerup() for all ammo based weapons except Concussion missiles. Limiting maybe_drop_net_powerup() to only spawn items missing from initial level inventory. Added function to let host respawn items that were lost for whatever reason. Expanded maybe_drop_net_powerup() and child functions to be able to drop item based on a random player. Changed back maybe_drop_secondary_weapon_egg() to its original behavior, dropping 3 of each type max. 2016-02-25 14:11:08 +01:00
Kp 4d8ae44794 Add helper macro DXX_CONSTANT_TRUE 2015-07-29 03:05:28 +00:00
Kp 15fb75c1c7 Fix check_header_includes build 2015-07-25 23:10:45 +00:00
Kp 06b453d617 Enable D1 weapon drops 2015-07-02 02:37:55 +00:00
zico cd27af9e41 Made MULTI_POSITION and MULTI_ROBOT_POSITION use quaternion packets to increase precision of powerup drops, robot movement and their firing; Also decreased priority of the first iteration of MULTI_POSITION from 2 to 1 as the first packet does not need to be protected but just serves as a convinient excuse to flush the multi data buffer 2015-06-28 19:20:46 +02:00
Kp 40b8bc1a06 Remove unused flag ammo
spit_powerup never sets ammo
2015-02-14 22:48:30 +00:00
Kp 93e01f71fd Remove unused Player_num from MULTI_DROP_FLAG 2015-02-14 22:48:29 +00:00
Kp 5212daa4ad Fix seismic duration sync 2015-02-14 22:48:29 +00:00
Kp 8ddab68448 Remove unused MULTI_DROP_WEAPON field player 2015-02-14 22:48:29 +00:00
Kp 7bf56a7d69 Add compile-time check on multi message sizes 2015-02-14 22:48:28 +00:00
Kp f0a1146b29 Unify MULTI_ROBOT_EXPLODE
Derive thief state locally.  Remove unused player number.  Use new
serializer.
2014-09-14 01:14:33 +00:00
Kp c3086f0875 Split out boss action messages 2014-08-13 03:19:13 +00:00