Commit graph

12130 commits

Author SHA1 Message Date
Kp dd374ef65e Pass std::span to multi_do_guided 2022-07-30 17:42:59 +00:00
Kp 74fd22a5a0 Pass std::span to multi_do_drop_flag 2022-07-30 17:42:59 +00:00
Kp a5c6a25cf2 Pass std::span to multi_do_drop_marker 2022-07-30 17:42:59 +00:00
Kp 652e3ceddd Pass std::span to multi_do_sound_function 2022-07-30 17:42:59 +00:00
Kp 84bb23e6d3 Pass std::span to multi_do_vulcan_weapon_ammo_adjust 2022-07-30 17:42:59 +00:00
Kp 4dd058d501 Pass std::span to multi_do_drop_weapon 2022-07-30 17:42:59 +00:00
Kp 5ac2a90121 Pass std::span to multi_do_controlcen_destroy 2022-07-30 17:42:59 +00:00
Kp 454bec9715 Pass std::span to multi_do_quit 2022-07-30 17:42:59 +00:00
Kp f923a5d710 Pass std::span to multi_do_player_deres 2022-07-30 17:42:59 +00:00
Kp aa95c6f804 Pass std::span to multi_do_remobj 2022-07-30 17:42:59 +00:00
Kp 7d464db18d Pass std::span to multi_do_reappear 2022-07-30 17:42:59 +00:00
Kp 74af38bba2 Pass std::span to multi_do_position 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 3bc110ec01 Fold robot kamikaze explode_object calls 2022-07-30 17:42:59 +00:00
Kp dc674eafe8 Replace various uses of std::enable_if with C++20 requires()
Compiler error messages are generally better when reporting a misuse
that fails a requires() versus reporting a misuse that fails a
std::enable_if.  In some cases, this also makes the code clearer, and
avoids the need for dummy template parameters as a place to invoke
std::enable_if.
2022-07-30 17:42:59 +00:00
Kp 58061b5f45 Use C++20 std::span for morph_data 2022-07-30 17:42:59 +00:00
Kp e5dcb8a505 Prefer C++20 std::span over internal span for decode_row
This generates the same code before and after.
2022-07-30 17:42:59 +00:00
Kp f92a978b4a Unify collide_player_and_materialization_center -> apply_damage_to_player
D2 changed the rule for the parameter `killer`.  Split that out to a
variable and combine the underlying call.  This does not change the game
semantics.
2022-07-23 20:58:10 +00:00
Kp d9d2bac092 Use enum class for apply_damage_to_player::possibly_friendly
Also, remove a redundant invulnerability check in one caller.
apply_damage_to_player already tests for invulnerability and returns if
appropriate.
2022-07-23 20:58:10 +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 e6c510d467 Use vector read/write helpers in network messages 2022-07-23 20:58:10 +00:00
Kp 4141e04359 Pass thief stolen item storage to drop_stolen_items 2022-07-23 20:58:10 +00:00
Kp a3a2f7cc9a Pass context to drop_stolen_items
Pass the specific object fields needed, rather than the entire object.
2022-07-23 20:58:10 +00:00
Kp 801c76cbd2 Pass context to spit_powerup 2022-07-23 20:58:10 +00:00
Kp b61add4765 Pass context to drop_powerup 2022-07-23 20:58:10 +00:00
Kp 6ff9c9029d Use specific type in MVEFILE instead of void *
Replace `void *stream` with a typedef and `stream_type *stream`, so that
the original type information is propagated down.
2022-07-23 20:58:10 +00:00
Kp 51219d3607 Use enum class for PlayMovie flag must_have 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 c03b772ce7 Use caller supplied object for player_info in Flare_create
The caller supplies the local player, so use that instead of computing
it again.
2022-07-23 20:58:10 +00:00
Kp 68681d462c Fire flare from local player, not from ConsoleObject
The local player object was already computed above, and so is free to
reuse here.
2022-07-23 20:58:10 +00:00
Kp a0dc1b4283 Use union of multi_command<> for multi_send_fire message
Switch to a union of the possible multi_command<> types, and eliminate
the explicit length parameter passed to multi_send_data.
2022-07-23 20:58:10 +00:00
Kp 52aa9891b9 Simplify passing weapon to do_missile_firing
When the player fires a generic secondary, the choice of proximity bomb
versus super-mine is never read.  When the player specifically drops a
bomb, only that choice needs to be read.  Pass the chosen weapon as an
argument, and avoid computing the choice on the path where it is never
read.
2022-07-23 20:58:10 +00:00
Kp b4fcb9c305 Simplify do_missile_firing test for whether to autoselect
If `drop_bomb` is false, then `weapon == player_info.Secondary_weapon`.
If `drop_bomb` is true, then `weapon == bomb`.
2022-07-23 20:58:10 +00:00
Kp c0e12eee3f Push player object lookup from do_missile_firing to caller
The caller already needs the player object for other purposes, so let
the caller pass it down to do_missile_firing.
2022-07-23 20:58:10 +00:00
Kp 0dd5d6e0d5 Split guided missile release local/remote handling
Two paths are always local.  One path is always remote.  Split the
handler function to remove the locality test and rely on the caller's
knowledge of whether the affected player is local.
2022-07-23 20:58:10 +00:00
Kp 0cb0b5cdc0 Use playernum_t for guided missile player number 2022-07-23 20:58:10 +00:00
Kp 4886afdf93 Lift which_bomb from do_missile_firing to caller
Callers already have the player_info available, and will need the value
of bomb in a subsequent commit.  Lift it here.
2022-07-16 15:26:12 +00:00
Kp 3139445f02 Cache player object in do_missile_firing
Resolve the object to a vmobjptridx once, and use it as needed.  Replace
some uses of ConsoleObject with the local player, since those should be
the same, and local player is already computed.
2022-07-16 15:26:12 +00:00
Kp 1d65a83d73 Use primary_weapon_index_t for do_laser_firing weapon_id 2022-07-16 15:26:12 +00:00
Kp cbab79a56a Simplify multi_send_fire handling of is_bomb_objnum
Only one caller passes a value other than `object_none` for
`is_bomb_objnum`.  That one caller uses an equivalent predicate to the
one that `multi_send_fire` uses for deciding whether to use
`MULTI_FIRE_BOMB`.  Therefore, if `is_bomb_objnum != object_none` is
true, the weapon is guaranteed to be a proximity bomb or smart mine, and
`multi_send_fire` can use `MULTI_FIRE_BOMB` without retesting the object
id.
2022-07-16 15:26:12 +00:00
Kp f22b627949 Simplify do_missile_firing lookup of track_goal
Commit 81dd23b151 ("Only charge player for weapons that fire successfully")
added an early return when `objnum == object_none`, so if execution
reaches the call to `multi_send_fire`, then the object is guaranteed to
exist.  Access the track_goal without rechecking whether the object
exists.
2022-07-16 15:26:12 +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 ea18bd074c Use multi_command for multi_send_message 2022-07-16 15:26:12 +00:00
Kp 2ea48475e3 Use multi_command for robot_fire_buf 2022-07-16 15:26:12 +00:00
Kp 2288f85d6a Use multi_command for multi_send_drop_marker 2022-07-16 15:26:12 +00:00
Kp 1d23e5848f Use enumerated_array for UDP_mdata_store::pkt_num 2022-07-16 15:26:12 +00:00
Kp bfd83c6702 Use enumerated_array for UDP_mdata_store::pkt_timestamp 2022-07-16 15:26:12 +00:00
Kp efecd3507f Optimize removal of expired mdata records
Instead of sliding the entire queue down one element at a time, move the
non-expired elements in one step, and wipe all the trailing elements
in a single pass.
2022-07-16 15:26:12 +00:00