Commit graph

3361 commits

Author SHA1 Message Date
Kp f43665917e Merge branch ziplantil/win32-sdl2-cdaudio-sync into master 2019-10-28 00:45:34 +00:00
ziplantil b38f99d7ce modify SConstruct to handle target platform; fix track finish detect code 2019-10-27 14:53:48 +02:00
ziplantil 24fc28c8bd indent fixes, improve comments, other code fixes 2019-10-27 03:11:15 +03:00
ziplantil e664d93ea4 add hack for MCI or CD driver bug (?) 2019-10-27 02:48:20 +03:00
ziplantil 2c5ab8e739 initial version of this, trying to catch MCI events 2019-10-27 02:47:45 +03:00
Kp d2640462cb Backport D2's Dont_start_sound_objects to D1
Descent 2 has a hack, present as far back as I can trace, that
suppresses starting sounds during level load.  The original reason was
not recorded, but this hack has the useful side effect that it avoids
using uninitialized data when set_sound_sources tries to use a Viewer
that has not been reset for the objects of the new level.

Descent 1 lacks this hack, so an invalid Viewer is used, which may
trigger a valptridx trap if the undefined data has an invalid segment
number, and could cause memory corruption in builds which do not
validate the segment index.  The valptridx trap:

```
terminate called after throwing an instance of 'valptridx<dcx::segment>::index_range_exception'
  what():  similar/main/digiobj.cpp:389: invalid index used in array subscript: base=(nil) size=9000 index=65021
```

The backtrace leading to the trap:
```
d1x::digi_link_sound_common (viewer=..., so=..., pos=..., forever=<optimized out>, max_volume=<optimized out>, max_distance=..., soundnum=42, segnum=...) at similar/main/digiobj.cpp:389
0x00005555555a4e2d in d1x::digi_link_sound_to_pos2 (vcobjptr=..., max_distance=..., max_volume=32768, forever=1, pos=..., sidenum=4, segnum=..., org_soundnum=121) at similar/main/digiobj.cpp:483
d1x::digi_link_sound_to_pos (soundnum=soundnum@entry=121, segnum=..., sidenum=sidenum@entry=4, pos=..., forever=forever@entry=1, max_volume=32768) at similar/main/digiobj.cpp:490
0x00005555555c140d in d1x::set_sound_sources (vcsegptridx=..., vcvertptr=...) at similar/main/gameseq.cpp:817
d1x::LoadLevel (level_num=<optimized out>, page_in_textures=1) at similar/main/gameseq.cpp:1022
0x00005555555c2654 in d1x::StartNewLevelSub (level_num=-1, page_in_textures=<optimized out>) at similar/main/gameseq.cpp:1865
```

Backport this hack into Descent 1.  Ultimately, the hack should go away
and data should be loaded in an order that does not access undefined
memory.

Reported-by: Spacecpp <https://github.com/dxx-rebirth/dxx-rebirth/issues/463>
2019-10-26 23:13:14 +00:00
Kp d056611989 Fix mglobal.cpp build in clang-9
clang-9 reports:

```
similar/main/mglobal.cpp:210:44: error: 'report_error_uses_exception' is a protected member of 'valptridx_specialized_type_parameters<unsigned char, 90, valptridx_untyped_utilities::report_error_style::exception, valptridx_untyped_utilities::report_error_style::exception>'
template <typename T, bool = valptridx<T>::report_error_uses_exception::value>
                                           ^
similar/main/mglobal.cpp:229:16: note: in instantiation of default argument for 'instantiation_guard<dcx::active_door>' required here
template class instantiation_guard<dcx::active_door>::type::index_range_exception;
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/include/fwd-valptridx.h:42:2: note: constrained by protected inheritance here
    protected valptridx_specialized_types<managed_type>::type
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/include/cpp-valptridx.h:175:8: note: member is declared here
    using report_error_uses_exception = std::integral_constant<bool,
```

Add a `using` statement to switch `report_error_uses_exception` to
`public` access.  Nothing else uses it, and there is no design purpose
served by keeping it `protected`.
2019-10-23 02:58:41 +00:00
Kp 781a7366a9 Whitelist Vertigo smelter's phoenix cannon
Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/458>
Fixes: 2bcc7bb371 ("Only create lasers for known weapon types")
2019-10-21 03:45:29 +00:00
daivuk 74ef8b02e6 Added axis buttons
Each axis can act as two buttons in both ways.
For example, a player might map slide left and slide right to J1 -A1 and J1 +A1 as button presses instead of the slide L/R axis.

