Commit graph

12071 commits

Author SHA1 Message Date
Kp 45362ac37b Fix guest loading of multiplayer saved games
Using `sav_objnum` caused the player to be restored into the object slot
of the pre-load level, in the object table of the post-load level.  This
was harmless when the slots were the same, and wrong when they were not.
It became noticeably wrong when more player data was moved into the
object.  After those changes, the player's data was stored into the
correct post-load slot, but the ship was assigned to the pre-load slot.

Remove the incorrect slot switch, and add an assert that the object
being overwritten is a player ghost.  With the incorrect switch present,
this assert will catch most (but not all)[1] cases of the incorrect
restore.  With the incorrect switch removed, this assert succeeds.

[1] In the unlikely case that the post-load slot was a player start, but
for a different player, the assert could succeed despite the slot
mismatch bug.  In the common case, the post-load slot would not be a
start of a different player; it would either be the correct player slot,
in which case `sav_objnum` was harmless, or it would be some other
object, such as a robot.
2022-09-11 17:00:45 +00:00
Kp d9f30ba10c Avoid spinning in net_udp_request_poll
If the guest is slow to respond, the host would enter a busy loop
polling for the guests to be ready.  Mitigate the CPU load by sleeping
for 50ms when guests are not yet ready.
2022-09-11 17:00:45 +00:00
Kp 232c648024 Add Windows version resource for Windows build 2022-09-11 17:00:45 +00:00
Kp 11a400ab8f Move upid sizes to constexpr variable 2022-09-11 17:00:45 +00:00
Kp 70fd424599 Split net_udp_process_game_info to light/heavy variants
The two paths had nothing in common, so split them into separate
functions and call the appropriate version from each caller.
2022-09-11 17:00:44 +00:00
Kp 575bfe8a69 Use enum class for tracker_game_id 2022-09-11 17:00:44 +00:00
Kp 8f847c16bb Use std::span for csocket_data_buffer 2022-09-11 17:00:44 +00:00
Kp 763f1d4902 Use std::span for socket_data_buffer 2022-09-11 17:00:44 +00:00
Kp eb8a7d8186 Use std::span for multi::send_data_direct 2022-09-11 17:00:44 +00:00
Kp 53770489d8 Use std::span for net_udp_noloss_add_queue_pkt 2022-09-11 17:00:44 +00:00
Kp 2589ba9c60 Ignore invalid MULTI_START_TRIGGER messages 2022-09-11 17:00:44 +00:00
Kp 0512ea8d65 Use enum class for upid 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
Kp 4cf1eb328f Use std::array for prepare_kill_name storage 2022-09-11 17:00:44 +00:00
Kp 0a8bf6bfa8 Remove redundant test in multi_do_finish_game
This is only called from the dispatch switch which checked the type.
There is no need to check the type again.
2022-09-11 17:00:44 +00:00
Kp dac7b13f65 Pass optional parameters to multi_do_fire from caller
Remove the multi_do_fire branches that check the message type.  Delegate
those checks to the caller, so that multi_do_fire can work with the
common initial sequence of the three messages.
2022-09-11 17:00:44 +00:00
Kp 231acfe0ae Include git-describe data in archived snapshots 2022-08-31 01:46:58 +00:00
Kp 366b048879 Merge commit 'refs/pull/657/head' into master 2022-08-23 02:13:01 +00:00
Kp 0a1758f44f Ignore excess hostages during scoring
Descent 2 secret levels allow a player to rescue hostages that are not
counted in `total_hostages`, so a player can exit with more hostages
saved than were in the mine.  Change the scoring logic not to penalize a
player for saving these unaccounted hostages.
2022-08-22 01:24:49 +00:00
Kp cd09a742a0 Initialize aip->CURRENT_GUN in robot setup
In non-memory-poison builds, the zero initialization of the new object
will suffice to cover this.  In memory-poison builds, the new object
will be reset to a poison value, so the member must be given a
reasonable value here.
2022-08-22 01:24:49 +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 c08b35ff45 Add SConf test for C++17 attribute [[nodiscard]]
This attribute is already in use in the code, but add an explicit test
to detect at configure time if the compiler lacks support for it.
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 4e66bff3f6 Fix SDL-only build of game.cpp
Fixes: 8be306efa7 ("Use enum class for cockpit_mode_t")
2022-08-22 01:24:49 +00:00
Kp b8313fdeb0 Filter out empty feature text fragments
Avoid generating a banner comment over an empty text fragment.
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 3ea0cc7053 Store Pof_addr at local scope
Pass it to called functions as needed.
2022-08-22 01:24:49 +00:00
Kp 6b7ba83a00 Move anim_angs into local scope, since it is copied out later 2022-08-22 01:24:49 +00:00
Kp 99577c4296 Simplify pof_read_string
The resulting string is discarded, so change it to skip without copying.
2022-08-22 01:24:49 +00:00
Kp a41908dece Move Pof_file_end to local scope
Rely on the extent in std::span for called code that needs to know
bounds.
2022-08-22 01:24:49 +00:00
Kp 3e13dcdf19 Use std::span to bound read_model_guns valid bytes 2022-08-22 01:24:49 +00:00
Kp 15e8ceeaa4 Use std::span to bound read_model_file valid bytes 2022-08-22 01:24:49 +00:00
Kp 42caec7e58 Use std::span for pof reading functions 2022-08-22 01:24:49 +00:00
Kp c5c5e8ea39 Simplify pof_read_angs
The caller passes a length of 1, so inline that and simplify the
function.
2022-08-22 01:24:49 +00:00
Kp 69579df368 Simplify pof_read_short
Use the general little-endian helper.
2022-08-22 01:24:49 +00:00
Kp 87c79206e8 Simplify pof_cfread
All callers pass a value of 1 for one of the two length terms, so inline
that and eliminate the multiplication.
2022-08-22 01:24:49 +00:00
Kp bfb7ed7efc Simplify pof_read_vecs
All callers pass a count of 1, so inline that and eliminate the loop.
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
Kreeblah 25688635bb
Use Brewfile for macOS Github builds 2022-08-15 21:20:18 -07:00
Kp d49931d57b Merge commit 'github-packaging-c++20' into master 2022-08-16 03:15:32 +00:00
Kp 0d045ae3da Fix Windows net_udp build
Convert the RAIIsocket to a simple SOCKET before passing it to FD_SET.
Otherwise, the build fails with:

```
similar/main/net_udp.cpp: In function 'int {anonymous}::udp_general_packet_ready(dcx::{anonymous}::RAIIsocket&)':
similar/main/net_udp.cpp:969:2: error: use of deleted function 'bool dcx::{anonymous}::RAIIsocket::operator==(T) const [with T = long long unsigned int]'
  969 |  FD_SET(sock, &set);
      |  ^~~~~~
similar/main/net_udp.cpp:493:29: note: declared here
  493 |  template <typename T> bool operator==(T) const = delete;
      |                             ^~~~~~~~
```
2022-08-16 03:15:04 +00:00
Kreeblah bfdeff93b2
Added Brewfile and updated macOS compilation instructions 2022-08-14 19:36:02 -07:00
raptor 6440e387d6 Fix Linux/macOS builds with c++20 dialect 2022-08-14 19:00:18 -06:00
Kp daebb32925 Merge commit 'github-packaging' into master 2022-08-14 22:53:35 +00:00
raptor 1a10ffd031 Update macos package building scripts to install dylibbundler via brew and instruct scons to do the bundling 2022-08-11 21:52:06 -06:00
raptor 85a617386f Packaging changes:
- Split out builds in order to trigger them separately
- Anchor macdylibbundler to a specific revision
2022-08-10 09:25:08 -06:00
raptor 0e03692ec3 Packages for Windows, Linux, and macOS. Uses Github's Actions 2022-08-01 09:39:41 -06:00