Commit graph

5164 commits

Author SHA1 Message Date
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 211a172c1d Tighten checks on killer_obj type
Do not assume that a type other than OBJ_ROBOT will be OBJ_WEAPON.
Check explicitly for OBJ_WEAPON.

Reported-by: Johnsondr80 <https://github.com/dxx-rebirth/dxx-rebirth/issues/437>
2019-08-21 02:54:08 +00:00
Kp 653a705e90 Test that guided missile's parent is still a player
If a guided missile is in flight, and its owning player dies, the
player's type is changed to OBJ_GHOST.  The damage that killed the
player should have put the guided missile into autonomous mode, so for
this purpose, return that the missile is not actively guided.

Reported-by: Johnsondr80 <https://github.com/dxx-rebirth/dxx-rebirth/issues/437>
2019-08-21 02:54:08 +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
ziplantil 6588bd6626 refactor secret level music code 2019-08-18 20:18:34 +03:00
ziplantil 79e0e2fdea dxx-r.sng: add !Rebirth.secret 2019-08-16 00:20:52 +03: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 6fe1c90aef Make D2 emulate D1 homers in D1 missions 2019-08-15 01:34:22 +00:00
Kp 4f8df36129 Compact HandleDeathInput 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 e58daea0da Restrict reactor-sleep logic to D2 levels
This code was not in D1, so running it when emulating D1 on the D2
engine is incorrect.
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 edc1ec0729 Fold multi_do_controlcen_destroy call of net_destroy_controlcen 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 fd09f9d36b Add is_proximity_bomb_or_any_smart_mine
Zico's commit 38fabd7c49 open-coded a test for a robot smart mine.  So
far, this is the only place it is needed, but others might arise.  Move
the test and its comment out to a static helper function.
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 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
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 ec234e0b8e Cache intermediate values in draw_mine_exit_cover 2019-08-06 03:02:32 +00:00
Kp 7f4c57b614 Merge https://github.com/ziplantil/dxx-rebirth.git branch 'exithatchfix' 2019-08-06 02:59:41 +00:00
Kp a4d3cbe5e5 Check for invalid orb dimensions when loading hoard data 2019-08-06 02:59:41 +00:00
Kp 31136cfd1b Fix undefined access if N_bitmaps <= 1
clang-check warns that if `N_bitmaps <= 1`, then
`DiskBitmapHeader_d1_read` will never run, but `bmh.wh_extra` will be
read in `bitmap_read_d1`.  Reorder the logic to return early if there
are no bitmaps.
2019-08-06 02:59:41 +00:00
Kp 04b50757c5 Explicitly test for nullptr in do_physics_align_object
clang-check warns about a potential binding a reference to nullptr in
the case that a segment has 0 sides.  While this is silly and
impossible, a related failure mode would occur if vm_vec_dot never
indicated a side as good.  This should be impossible, but the test for
nullptr is cheap, so add it to silence the checker.
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 4eb61ecf5c Fix original game bug: failure to reset Level_shake_duration
The game has an alternative level file format that is not normally used.
This format can enable seismic events on a timer, independent of reactor
countdown or earthshaker usage.  However, this feature is not reset on
loading a regular level after playing a level with the timer-driven
seismic events, so the regular level shakes according to the timer, even
though its author never designed it to do so.