This is mostly to fix XBox 360 Controller Left and Right triggers. But it can work on every axis if the player wishes to bind them.
2019-09-01 13:11:14 -04:00
Kp c355e207fe Refactor song loading
Use an RAII object to manage allocations and keep the length and pointer
together.
2019-08-25 16:43:17 +00:00
Kp 2b2ca67de5 Add enumerated_iterator::operator==
Defining _GLIBCXX_DEBUG introduces a dependency on this method.
Implement it so that _GLIBCXX_DEBUG can be used.
2019-08-24 18:14:16 +00:00
Kp dd0f639176 Avoid reducing player's highest-level when replaying a non-MRU level
If the level was not the most recently played, a save is forced so that
it can be marked as most recently played.  However, the logic to force
the save also forced an update of the highest-level field, even if that
reduced it.

- Rename the parameter to clarify its meaning.
- Add comments explaining the logic to force the save.
- Only update the highest-level field when the update would increase the saved value
2019-08-24 04:32:24 +00:00
Kp 6d0cd8513e Recompute automap subcanvas on window size change
The subcanvas is positioned based on the dimensions of the containing
window, so it must be repositioned if the outer window is resized.

Reported-by: vLKp <https://github.com/dxx-rebirth/dxx-rebirth/issues/394>
Fixes: f491059ed7 ("Enable building with SDL2")
2019-08-18 20:37:29 +00:00
Kp ade6ee4195 Move exit_segnum to d_player_unique_endlevel_state
exit_segnum is set during load_endlevel_data, which currently runs too
early for this to depend on the exit used, and thus to be player-unique.
That data should be loaded at need, when the level ends, rather than
during level setup.  This can be addressed later, when support for
multiple exits is improved.
2019-08-15 01:34:22 +00:00
Kp 2daf788b34 Move transition_segnum to d_player_unique_endlevel_state
transition_segnum is a function of how the player exited the mine, since
there could be multiple exit tunnels, although current code appears not
to handle that well in other places.  Therefore, it needs to be
per-player data, not part of the level data, where it would not depend
on the player exiting.
2019-08-15 01:34:22 +00:00
Kp 9bafdc9078 Move Death_sequence_aborted to d_game_view_unique_state 2019-08-15 01:34:22 +00:00
Kp 6f9657cf9b Move controlcen_death_silence to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp 9f0b455f6d Move Reactor_strength to d_level_shared_control_center_state 2019-08-15 01:34:22 +00:00
Kp 9689a7f7d2 Move Base_control_center_explosion_time to d_level_shared_control_center_state 2019-08-15 01:34:22 +00:00
Kp f2eebca6c3 Move Last_time_cc_vis_check to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp d9d536afda Move Control_center_player_been_seen to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp 0826881fa0 Move Dead_controlcen_object_num to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp d0a9d8db98 Move Control_center_present to d_level_unique_control_center_state
This could be a shared variable instead, since it cannot be directly
influenced by gameplay.  However, it is influenced by the game mode, and
keeping shared variables that are mode-specific would be more complexity
for very little savings.
2019-08-15 01:34:22 +00:00
Kp 11278eb153 Rename Control_center_next_fire_time to Frametime_until_next_fire
Clarify the type of the value.
2019-08-15 01:34:22 +00:00
Kp 195f5e7d9f Move Control_center_next_fire_time to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp 885296b136 Move Control_center_been_hit to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp f988948eef Move Countdown_timer to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp 21c927584b Move Total_countdown_time to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp 707b3c5b0d Move Countdown_seconds_left to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp 519edb9e16 Move Control_center_destroyed to d_level_unique_control_center_state 2019-08-15 01:34:22 +00:00
Kp 0d9e032c60 Factor out some multi net_destroy_controlcen usage 2019-08-15 01:34:22 +00:00
Kp 8997f622bd is_proximity_bomb_or_smart_mine*: s/smart/player_smart/g
As documented in zico's commit 38fabd7c49, robot smart mines have a
different ID number than player smart mines.  Rename the test functions
to clarify that they only recognize player smart mines, but not robot
smart mines.

