Commit graph

3418 commits

Author SHA1 Message Date
Kp b037cd556f Explicitly default valptridx<T>::strong_typedef
gcc considers strong_typedef to be POD both with and without the
explicit default.  clang considers it to be POD only if the constructor
is explicitly defaulted.
2019-12-17 05:01:38 +00:00
Kp 0d9b488be4 Support building valptridx without slice checking
For correctness, valptridx::ptridx instances must not be sliced down to
their component ::ptr or ::idx base classes.  Previously, this was done
with a dummy template parameter to ensure that a bare ::idx had a
different type than the idx base of a ::ptridx.  This extra distinction
complicates analysis of the code, and is not needed when the code is
already correct.  Add the ability to build without slice checking.
2019-12-16 01:57:00 +00:00
Kp 219a3fcd11 Move laser_info::get_last_hitobj out of line
It is only used in two places, neither of which are hot paths.  Move it
out of line so that other files do not need to parse it.
2019-12-16 01:56:59 +00:00
Kp 148fe47d82 Split checked/unchecked valptridx converting constructor logic
This allows the caller to omit filename/line information for calls that
will never need it.
2019-12-16 01:56:59 +00:00
Kp 5950485a6c Fix ptridx move constructor delegating to ptr copy constructor
Fix a bug where the ptridx converting move constructor delegated to the
ptr converting copy constructor, since the ptr copy constructor had
filename/line arguments, the ptr move constructor did not, and the
ptridx move constructor always passed filename/line.
2019-12-16 01:56:59 +00:00
ziplantil cb2b844af3 do not free extra models when loading exit stuff on D2 2019-12-12 17:25:11 +02:00
Kp 075b14373a Change Difficulty_level_type from unsigned to signed
Difficulty_level_type is used in arithmetic expressions.  If
Difficulty_level_type is unsigned, then those expressions use unsigned
terms, but some of the expressions were designed to use signed terms and
produce incorrect results when used with unsigned terms.  There is no
strong reason to make Difficulty_level_type unsigned, so switch it to
signed instead of trying to fix every site that uses it.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/471>
Fixes: 1eaaff3016 ("Move Difficulty_level to GameUniqueState")
2019-11-17 23:27:13 +00:00
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
Kp 10de0975f4 Fix gcc-9 build of joy.cpp
gcc-9 fails to constrain `i`, then warns that very large `i` would
be truncated.  Add `cf_assert` and `xrange` to inform gcc that `i` is
constrained.
2019-05-06 00:36:16 +00:00
Kp 340dc79bec Fix check_header_includes=1 build 2019-05-04 18:27:37 +00:00
Kp a52d8106ce Use xrange for loops with simple identifier start and simple identifier end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*\([A-Za-z_0-9]\+\)\s*;\s*\2\s*!=\s*\([A-Za-z_0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\3, \4))/
2019-05-04 18:27:37 +00:00
Kp 3bd10610fc Use xrange for loops with zero start and simple identifier end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*!=\s*\([A-Za-z_0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\3))/
2019-05-04 18:27:37 +00:00
Kp 538286e02c Add range helper zip() 2019-05-04 18:27:36 +00:00
Kp 2243cd7f58 Use xrange for loops with zero start and constant numerical end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*\(!=\|<\)\s*\([0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\4u))/
2019-05-04 18:27:36 +00:00
Kp 15ac8a5ac6 Add utility xrange for range-based loops with precomputed bounds
Utility xrange, inspired by the Python2 feature of the same name,
provides an object that returns successive values from [start, end).  It
is useful when the end index is known in advance, and is particularly
helpful when that index is expensive to recompute.
2019-05-04 18:27:36 +00:00
Kp 4d8d244bb9 Move spreadfire,helix orientation to player_info 2019-05-04 18:27:36 +00:00
Kp fb6323ed42 Use check_untrusted on boss robot messages 2019-04-28 00:53:40 +00:00
Kp 3e25804026 Use NSDMI wherever possible 2019-04-28 00:53:40 +00:00
Kp 3cc644eb52 Fix gcc-7 build of joy.cpp
gcc-7 needs an additional cf_assert to inform it that e.idx is
constrained.  Without this, it assumes e.idx could have any positive
value, then issues a fatal warning when INT_MAX does not fit in the
provided buffer.

    common/arch/sdl/joy.cpp: In function 'void dcx::joy_init()':
    common/arch/sdl/joy.cpp:281:6: error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 4 [-Werror=format-truncation=]
    common/arch/sdl/joy.cpp:281:6: note: directive argument in the range [1, 2147483647]
    common/arch/sdl/joy.cpp:333:13: note: 'snprintf' output between 6 and 24 bytes into a destination of size 8