Fix that by resetting the timer state to 0 before loading a regular
level.
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 7691e98304 Factor out seismic effect processing
Level seismic events and Earthshaker seismic events start with different
intensities, but share everything afterward.  Move the common parts to a
function.
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 596a17db69 Fold Seismic_sound_playing into Next_seismic_sound_time
When Next_seismic_sound_time is non-zero, a seismic sound is playing.
When Next_seismic_sound_time is zero, no sound is playing.  Use this to
eliminate the explicit tracking variable Seismic_sound_playing.
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
ziplantil bea2eaaec9 exit tunnel cover shape: make code neater 2019-07-29 00:57:55 +03:00
ziplantil e6f07a7b2f add black shape to cover 'mine' after exit hatch blows up 2019-07-29 00:43:04 +03:00
Kp dde11d0495 Merge https://github.com/ziplantil/dxx-rebirth.git branch 'cloakeffect' 2019-07-28 21:34:48 +00:00
Kp 635ae0b595 Use typedef for savegame description 2019-07-28 21:09:07 +00:00
Kp 5683c2b6ed Simplify skipping unnecessary callsign in savegame preview 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 76cfe1368d do_new_game_menu: improve new game dialog text 2019-07-28 21:09:07 +00:00
ziplantil 639d33b4de reorder palfx logic; use inline func in gr_palette_step_up 2019-07-28 12:47:24 +03:00
ziplantil 4f3b2a1520 make alast_* function-local 2019-07-28 01:41:37 +03:00
ziplantil f446790b03 optimize; abs no longer necessary 2019-07-28 00:49:30 +03:00
ziplantil 4eab54284c change palfx code; special only for all < 0 (cloak) 2019-07-28 00:42:37 +03:00
ziplantil 3753e5942d fix effect (on GL) when picking up cloak 2019-07-27 23:38:34 +03:00
Kp ac4f76136b object_create_explosion_sub: check object type before checking flash
`explode_badass_player` can pass an OBJ_PLAYER, not an OBJ_WEAPON, as
`obj_explosion_origin`.  Using `get_weapon_id` on a non-weapon is wrong
and provokes a diagnostic.  The test tries to check if the passed object
is _not_ a flash missile.  Players are not flash missiles, so maintain
the intended semantics by treating non-weapons as not-flash-missiles.

Reported-by: Johnsondr80 <https://github.com/dxx-rebirth/dxx-rebirth/issues/437>
2019-07-27 17:48:03 +00:00
Kp 3511da2a10 object_create_explosion_sub: improve variables' names
`objp`, `obj`, and `obj0p` is not helpful when trying to reason about
the logic of this function.  Rename them to `obj_explosion_origin`,
`obj_fireball`, and `obj_iter`, respectively.
2019-07-27 17:48:03 +00:00
Kp 65555b6eba Require only object_base for object_to_object_visibility 2019-07-27 17:48:03 +00:00
Kp 98ad2402bf Fix Win32 build 2019-07-22 00:51:01 +00:00
Kp 03130aac2c Fix blank player names in multiplayer
Reading from Players[] while not in a game is not well-defined.  Get the
local player's callsign from InterfaceUniqueState instead.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/435>
Fixes: bea95ce1df ("Reset definedness of per-game globals on new game")
2019-07-20 20:08:29 +00:00
Kp a17792c89f Always initialize station_idx on level start
It is reinitialized if the segment is a special segment, but not
reinitialized if the segment is a normal segment.  Most segments are
normal segments.  The absence of this initialization permitted players
to keep the value from a prior level.  For normal segments, this would
normally not be a problem, because the value is only meaningful for
special segments.  However, the netgame synchronization code always
mixes in the value of every station_idx, regardless of whether the
segment is a special segment.  As a result, late-joining guests who
started directly onto the current level could disagree with the host
about the value, causing a synchronization mismatch.  The host would be
wrong, but the guests would be blocked from joining.  For this purpose,
late-joining includes both people who joined the campaign late and
people who left the game and restarted the program, even if they had
previously been in the game.

Reported-by: OldSaltyGamer <https://forum.dxx-rebirth.com/showthread.php?tid=1098&pid=12630#pid12630>
[ Possibly also previously reported by LightWolf, but that report never
had enough information to proceed.  The report from OldSaltyGamer solved
this. ]
Fixes: 596ecbb38d ("Rename segment::value to segment::station_idx")
2019-07-20 18:24:24 +00:00
Kp ff9cff4fea Relax laser_parent_is_player check so that dead players match
Fixes: bfeca84bb8 ("Change object::signature to be a generation counter")
2019-07-18 02:06:45 +00:00
Kp b19149c7b3 Initialize Netgame name from InterfaceUniqueState
Players[] is not defined at this point.
2019-07-16 04:00:50 +00:00
Kp 4a9e027e02 Fix bug that ignored -pilot
Fixes: d03a6c44b8 ("Register new pilots on menu creation, not activation")
2019-07-16 04:00:50 +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 d2da218f94 Remove apply_damage_to_robot swapping of Stolen_items
It has always been here, but appears to serve no purpose.
`multi_explode_robot_sub` clears `Stolen_items`, so at first look, this
swap seems to be preserving the prior values.  However,
`multi_send_robot_explode` does not use `Stolen_items`, and after
`multi_send_robot_explode` completes, `Stolen_items` is explicitly wiped
again.  Thus, removing the whole block will let the wipe performed by
`multi_explode_robot_sub` stand, producing the same result with less
code.
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 46a327eb35 Move relocated player data to wrapper type 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 46e7f8e3d5 Backport Descent 2 change to ignore objects in AI visibility 2019-07-13 22:28:57 +00:00
Kp a65e461bb6 Restore D1 boss always-teleport in D1 missions
In Descent 1, up until commit 8291391, boss robots teleported without
regard to whether the player was visible or active.  Commit 8291391
changed that in an attempt to make the D2 emulation of D1 boss robots
behave well in levels that relied on the D2 quirk of spawning the boss
in a confined segment, then letting it teleport freely once the player
releases it.  However, that change applied even in D1 missions and in
the D1 engine, where maps were designed with the expectation that boss
robots teleported routinely.  Restrict the new rule to the D2 engine
playing D2 levels.  This enables boss robots to teleport freely on D1
missions, regardless of which engine is used.  It would be better if
there were a level flag explaining whether the author wanted the boss to
teleport freely, but there is no such flag, so this heuristic must
suffice.