git grep -l is_proximity_bomb_or_smart_mine | xargs sed -i -e 's/is_proximity_bomb_or_smart_mine/is_proximity_bomb_or_player_smart_mine/g'
2019-08-15 01:34:22 +00:00
Kp 2ceb0168f2 Split is_proximity_bomb_or_smart_mine* to d1x/d2x 2019-08-15 01:34:22 +00:00
Kp b8cb819bb4 Make read_sndfile static for D1
Currently, only D2 can reread sounds.  Restore static for D1
read_sndfile.
2019-08-15 01:34:22 +00:00
Kp aa9bea4b92 Remove redundant declaration of Piggy_hamfile_version 2019-08-15 01:34:22 +00:00
ziplantil d9c113c315 load .s11,.s22 when loading D2 mission to allow custom sounds 2019-08-13 22:47:22 +03:00
Christian Beckhäuser 38fabd7c49 Fixed two issues with game's transparency effects feature (which I introduced when implementing it): First, Superprox mines dropped by enemies were made undesirably transparent since they have their own ID not considered by is_proximity_bomb_or_smart_mine(). Second, only some force field textures in D2X had transparency effects since the game has two different textures for force fields - eclip num 78 and 93 - but only the former was defined and used in is_alphablend_eclip() 2019-08-08 11:57:52 +02:00
Kp 334da8e8e6 Move some SDL-only symbols into !DXX_USE_OGL 2019-08-06 02:59:41 +00:00
Kp f0faac66d4 Move Seismic_tremor_magnitude to d_level_unique_seismic_state 2019-08-06 02:59:41 +00:00
Kp 4b0f797d7e Move Secret_return_orient to d_level_shared_segment_state 2019-08-06 02:59:41 +00:00
Kp ad16d90dd5 Move Secret_return_segment to d_level_shared_segment_state 2019-08-06 02:59:41 +00:00
Kp 625d863c55 Move Smega_detonate_times to d_level_unique_seismic_state::Earthshaker_detonate_times 2019-08-06 02:59:41 +00:00
Kp 140711cb35 Move Next_seismic_sound_time to d_level_unique_seismic_state 2019-08-06 02:59:41 +00:00
Kp 8fd231e501 Move Seismic_tremor_volume to d_level_unique_seismic_state 2019-08-06 02:59:41 +00:00
Kp 42778ff7fa Move Level_shake_duration to d_level_shared_seismic_state 2019-08-06 02:59:41 +00:00
Kp b8fa75c8cb Move Level_shake_frequency to d_level_shared_seismic_state 2019-08-06 02:59:41 +00:00
Kp 184337e6e1 Move Seismic_disturbance_end_time to d_level_unique_seismic_state 2019-08-06 02:59:40 +00:00
Kp ef0e64d421 Move awareness events to d_level_unique_robot_awareness_state 2019-08-06 02:59:40 +00:00
Kp 03214c0e6f Fix original game bug that meant to reset camera flag, but did not 2019-08-06 02:59:40 +00:00
Kp 215252b8ca Fold Final_boss_is_dead into Final_boss_countdown_time 2019-08-06 02:59:40 +00:00
Kp 5455a65d33 Move Final_boss_countdown_time to d_game_unique_state 2019-08-06 02:59:40 +00:00
Kp 3d8c02fefa Move Final_boss_is_dead to d_game_unique_state 2019-08-06 02:59:40 +00:00
Kp 7d803cf63e Move some save/restore functions to dcx/dsx as appropriate 2019-08-06 02:59:40 +00:00
Kp be84013494 Move Boss_hit_time to d_level_unique_boss_state 2019-08-06 02:59:40 +00:00
Kp 0a74eb6989 Move Boss_hit_this_frame to d_level_unique_boss_state 2019-08-06 02:59:40 +00:00
Kp 75440153a0 Move Boss_dying_sound_playing to d_level_unique_boss_state 2019-08-06 02:59:40 +00:00
Kp a0c242c46f Move Boss_dying_start_time to d_level_unique_boss_state 2019-08-06 02:59:40 +00:00
Kp 63d869fa0c Move Boss_dying to d_level_unique_boss_state 2019-08-06 02:59:40 +00:00
Kp 4ec96337b6 Move Last_teleport_time to d_level_unique_boss_state 2019-08-06 02:59:40 +00:00
Kp 69404ebc6e Move Boss_cloak_start_time to d_level_unique_boss_state 2019-08-06 02:59:40 +00:00
Kp 184be218b7 Emulate D1 bosses more accurately
Use D1 timing for gating, cloaking, and teleporting
2019-08-06 02:59:40 +00:00
Kp 49fd1f358e Eliminate unnecessary Gamesave_current_filename
It is only read in contexts where the initializing filename is still
available, so pass the filename down instead of copying it to a global.
2019-08-06 02:59:40 +00:00
Kp de77d2412b Move Automap_visited to d_level_unique_automap_state 2019-08-06 02:59:40 +00:00
Kp 635ae0b595 Use typedef for savegame description 2019-07-28 21:09:07 +00:00
Kp f43141f738 Use typedef for savegame file path 2019-07-28 21:09:07 +00:00
Kp 65555b6eba Require only object_base for object_to_object_visibility 2019-07-27 17:48:03 +00:00
Kp dd8cfa763f Expand gcc memcpy workaround
Add link to upstream bug report.
2019-07-22 00:51:01 +00:00
Kp 347d1ba05f Shrink struct vclip
`flags` only needs to be 1 bit wide, so switch from `int` to `uint8_t`.
Shrinking to a single bit would not save more space, but would
complicate the code.
2019-07-20 18:24:24 +00:00
Kp 41f4e84261 Move Stolen_item_index into d_thief_unique_state 2019-07-16 04:00:50 +00:00
Kp a2560cdfb5 Move Stolen_items into d_thief_unique_state 2019-07-16 04:00:50 +00:00
Kp 91bb7e533c Move player::hostages_total to d_game_unique_state
The number of hostages in a game is a function of the the game's levels,
not any particular player.  Move it to d_game_unique_state and rename it
to total_hostages.
2019-07-16 04:00:50 +00:00
Kp 8f475021ca Move player::hostages_level to d_level_unique_object_state
The number of hostages on a level is a function of the level, not any
particular player.  Move it to d_level_unique_object_state and rename it
to total_hostages.
2019-07-16 04:00:50 +00:00
Kp 2ca2de6ee7 Move player::num_robots_total to d_game_unique_state
The number of robots accumulated in a game is a function of the the
game's levels, not any particular player.  Move it to
d_game_unique_state and rename it to accumulated_robots.
2019-07-16 04:00:50 +00:00
Kp a24de0c003 Move player::num_robots_level to d_level_unique_object_state
The number of robots accumulated on a level is a function of the level,
not any particular player.  Move it to d_level_unique_object_state and
rename it to accumulated_robots.
2019-07-16 04:00:50 +00:00
Kp e33aaa7537 Make init_player_stats_level static 2019-07-16 04:00:50 +00:00
Kp c61dee7e6a Move Boss_teleport_interval to d_level_shared_boss_state 2019-07-13 22:28:57 +00:00
Kp 595c3ca086 Move Boss_cloak_interval to d_level_shared_boss_state 2019-07-13 22:28:57 +00:00
Kp b47f84ffd4 Move Gate_interval to d_game_unique_state 2019-07-13 22:28:57 +00:00
Kp 9df482a423 Move Last_gate_time to d_level_unique_boss_state 2019-07-13 22:28:57 +00:00
Kp 867223556c Fix fallthrough warning in ntmap.cpp [SDL only] 2019-07-07 22:00:02 +00:00
Kp 8d349dd0c1 Include pilot name in window caption 2019-07-07 22:00:02 +00:00
Kp 0c7de10512 Track chosen pilot name outside Players[]
Players need not be defined outside a game, but the pilot's name needs
to be available outside a game.  Therefore, track it outside Players[].
2019-07-07 22:00:02 +00:00
Kp bfeca84bb8 Change object::signature to be a generation counter
This removes the need to walk all objects when creating a new one, since
each object can have a private generation counter, unaware of other
objects.  For compatibility with demos, mix in the object's index when
writing the signature value.
2019-07-07 22:00:02 +00:00
Kp efc071e830 Make init_player_stats_ship static 2019-07-07 22:00:02 +00:00
Kp 597cb41717 Downgrade PCX failures from Error to CON_URGENT
There is no need to kill the program due to a missing or malformed PCX file.
2019-07-07 22:00:02 +00:00
Kp e2692d26ab Clear grs_main_bitmap before initializing
No code path has been observed causing a leak by reinitializing without
resetting, but add an explicit reset to prevent future mistakes.
2019-07-07 22:00:02 +00:00
Kp 1eaaff3016 Move Difficulty_level to GameUniqueState 2019-06-27 03:26:20 +00:00
Kp cfb481c74a Add experimental support for guidebot in multiplayer
This was requested by a user in early 2018.  However, the proposed
prototype was susceptible to various forms of desynchronization, and was
unsuitable for merging.  No further revisions were proposed, and the
feature languished.  This commit enables the guidebot in cooperative
games and addresses the known synchronization problems, as well as some
other bugs that were uncovered during light testing.  This is classified
as an experimental feature because it has not been heavily tested in
complicated games.

