Commit graph

12100 commits

Author SHA1 Message Date
Kp c09899f457 Pass std::span to load_mus_data 2022-09-24 17:47:52 +00:00
Kp e911d14808 Reduce scope of mix_play_file full_path
It is only set or used when expanding home directory references.  Reduce
its scope accordingly.
2022-09-24 17:47:52 +00:00
Kp fd1be66fa4 Pass std::span to draw_tmap, draw_tmap_flat 2022-09-24 17:47:52 +00:00
Kp a48e6ab56b Pass std::span to _g3_draw_tmap 2022-09-24 17:47:52 +00:00
Kp ad8325b63c Pass std::span to _g3_draw_tmap_2 2022-09-24 17:47:52 +00:00
Kp 491d23e2d9 Pass std::span to _g3_draw_poly 2022-09-24 17:47:52 +00:00
Kp 97f0c5a6d0 Pass std::span to decode_data 2022-09-24 17:47:52 +00:00
Kp 0b91da6d9c Use span methods to construct dxx_sendto input 2022-09-24 17:47:52 +00:00
Kp 9faa3d912d Pass std::span to pcx_encode_line 2022-09-24 17:47:52 +00:00
Kp e69f219539 Pass std::span to g3_validate_polygon_model 2022-09-24 17:47:52 +00:00
Kp 928834fdf8 Pass std::span to g3_init_polygon_model 2022-09-24 17:47:52 +00:00
Kp 76643ed432 Change trace_segs not to recompute children on every pass
`oldsegnum` is `const`, so the address computed from it cannot change.
Lift the computation of `auto &children` out of the loop.

Reduce the scope of `biggest_val`, since it does not need to outlive the
loop.
2022-09-24 17:47:52 +00:00
Kp ce0c183737 Change valptridx allow_end_construction to avoid assertion
gcc libstdc++ built with -D_GLIBCXX_DEBUG includes in
std::array::operator[] an assertion of the form:

```
	assert(index < size());
```

The valptridx allow_end_construction constructor, when given a
completely full array, will call operator[](size()), which causes the
assertion to fail.  Rework the constructor to compute an end iterator
without using operator[].  valptridx allow_end_construction expects that
the resulting iterator may be the end iterator and shall not be
dereferenced.
2022-09-24 17:47:52 +00:00
Kp d797072596 Make vector magnitude constant in more cases
Introduce a helper to obtain both the magnitude of a vector and the
corresponding normalized vector.  Use it to capture both values as const
when possible.
2022-09-24 17:47:52 +00:00
Kp f599ad90b4 Make create_omega_blobs::omega_delta_vector const 2022-09-24 17:47:52 +00:00
Kp 781ca0c97d Reorder endlevel exit_side initialization to fix -Wmaybe-uninitialized
gcc-11.3.0 issues a -Wmaybe-uninitialized warning for `exit_side`.
Reorder the code to eliminate this warning.  Also, fix a potential
out-of-bounds read if `matt_find_connect_side` returned `side_none`.
Before, this would lead to a read of `Side_opposite[side_none]` before
the test that `entry_side` is not `side_none`.  Now, if
`matt_find_connect_side` returns `side_none`, the read of
`Side_opposite` is skipped and logic goes directly to finding a proper
exit side.
2022-09-24 17:47:52 +00:00
Kp d1354911fc Reorder nm_string_inputbox to avoid -Wmaybe-uninitialized
gcc-11.3.0 with -Og may issue a -Wmaybe-uninitialized warning for `w1`
because it fails to prove that every path sets the variable.  Reorder
the logic to use a local lambda to ensure that every path assigns a
value.
2022-09-24 17:47:52 +00:00
Kp 2ecad00e90 Pass std::span to load_palette 2022-09-24 17:47:52 +00:00
Kp 805d71de6b Move Shareware_level_names,Registered_level_names to dumpmine.cpp
They are only used in this file, so move them there and make them
static.
2022-09-24 17:47:52 +00:00
Kp cbe6c94f1e Pass std::span to file_getdirlist 2022-09-24 17:47:52 +00:00
Kp 8f1055ca6b Use std::span for poison helper functions 2022-09-24 17:47:51 +00:00
Kp 17a0452001 Use std::span for nm_item_input 2022-09-24 17:47:51 +00:00
Kp ee68f43bb5 Remove SConf tests for curl, jsoncpp
These have been disabled since they were added in 2016, and the new HTTP
tracker they were meant to support was never put into service.  Remove
the tests.

Fixes: 9a8bd1aecb ("Add disabled tests for curl/jsoncpp")
2022-09-24 17:47:51 +00:00
Kp e0300e1e30 Pass std::span to dispatch_table::send_data 2022-09-24 17:47:51 +00:00
Kp 2d46e020e0 Return length change from copy_from_ntstring
Switch from passing length by-reference to instead passing it in by
value and returning the change.  This lets callers keep the length in a
register.
2022-09-24 17:47:51 +00:00
Kp 95bb58a2fe Convert PUT_INTEL_* uses to operator[]
Switch away from operator+(uint8_t *, std::size_t), since future work
will use a type that defines operator[] and not operator+.
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
JohnnyonFlame c90ac3e611 Fix OpenGL ES build on SDL2. 2022-09-18 21:35:55 -03:00
Kp ad46235b67 Avoid spinning in multiplayer when the game window is hidden
When the host exits the game, guests switch the game window to be
non-visible, and raise a dialog box stating `Host has left the game!`.
Prior to this change, the guests would then busy loop until the dialog
was dismissed.  With this change, the game will sleep for each idle
event, minimizing CPU use during the period waiting for the player to
acknowledge the dialog box.
2022-09-11 17:00:45 +00:00
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