Commit graph

11809 commits

Author SHA1 Message Date
Kp 68453cd86f Remove redundant net_udp_welcome_player checks
This loop is run once before the `if()` test, then again at the top of
both the true and false branches of the `if`.  Remove the runs inside
the conditional, since they should produce the same result as the run
that occurs before the conditional.
2022-06-05 17:44:53 +00:00
Kp 9816475706 Pass Object array to object_goto_next_viewer 2022-06-05 17:44:53 +00:00
Kp e66da397a5 Add dummy 'file' key to executable entry in compilation database
clang rejects the entire database if any entry lacks a 'file' key,
regardless of whether the entry is used.

Fixes: bc6d043f5d ("Extend SConstruct compilation_database support to cover Program()")
2022-06-05 17:44:53 +00:00
Kp c5de47b51e Add const qualifiers to some net_udp functions 2022-06-05 17:44:53 +00:00
Kp 3d7cb4abc7 Remove force_dump_ai_objects_all
It rotted because it is only ever used when PARALLAX is defined.  No one
has reported it broken, so remove it.
2022-06-05 17:44:53 +00:00
Kp 0faa33d3df Harden bm_read_player_ship against invalid model numbers
Eliminate an unnecessary internal copy.  Terminate the search early if
an invalid model number is used.
2022-06-05 17:44:53 +00:00
Kp 504e950b75 Simplify bm_read_player_ship last_model_num handling
The existing handling always wrote to slot 0, but did so in a convoluted
way.  The variable names suggest this was not intended, but no one has
ever reported it as broken, and some otherwise valid data files may
depend on this quirk.
2022-06-05 17:44:53 +00:00
Kp 1b13274a5e Combine D1/D2 bm_read_player_ship call to load_polygon_model
D1 and D2 used logically equivalent code, but it was not the same text,
so the unification project split this with a `#ifdef`.  Since the code
does the same thing in both games, combine it into a non-guarded
statement.
2022-06-05 17:44:53 +00:00
Kp 5be32a05c6 Reorder check_line_to_line to eliminate useless copy
Instead of copying the input v1/v2 into det.uvec, pass a reference for
v1/v2 directly to calc_det_value.
2022-06-05 17:44:53 +00:00
Kp 9071675a0d Pass calc_det_value vectors separately
Pass 3 vectors rf/u instead of one vms_matrix.  This may make the code
slightly worse in the short term, but it makes a later change clearer.
2022-06-05 17:44:52 +00:00
Kp bfe7f2bb19 Reorder fvi_sub object type tests
Two tests in series examined the object for a type of OBJ_ROBOT.  Fold
the test together.

The next test also examines ->type.  Move that to an else since it
cannot be true if the first test was true.
2022-06-05 17:44:52 +00:00
Kp e180375f97 Pass GameBitmaps to draw_object_blob 2022-06-05 17:44:52 +00:00
Kp cc2f3caa7e Split piggy.h -> fwd-piggy.h 2022-06-05 17:44:52 +00:00
Kp 6228b07b45 Fix check_header_includes=1 build of fvi.h 2022-06-05 17:44:52 +00:00
Kp 6e2ed26659 Pass object to init_player_object 2022-06-05 17:44:52 +00:00
Kp 9f207daf95 Pass player object to reset_player_object 2022-06-05 17:44:52 +00:00
Kp 11a0aae9ee Pass GameBitmaps to piggy_bitmap_page_in 2022-06-05 17:44:52 +00:00
Kp f36a8e015e Disable collecting segment list in see_object
The segment list is written to `hit_data`, but `hit_data` goes out of
scope before the segment list is read back.  Skip collecting it, since
it was effectively write-only on this path.
2022-06-05 17:44:52 +00:00
Kp 33152640bc Remove fvi_info::hit_type
Its value is always readily available as the return value of
find_vector_intersection, so remove the structure member and rely on the
returned value.
2022-06-05 17:44:52 +00:00
Kp 8c4adbc262 Show repaircenters on automap 2022-06-05 17:44:52 +00:00
Kp 33923ab4ca Enable creating repaircenters in the editor
This is untested, but matches the logic used for
fuelcen_create_from_curseg.
2022-06-05 17:44:52 +00:00
Kp be7388a369 Enable repaircenter in D1
The code exists in D2, and the segment special is reserved for both
games.  Include the repaircenter code in D1, also.
2022-06-05 17:44:52 +00:00
Kp 885b0939d6 Defer charging for Omega cannon until blobs are created
If the creation of the Omega cannon blob fails, do not play the sound or
deplete the player's energy.
2022-06-05 17:44:52 +00:00
Kp 69d8dada1c Return next object from obj_detach_one
This allows obj_detach_all to avoid reloading the value from the parent
object each time.
2022-06-05 17:44:52 +00:00
Kp 6bd6a47612 Rework compress_segments to use segment iterators
This removes direct math on segnum_t, which will simplify later use of
`enum class segnum_t`.
2022-06-05 17:44:52 +00:00
Kp 86a32dd0ff Change enum sidenum_t to enum class sidenum_t 2022-06-05 17:44:52 +00:00
Kp 4fd412b2ea Precompute g3_draw_line GL color data 2022-06-05 17:44:52 +00:00
Kp e54338ce4e Combine canvas+color into g3_draw_line_context 2022-06-05 17:44:52 +00:00
Kp a44324abe1 Tighten net_udp player index check 2022-05-29 19:37:58 +00:00
Kp 0de494c2e0 Make thief explode when killed
Commit 1a9fba804d made an incorrect simplification.  It observed that
thief robots are not boss robots and vice versa, and from that changed:

```
	if (is_thief) { drop_stolen_items(); }
	if (is_boss) { start_boss_death_sequence(); }
	else if (death_roll) { start_robot_death_sequence(); }
	else { regular_death(); }
```

to

```
	if (is_thief) { drop_stolen_items(); }
	else if (is_boss) { start_boss_death_sequence(); }
	else if (death_roll) { start_robot_death_sequence(); }
	else { regular_death(); }
```

This was incorrect, because although a thief is not a boss, a thief does
need to proceed through the other non-boss if tests.  This error caused
a thief not to explode on death, and instead continue to fly around and
absorb weapon fire.

Fix the logic error by removing the incorrect `else`, so that a thief
can be tested for is_boss, get false, and then proceed through the
non-boss death logic.

Fixes: 1a9fba804d ("Avoid repeated valptridx dereferences in multibot.cpp")
2022-05-29 18:44:59 +00:00
Kp 092daecb61 Use static_cast<> to convert player_marker_num to game_marker_index
gcc-12 rejects the list initialization syntax.  Switch to static_cast<>,
which generates equivalent code.

Reported-by: dbermond <https://github.com/dxx-rebirth/dxx-rebirth/issues/638>
2022-05-28 21:04:37 +00:00
Kp 12cca97870 Remove unused piggy_new_pigfile local char tempname[20]
gcc-12 warns that the snprintf to initialize `tempname` may be
truncated.  The variable is never used after it is initialized, so
delete the initialization and declaration.
2022-05-28 21:04:37 +00:00
Kp a8e7f6ad59 Use enum class for find_vector_intersection result 2022-05-24 02:32:58 +00:00
Kp d8ab3c9bd3 Remove quadint members low, high
Always access the data through the member `q`.  This makes the code
independent of architecture endian decisions.
2022-05-24 02:32:58 +00:00
Kp e154d37e5e Tighten valptridx::ptridx range checking for pointer_type constructor
Previously, the supplied pointer was converted to an array index, then
passed to valptridx::idx for validation.  If the index_type is smaller
than std::size_t, this would truncate the value before validation.
Certain out-of-range indexes would be in-range after truncation, and
incorrectly not be reported.

Reorder the check to validate the index against the array size before
truncation.
2022-05-24 02:32:58 +00:00
Kp 67705bdd7a Return checkmuldiv result in std::optional 2022-05-24 02:32:58 +00:00
Kp 1f5d72e747 Use native 64-bit math in checkmuldiv 2022-05-24 02:32:58 +00:00
Kp 62635ec285 Use enum class for vm_magnitude_squared 2022-05-24 02:32:58 +00:00
Kp cf51ac4ee0 Fix BUG on show-path cheat
Players are not robots, but the show-path cheat tried to pretend they
are, and triggered a BUG warning[1] when looking up robot information
from the player object.  Fix this by passing in the robot_info when the
caller is providing a robot, and a named `nullptr` value (as
`create_path_unused_robot_info`) when the caller is providing a
non-robot object.

[1] As below, but repeated many times
```
similar/main/ai.cpp:1905: BUG: object 0x555555858550 has type 4, expected 2
similar/main/ai.cpp:1974: BUG: object 0x555555858550 has type 4, expected 2
```
2022-05-21 19:51:18 +00:00
AlumiuN da0b746037 Set console output priority to highest given option rather than most recently specified 2022-05-16 20:03:34 +12:00
Kp e29cddd524 Cache Difficulty_level during aim-leading calculations 2022-05-11 03:17:23 +00:00
Kp edbdec361c Check return value of check_line_to_line 2022-05-10 01:58:55 +00:00
Kp 2b36332228 Use enum class for intersection_type in fvi 2022-05-10 01:58:55 +00:00
Kp 8c5eff2ba0 Remove unused return value of callsign_t::copy 2022-05-10 01:58:55 +00:00
Kp 7b7145f20a Simplify zeroing callsign on copy-in
Zero the entire array, then overwrite the leading portion with the
received data.  This permits the compiler to do a fixed number of large
stores, instead of a variable number of small stores.
2022-05-10 01:58:55 +00:00
Kp 887851cb99 Make RAIIsocket::closesocket static
It exists as a wrapper for the Windows call of the same name.  Windows
does not require an object, so neither should this method.
2022-05-10 01:58:55 +00:00
Kp 464b5b302f Change RAIIaddrinfo to use using instead of forwarding functions 2022-05-10 01:58:55 +00:00
Kp 163a6222c2 Remove unnecessary endian instances in serial.h
The type aliases are sufficient.  Individual bytebuffer_t
implementations can define a `static constexpr` member `endian` from the
type alias and rely on `std::integral_constant<T, V>::operator()`
instead of defining a `static` method just to return an instance of the
`std::integral_constant`.
2022-05-05 02:59:11 +00:00
Kp bdff6f7a00 Remove unused return value of attempt_to_steal_item 2022-05-05 02:59:11 +00:00
Kp 58deb3c333 Rename check_header_includes object directory to be descriptive
Change from `chi` to `check_header_includes`.
2022-05-05 02:59:11 +00:00