Requested-by: cfeuersaenger <https://github.com/dxx-rebirth/dxx-rebirth/issues/364>
2019-06-27 03:26:20 +00:00
Kp bea95ce1df Reset definedness of per-game globals on new game 2019-06-27 03:26:20 +00:00
Kp d03a6c44b8 Register new pilots on menu creation, not activation 2019-06-27 03:26:20 +00:00
Kp aacdaa77fe Use std::find_if in create_buddy_bot
Avoid open-coded for loop.
2019-06-27 03:26:20 +00:00
Kp af166735cc Use enum class for player visibility 2019-06-20 04:02:27 +00:00
Kp 5ab50520b7 Remove unused vec_to_player in D1 ai_follow_path
Only Descent 2 uses this field.
2019-06-20 04:02:27 +00:00
Kp 72f04b9828 Remove exploding wall assertion
In multiplayer, the host sends a destroy message for both sides of the
wall.  `do_exploding_wall_frame` processes both, but
`num_exploding_walls` is only decreased by 1, causing an assertion
failure at the end.  Remove the assertion, since the wall does not
explode instantly on join, despite being marked as WALL_EXPLODING.
2019-06-20 04:02:27 +00:00
Kp bfcff2cefe Fix crash loading guidebot with unreachable goal
Remove use of object_guidebot_cannot_reach and instead track the
reachability of the object as a separate flag.  This allows the game to
remember when an object was found, but unreachable.  Previously, it
would store only that some unreachable object was found.  Now, it stores
the index of the unreachable object.  This extra information is not used
yet.