Reported-by: TheMiracleMatter <https://github.com/dxx-rebirth/dxx-rebirth/issues/434>
Fixes: 8291391b7f ("Fix D2 emulation of D1 boss teleport handling")
2019-07-13 22:28:57 +00:00
Kp 7bd861e374 Only death-spew armed proximity bombs in multiplayer
Commit 829e95b6 meant to remove the restriction that the game not be
hoard mode, but incorrectly also removed the restriction that the game
be multiplayer.  Restore the multiplayer restriction.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/433>
Fixes: 829e95b6f8 ("Separate hoard/proximity tracking")
2019-07-12 02:01:53 +00:00
Kp d413a5da13 Initialize powerup flags at level load 2019-07-07 22:00:02 +00:00
Kp a10077f2ec Skip setting contains_type/contains_id on objects that contain nothing
If the count is zero, then the type and id should be undefined.
2019-07-07 22:00:02 +00:00
Kp 01eb585c7a Set matcen_creator on loaded robots
This avoids a Valgrind warning for use of an uninitialized field.
2019-07-07 22:00:02 +00:00
Kp eeb310467b Fix SDL-only link failure 2019-07-07 22:00:02 +00:00
Kp fcd2ce1b47 Fix SDL-only build of render.cpp 2019-07-07 22:00:02 +00:00
Kp 86053852dc Fix build of SDL-only gr.cpp 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 d750b25073 Avoid copying background to itself
`init_new_page` calls `load_briefing_screen` with the a pointer to
`br->background_name`, which causes a strncpy of the form

```
	strncpy(X, X, N);
```

Valgrind warns for this overlap.  The copy is useless in that case, so
skip it.
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 3a0cca001f Limit size of PCX files 2019-07-07 22:00:02 +00:00
Kp 75de1c23c1 Reduce ship rocking during countdown
A prior change switched to using the greater, rather than the lesser, of
`16` or `Countdown_seconds_left`, which increased the rotation from the
ship rocking effect.  Switch back to use the lesser value.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/431>
Fixes: 644d6fa513 ("Simplify do_countdown_frame ship rocking effect")
2019-06-28 01:14:36 +00:00
Kp 1eaaff3016 Move Difficulty_level to GameUniqueState 2019-06-27 03:26:20 +00:00
Kp 61755f4d68 Factor out difficulty adjustment to energy usage 2019-06-27 03:26:20 +00:00
Kp ba3d3107bc Backport auto-select of vulcan when energy exhausted
This was added to D2, but is useful in both games.  Apply it in D1, too.
2019-06-27 03:26:20 +00:00
Kp a4f06f1f51 Backport MK's mega/lava fix to D1 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 644d6fa513 Simplify do_countdown_frame ship rocking effect 2019-06-27 03:26:20 +00:00
Kp 171ad60262 Fix some type mismatches using player_path_set_orient_and_vel 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 f1878254df Simplify automap drawing of other players 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 d5510bfc82 Fix harmless robot ID check warning
`make_nearby_robot_snipe` computed the `robot_info` of every `object` in the
area before checking whether those `object`s were of type `OBJ_ROBOT`.  This
is wrong, but usually harmless since it checked the type before using
the resulting `robot_info`.  Starting in commit 9f26e2211, this triggered
a warning whenever `make_nearby_robot_snipe` checked nearby non-robot
`object`s.