2019-04-28 00:53:40 +00:00
Kp cc248602fd Track headlights in d_level_unique_light_state 2019-04-13 18:00:07 +00:00
Kp f69ba8ae82 Remove obsolete draw_vclip_object parameter lighted
It is always 0.
2019-04-13 18:00:07 +00:00
Kp 645daa2304 Format joystick indices as unsigned values 2019-04-13 18:00:07 +00:00
Kp e61100a858 Fix integer truncation in quaternion setup
Commit 47a6f744d split out redundant code, but accidentally stored
temporaries in a `signed short` instead of a `fix` as they should have
been.  This truncated some values, causing odd results whenever
quaternions were used.  Fix the problem by storing the intermediate
results in a `fix`.

Fixes: 47a6f744d8 ("Factor out vms_quaternion_from_matrix division")
Reported-by: Ninjared <https://forum.dxx-rebirth.com/showthread.php?tid=1113>
2019-04-13 18:00:07 +00:00
Kp 063bf29225 Enable -Wimplicit-fallthrough=5; fix resulting breaks
This enables using -Wimplicit-fallthrough with ccache+distcc, which
strip the fallthrough comments, but do not strip the attribute
annotationns.
2019-04-04 04:29:03 +00:00
Kp 5e434cbe95 Require availability of C++11 begin
Remove the fallback to Boost.Begin.  C++14 is now the minimum supported
standard, and any conforming C++14 compiler should have a working C++11
std::begin.
2019-04-04 04:29:03 +00:00
Kp 87125c5053 Fix Descent 1 laser color
Descent 1 mangles colors during `g3_init_polygon_model`, so this must
not be called on polygons not designed for mangling.  Rearrange the
logic to allow Descent 1 to verify that polygon models are well-formed
without using the functions that mangle the colors.

Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/416>
2019-03-20 03:57:15 +00:00
Kp 3aed2a1719 Move Num_robot_centers to d_level_shared_robotcenter_state 2019-03-12 04:01:07 +00:00
Kp 9898d136f1 Fix fortification crash loading missions with long filenames
The highest-level tracking code assumed filenames would always fit in a
char[9].  This was true on DOS, but has not been true in Rebirth for
many years.  Builds without fortification caused silent memory
corruption in this case.

Refuse to create highest-level entries if they would cause corruption.
Log a diagnostic telling the user that this happened.
2019-03-09 23:39:16 +00:00
Kp 42a2e3ab0b Avoid crash loading polymodels with invalid subcalls
Truncate the model at the first error.  This allows the level to load,
but makes some or all of the model invisible.
2019-03-06 05:03:48 +00:00
Kp 8764cad457 Use unsigned in more prototypes 2019-03-03 00:31:09 +00:00
Kp 3edef3c64b Move robot_create out of line
It is not used enough to justify its presence in a header.
2019-03-03 00:31:09 +00:00
Kp 699030606e Move Effects to d_level_unique_effects_clip_state 2019-03-03 00:31:09 +00:00
Kp 5dc630b58f Move Last_buddy_message_time to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp 5da35845d9 Move Buddy_last_player_path_created to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp 5b503c22a6 Move Escort_last_path_created to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp bc62ae694b Move Last_come_back_message_time to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp 7e61451792 Move Last_time_buddy_gave_hint to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp 7577a3e408 Move Escort_special_goal to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp d46fd99425 Move Buddy_last_missile_time to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp b1e19ac667 Move Buddy_last_seen_player to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp bd1cce0cc3 Move Buddy_sorry_time to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp ee584f1f37 Move Last_buddy_polish_path_tick to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp 9e3c5ec272 Move Last_buddy_key to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp b34e7bae24 Move Buddy_gave_hint_count to d_unique_buddy_state
Fix original bug that buddy was limited to 5 hints per program run, not
5 per boss as it probably should have been.

Due to savegame format limitations, this still is not right.  Reloading
the game should restore Buddy_gave_hint_count to its value at save time,
but will not.
2019-03-03 00:31:08 +00:00
Kp 58d59da9d2 Move Escort_goal_object to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp 926afe73d5 Move Looking_for_marker to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp ace3313dc3 Move Buddy_messages_suppressed to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp c3cead4319 Move Escort_goal_index to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp c02bee26d6 Move Buddy_allowed_to_talk to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp 420464549b Move Buddy_objnum to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp 1008ab397e Move Objects to d_level_unique_object_state 2019-03-03 00:31:08 +00:00