Reported-by: Dainslaif <https://github.com/dxx-rebirth/dxx-rebirth/issues/421>
Fixes: c3cead4319 ("Move Escort_goal_index to d_unique_buddy_state")
2019-05-26 00:44:37 +00:00
Chris 44212ed77b Changed default tracker host address from dxxtracker.hopto.org to tracker.dxx-rebirth.com as requested by A Future Pilot 2019-05-17 15:36:58 +02:00
Kp 3a5e203638 Fix Windows build of hmp.cpp
Reported-by: zicodxx <private>
Fixes: 2243cd7f58 ("Use xrange for loops with zero start and constant numerical end")
2019-05-17 02:13:22 +00:00
Kp 48527630dd Remove __attribute__((packed)) on shortpos for gcc-9 support
gcc-9 warns on taking the address of an unaligned member in a packed
structure.  This structure does not need to be packed.  Remove
__attribute__((packed)) and fix the code to implement I/O correctly
without packing.
2019-05-11 20:18:29 +00:00
Kp 2c91eda5bc Fix various gcc-9 -Wformat-truncation warnings 2019-05-06 00:36:16 +00:00
Kp 5ea591af18 Fix gcc-9 build of d_range.h
gcc-9 rejects `std::enable_if<false,
std::integral_constant<std::integral_constant, 1> 0>::type` before it
notices that the whole expression is eliminated due to SFINAE.  Use
`std::common_type` to coerce the inner integral_constant to an
appropriate integer type, which allows the expression to be well-formed
enough to reach the SFINAE check from enable_if, then be silently
removed from the overload resolution set.
2019-05-06 00:36:16 +00:00