Rewrite the tests to check for type `OBJ_ROBOT` before reading the
`object`'s id.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/429>
Fixes: 9f26e2211e ("Warn on invalid object ID access")
2019-06-21 02:51:49 +00:00
Kp 0105777b43 Fix highest_level tracking for D1X-Rebirth with First Strike
Commit 9898d13 fixed a crash on long filenames, but also tried to
optimize the Destination Saturn hack.  However, this optimization was
implemented incorrectly, and caused the game to read only the
Destination Saturn highest_level entry when playing the First Strike
campaign, rather than using the greater level of Destination Saturn or
First Strike.

Restore the old logic, but restrict it to D1X.  D2X never used an empty
string for the First Strike campaign, so this logic could not trigger
there, which is also how the bug was missed in initial testing.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/428>
Fixes: 9898d136f1 ("Fix fortification crash loading missions with long filenames")
2019-06-21 02:51:49 +00:00
Kp e671664332 Vary get-behind path for robots 2019-06-20 04:02:27 +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 4b4479b59a Split copyright/trademark lines to separate con_puts calls
This allows each line to have its own timestamp, which looks more
consistent in gamelog.txt.
2019-06-20 04:02:27 +00:00
Kp 459f754da5 Add workaround for PhysFS 3.0 ignoring symlinks to directories
PhysFS 3.0 tests whether archive members are directories, but treats a
symbolic link that points to a directory as distinct from the underlying
directory, even when symlink following is enabled.  As a result, if
$D2X_REBIRTH_HOME/missions is a symlink to a directory, then it is
ignored and no missions are available.  In PhysFS 2.0, the link was
followed and the missions were available.

Add a trailing dot to the path, which already has a trailing slash, to
force PhysFS to consider the underlying directory, not the link.
2019-06-20 04:02:27 +00:00
Kp 7e362f9433 Fix undefined behavior in D1 briefing setup
In one path, load_briefing_screen is called with `br->background_name`
as an input.  This caused a call to `snprintf(a, sizeof(a), "%s", a);`,
which is undefined behavior.  Switch back to the prior style of
unconditionally declaring a local array, performing filename
manipulation in that array, and copying the array back to
`br->background_name` afterward.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/420>
2019-05-30 03:29:24 +00:00
Kp 3a5b4ddd7b Fix clang signed/unsigned mismatch
Fixes: bfcff2cefe ("Fix crash loading guidebot with unreachable goal")
2019-05-28 03:39:23 +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
Kp f79f6ab1cc Make switches invulnerable to blast_nearby_glass
`blast_nearby_glass` calls `check_effect_blowup`, but ignores the result.
If `check_effect_blowup` executes a blow-up effect, and the blown object
is a switch, the return value will instruct the caller to execute the
associated trigger.  Since `blast_nearby_glass` ignores the return
value, it never executes a trigger.  This was originally masked by a bug
that passed undefined data from `blast_nearby_glass` to
`check_effect_blowup`, which usually confused `check_effect_blowup` into
treating the explosion as not originating from the player.  This
confusion then forced an early return when a switch was hit, effectively
accidentally making switches invulnerable to `blast_nearby_glass`.
Commit f6352e7 fixed the data confusion, allowing `check_effect_blowup`
to recognize that the explosion came from a player's weapon.  However,
it did not add handling for the trigger, so now `blast_nearby_glass` can
destroy the switch without activating the trigger.  This is at the least
annoying, and in some levels may make progress impossible.  There are
two ways to resolve this:

- Fix the logic to always execute the switch when the switch is
  destroyed, whether by direct hit or by `blast_nearby_glass`.
- Restore the quirk that switches are invulnerable to
  `blast_nearby_glass`.

Conveniently, the `force_blowup_flag` is set by `blast_nearby_glass` and
clear for all other callers, so it can be used to recognize that the
caller will not handle the switch.  Use this to implement choice 2.

Even with this change, a direct hit by a missile can still destroy a
switch and activate its trigger, since that is handled through
`collide_weapon_and_wall`.  Thus, players can still use the technique of
using a guided missile to activate an otherwise impossible switch.

