Commit graph

4048 commits

Author SHA1 Message Date
Kp 366b048879 Merge commit 'refs/pull/657/head' into master 2022-08-23 02:13:01 +00:00
Kp 44cf8b83be Advise gcc to inline morph_data::operator new
This is only used in the file where it is defined, so it can be inlined
even though the definition is not in a header.  Enabling inlining
encourages gcc to see that the `operator new`/`operator delete` calls
are not mismatched.
2022-08-22 01:24:49 +00:00
Kp c64a584bfd Use enum class for robot_gun_number
Validate gun numbers on loading object data.  Factor out and normalize
the logic for advancing to a robot's next gun.
2022-08-22 01:24:49 +00:00
Kp 0ffbc764af Store Windows HMP MIDIHDR inline in hmp_file
This avoids the need to make separate allocations for the individual
buffers, and to free them later.
2022-08-22 01:24:49 +00:00
Kp 1fb55eebc2 Use enum class for robot_animation_state 2022-08-22 01:24:49 +00:00
Kp 7ac4016f55 Remove DXX_VALPTRIDX_STATIC_CHECK
clang-14 is detected as being able to optimize out unreachable paths,
but then triggers a build error reporting an unspecified invalid use
somewhere in multi.cpp.

Remove the static check, and rely on -Wsuggest-attribute=noreturn to
report any functions which are guaranteed to fail.  This is a weaker
check, but over the course of development, the static check has been hit
rarely, if ever, so keeping it provides little value.

```
In file included from similar/main/multi.cpp:38:
In file included from common/main/game.h:32:
In file included from common/main/robot.h:34:
In file included from common/main/object.h:40:
common/include/valptridx.h:229:2: error: call to unsigned int valptridx<dcx::player>::check_index_range_size<valptridx<dcx::player>::index_range_exception, std::__1::less>(char const*, unsigned int, unsigned long, valptridx<dcx::player>::array_managed_type const*)::DXX_ALWAYS_ERROR_FUNCTION::dxx_trap_handle_index_range_error() declared with 'error' attribute: invalid index used in array subscript
    DXX_VALPTRIDX_CHECK(Compare<std::size_t>()(s, array_size), handle_index_range_error, "invalid index used in array subscript", a, s);
    ^
common/include/valptridx.h:37:3: note: expanded from macro 'DXX_VALPTRIDX_CHECK'
        DXX_VALPTRIDX_STATIC_CHECK(dxx_valptridx_check_success_condition, dxx_trap_##ERROR, FAILURE_STRING);    \
        ^
common/include/valptridx.h:20:5: note: expanded from macro 'DXX_VALPTRIDX_STATIC_CHECK'
            (DXX_ALWAYS_ERROR_FUNCTION(FAILURE_FUNCTION, FAILURE_STRING), 0)    \
             ^
build/ulinux-clang++-14-64b10d04-ogl/dxxsconf.h:84:2: note: expanded from macro 'DXX_ALWAYS_ERROR_FUNCTION'
    DXX_ALWAYS_ERROR_FUNCTION::F(); \
    ^
1 error generated.
```
2022-08-22 01:24:49 +00:00
Kp 26ab08d55f Add stub definitions of enum vertnum_t,wallnum_t
Given this code:

```
enum class X : unsigned;
X a{1};
```

gdb has an unfortunate behavior of reporting "incomplete type" and
refusing to show the underlying value of `a`, even when `a` is in scope.
Adding `enum class X : unsigned {}` fixes this and allows gdb to show
the value.
2022-08-22 01:24:49 +00:00
Tylor 6fee36638d Feat: Pitch unlocker 2022-08-21 16:16:40 -05: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 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 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 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 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 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 1d65a83d73 Use primary_weapon_index_t for do_laser_firing weapon_id 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 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
Kp 851edbbd3c Use enum class for player connected status 2022-07-16 15:26:12 +00:00
Kp 4cc1bc995b Pack player acknowledgement mask into a bitset
The only values for any given player are true/false, so use a bitset
instead of a byte per player.  Some implementations may use a uint64_t
internally, negating the space savings.  Even so, this version is
an improvement for requiring the use of playernum_t as an index.
2022-07-16 15:26:12 +00:00
Kp 7f8e074ab0 Tighten access specifiers on enumerated_bitset 2022-07-16 15:26:12 +00:00
Kp 4cff6fd9d7 Simplify multi_send_robot_frame argument sent
The function had one caller, which always passed `0`.  Inline that.
Next, observe that `sent` is only ever modified `if (!(Game_mode &
GM_NETWORK))`.  As a multiplayer function, `multi_send_robot_frame`
should never be called in single-player, so this test should always be
false.  Delete it, and observe that `sent` is now `const`.

Remove unused return value of `multi_send_robot_frame`.
2022-07-16 15:26:12 +00:00
Kp 450154452d Use enum class for multi_send_robot_position_priority
Increment all values by 1, to eliminate the increment inside
multi_send_robot_position.
2022-07-16 15:26:12 +00:00
Kp 47f622dbc4 Use std::bitset for robot_fired
This only ever tracks true/false, so use bitset to save space.
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