Commit graph

11989 commits

Author SHA1 Message Date
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
Kp 97f8aea2f8 Use header path for check_header_includes=1 compilation database entries 2022-05-05 02:59:11 +00:00
Kp 9e0431b861 digi_win32_play_midi_song: write hmp_open result directly to global
Commit 3b5b69cb97 changed the logic to store the result of hmp_open
into a local that was destroyed at the end of the function.  This was
incorrect, as destruction of the returned value will immediately halt
the music.  Revert to the previous behavior, where the result is written
to the global `cur_hmp` so that it persists past the end of the
function.

Reported-by: norbert79 <https://github.com/dxx-rebirth/dxx-rebirth/issues/634>
Analyzed-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/634#issuecomment-1110510761>
Proposed-fix-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/634#issuecomment-1110510761>
Fixes: 3b5b69cb97 ("Improve error reporting for hmp_open / hmp2mid")
2022-04-28 02:19:26 +00:00
Kp f95bc3193f Fix traceback when using GIT='' and check_header_includes=1
`check_header_includes` requires `git` to be installed and able to list
files from a working copy.  When `GIT=''` is used, SConstruct is told
not to find or run `git`.  This caused a traceback when
`check_header_includes` tried to use git to list headers.  Reorder the
test to report a clear failure message.
2022-04-24 20:42:01 +00:00
Kp 504b38759c Use enum class for weapon_sound_flag
Pass the silent/audible flag as an enum:uint8_t to avoid type confusion
issues.
2022-04-24 20:42:01 +00:00
Kp 34793b5477 Use std::array for find_connected_distance depth array
Zero the entire array, rather than adjusting the loop to account for the
count of segments in the level.  The array may not need to be zeroed at
all, but this is cheap and guarantees consistent results.
2022-04-24 20:42:01 +00:00
Kp 8de9facac1 Lift thief AIM_THIEF_ATTACK check into caller
attempt_to_steal_item_3 always fails if the thief is not in
AIM_THIEF_ATTACK mode.  The caller will call attempt_to_steal_item_3
repeatedly in some cases, but the mode does not change during the calls,
so if one fails for this reason, then all will fail for this reason.
Lift the check into the caller so that the loop of repeated calls can be
skipped if the mode check fails.
2022-04-24 20:42:01 +00:00
Kp a610a7b32d Pass bare object & to thief stealing routines
Use `object &` instead of `vmobjptr_t`.  This should generate equivalent
code, but produce smaller debug information and may require less
inlining by the compiler.
2022-04-24 20:42:01 +00:00
Kp 1c2e1c6946 Tighten type info for d_strdup
The allocated block is part of the dmem subsystem, so return a type that
reflects that.
2022-04-24 20:42:01 +00:00
Kp 81dd23b151 Only charge player for weapons that fire successfully
If creating the weapon object fails, do not charge the player for the
shot that was not created.
2022-04-17 22:27:19 +00:00
Kp 5b29428643 Propagate nfires within do_laser_firing
Previous work made this a local constant.  Propagate that constant now
to eliminate dead conditional paths.
2022-04-17 22:27:19 +00:00
Kp 8f8989e049 Propagate do_laser_firing nfires as 1
Every caller passes `1`, so remove the parameter and always use `1`.
For backward compatibility with the previous network protocol, continue
to send a `1` in the network message.
2022-04-17 22:27:19 +00:00
Kp c4fb3fc30f Defer creating awareness event until weapon is created
If creation of the weapon object fails, do not tell robots that the
weapon was fired.
2022-04-17 22:27:19 +00:00
Kp dde3747ed4 Improve drop-secondary messages
- Write a more specific message on failure
- Defer writing a success message until `spit_powerup` succeeds
- Defer the sound too
- Rewrite the success message to tell how much ammo remains
2022-04-17 22:27:19 +00:00
Kp 834aeea23f Fix drop-primary/drop-secondary keys
Commit 8c8b7419b6 defined Shift-F5 and Shift-F6 to adjust the VR
handling.  However, Shift-F5 and Shift-F6 already had a meaning: drop
primary weapon / drop secondary weapon.  The ordering of the logic
causes the new VR handling to suppress the old drop handling, thus
preventing players from dropping weapons.  Disable the VR meaning for
these keys so that drop-weapon works again, since F1 documents those
keys as drop-weapon.

Fixes: 8c8b7419b6 ("Improved conditionals for stereo vs non-stereo modes.")
2022-04-17 22:27:19 +00:00
Kp f79baf722c Move static obj_* functions into anonymous namespace 2022-04-17 22:27:19 +00:00
Kp cf2c7bbe80 Replace serial byteswap macros with constexpr function
This allows taking the input by-value instead of by-reference, while
still protecting against unwanted type conversion.

Add some basic static_assert tests that the swapped values are correct.
2022-04-17 22:27:19 +00:00
Kp 71b4c11f8c Combine DXX_HAVE_BUILTIN_BSWAP, DXX_HAVE_BUILTIN_BSWAP16
Commit f1606f7747 ("Simplify test for
__builtin_bswap16") changed the SConstruct test to either define both
DXX_HAVE_BUILTIN_BSWAP and DXX_HAVE_BUILTIN_BSWAP16 or to define neither
of them.  Follow up that commit by removing the definition of
DXX_HAVE_BUILTIN_BSWAP16 and redirecting uses of it to
DXX_HAVE_BUILTIN_BSWAP.
2022-04-17 22:27:19 +00:00
Kp 2a6c513ffd Fix LTO ODR build failure in wall.h
The conditional definition of a D2X flag causes a technical ODR
violation.  It is legal, though not useful, to define this flag in D1X
and in common code.  Remove the preprocessor guard so that D2X and
common code use the same definition for the enum.
2022-04-17 22:27:19 +00:00
Kp d0c32b8cf2 Pass LevelUniqueWallSubsystemState to wall_init 2022-04-17 22:27:19 +00:00
Kp 211dcede72 Inline trigger_init
It is used in only one place.  Move it inline.
2022-04-17 22:27:19 +00:00