Fixes: f6352e7957 ("Pass correct object to check_effect_blowup")
Reported-by: wm4 <https://github.com/dxx-rebirth/dxx-rebirth/issues/419>
2019-05-11 20:18:29 +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 f8769b9805 Fix gcc-9 -Wstringop-truncation in titles.cpp 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 57a850fce5 Use enumerate() to iterate some MAX_SIDES_PER_SEGMENT loops 2019-05-04 18:27:37 +00:00
Kp eb39a8087e Use xrange for render loops 2019-05-04 18:27:37 +00:00
Kp a7806dde5d Use xrange for loops with constant numerical start and simple identifier end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*\([0-9]\+\)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(\3u, \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 a74914eb9c Use xrange for loops with constant numerical start and end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*\([0-9]\+\)u\?\s*;\s*\2\s*!=\s*\([0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\3u, \4u))/
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 b5ddcfdd7b Unify D1/D2 openable_doors_in_segment conditions 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 0675e4bcad Factor out exit tunnel loop 2019-04-28 00:53:40 +00:00
Kp 3f31200997 Unify create_path_points D1/D2 check for doorway 2019-04-28 00:53:40 +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 0c99a97c63 Factor out player/fireball light emission 2019-04-13 18:00:07 +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 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 9bed4f6d78 Fix bogus borders due to fill_n length/value transposition
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/415>
Fixes: 7bcbaae230 ("Tighten protection against grs_bitmap bm_data confusion")
2019-03-29 02:34:53 +00:00
Kp cd261a8135 Simplify handicap handling 2019-03-29 02:34:53 +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 3a6bfb8dd6 Reduce use of vcobjptr in newdemo 2019-03-16 04:35:32 +00:00
Kp 31859ff128 Fix Win32 build
Windows std::ptrdiff_t is `int` instead of `long` as it should be.
Expand the values out to `long` (which is the same size as `int` on
Win32!) before printing them.  This fixes format string warnings.

Reported-by: Ninjared <https://forum.dxx-rebirth.com/showthread.php?tid=857&pid=12555#pid12555>
Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
2019-03-16 04:35:31 +00:00
Kp de53747452 Tighten test for color division by zero 2019-03-12 04:01:08 +00:00
Kp 3aed2a1719 Move Num_robot_centers to d_level_shared_robotcenter_state 2019-03-12 04:01:07 +00:00
Kp 73772f54b2 Open advanced sub-menus as submenus
Requested-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/121>
2019-03-10 18:48:40 +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 8f2bec3fde Remove bogus assertion in wall_hit_process
Fixes: 8764cad457 ("Use `unsigned` in more prototypes")
2019-03-06 05:03:48 +00:00
Kp 106de25617 Cache visited_segment_bitarray_t reference in apply_light_to_segment 2019-03-03 00:31:09 +00:00
Kp c992155ff1 Remove useless texture writeback in validate_segment_side 2019-03-03 00:31:09 +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 5b503c22a6 Move Escort_last_path_created 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 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 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 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
Kp a36eb1d52c Only use update_laser_weapon_info for quad laser change
Regular laser level changes are already tracked and handled separately.
2019-03-03 00:31:08 +00:00
Kp 5d99ec361d Simplify copy_defaults_to_robot
Write the shields once at the end.
2019-03-03 00:31:07 +00:00
Kp fec16daca4 Generate unique starfield per level 2019-02-02 18:36:39 +00:00
Kp 7bcbaae230 Tighten protection against grs_bitmap bm_data confusion
Bitmaps based on grs_main_bitmap own their data.  Bitmaps based on
grs_bitmap do not.  Adjust prototypes to prevent initializing a
grs_main_bitmap with data it will not own.
2019-02-02 18:36:39 +00:00
Kp 8dcf4f99e0 Suppress cooperative start report if not multiplayer coop
The value is only correct when the game is cooperative multiplayer.
Hide it when it would be incorrect.
2019-02-02 18:36:39 +00:00
Kp 92fdacfb60 Simplify do_cheat_menu
Reduce redundant player object lookups.
2019-02-02 18:36:39 +00:00
Kp ad6b857cf2 Move most laser_info fields to dcx 2019-02-02 18:36:39 +00:00
Kp 1037b2c296 Flip sense of boss_intersects_wall
This saves a boolean negation passing the result up.
2019-02-02 18:36:39 +00:00
Kp 12403a78f7 Pass vcvertptr to sphere_intersects_wall 2019-02-02 18:36:39 +00:00
Kp ffb5e8821c Flatten use of sphere_intersects_wall 2019-02-02 18:36:39 +00:00
Kp d7e85e0cff Move Boss_gate_segs, Boss_teleport_segs to d_level_shared_boss_state 2019-02-02 18:36:39 +00:00
Kp 05244122bd Tighten input for set_segment_depths 2019-02-02 18:36:39 +00:00