dxx-rebirth/similar/main
Kp d83972dfbb Hide game window when advancing a dead player to the next level
Commit 88b5e616a9 ("Replace calls to
window_set_visible in DoPlayerDead() with stop/start_time()") switched
from hiding the game window to only stopping time, and that only if
hiding the window would have stopped time.  In multiplayer, this allows
time to continue running.  This introduced a crash if the player dies
during the mine countdown.  When the player dies, the game checks if the
reactor has been destroyed.  If so, the game immediately advances to the
next level.  That advance will try to draw the game window if it is
visible.  When the window is drawn, if time is not stopped, then game
logic runs.  Some of that logic is not prepared to deal with the
inconsistent state present when a new level is only partially loaded.
That inconsistent state then causes a crash.  Call stack:

    #11 slew_frame () at similar/main/slew.cpp:152
    #12 in d2x::object_move_one () at similar/main/object.cpp:1758
    #13 in d2x::object_move_all () at similar/main/object.cpp:1956
    #14 in d2x::GameProcessFrame () at similar/main/game.cpp:1848
    #15 d2x::game_handler () at similar/main/game.cpp:1615
    #16 in dcx::window_send_event () at common/include/window.h:116
    #17 dcx::event_process () at common/arch/sdl/event.cpp:176
    #18 in newmenu_do2 () at similar/main/newmenu.cpp:498
    #19 in newmenu_do2<dcx::unused_newmenu_userdata_t> () at common/main/newmenu.h:184
    #20 newmenu_do<dcx::unused_newmenu_userdata_t const> () at common/main/newmenu.h:190
    #21 newmenu_do<1ul, dcx::unused_newmenu_userdata_t const> () at common/main/newmenu.h:196
    #22 net_udp_wait_for_requests () at similar/main/net_udp.cpp:4563
    #23 net_udp_level_sync () at similar/main/net_udp.cpp:4607
    #24 in multi_level_sync () at similar/main/multi.cpp:3458
    #25 in d2x::StartNewLevelSub () at similar/main/gameseq.cpp:1803
    #26 in d2x::StartNewLevel () at similar/main/gameseq.cpp:2018
    #27 in d2x::AdvanceLevel () at similar/main/gameseq.cpp:1648
    #28 in d2x::DoPlayerDead () at similar/main/gameseq.cpp:1721

The root cause of this is the layering violation:
- Killing the player can have the side effect of advancing the level
- Advancing the level can have the side effect of calling multiplayer code while the level data is in an inconsistent state
- Calling multiplayer code can cause the event system to redraw the game
- Redrawing the game can cause game logic to run

Hack around this by restoring the logic that hides the game window, so
that the window is not redrawn and the game logic is not run.  This does
not fix the layering problem, but prevents crashing affected users.  To
avoid undoing the feature from the breaking commit, hide the window only
when advancing to a new level, rather than unconditionally.  A player
advancing to a new level already lacks the move-at-cold-start capability
even on successfully escaping the mine, so no functionality is lost with
this change.  Players who are dead and do not advance to a new level
retain that capability.

Fixes: 88b5e616a9 ("Replace calls to window_set_visible in DoPlayerDead() with stop/start_time()")
Reported-by: Ninjared <https://forum.dxx-rebirth.com/showthread.php?tid=1097>
2018-12-08 19:16:01 +00:00
..
ai.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
aipath.cpp Pass segments to find_point_seg 2018-09-19 02:13:30 +00:00
automap.cpp Add experimental support for larger cooperative games 2018-12-03 04:25:11 +00:00
bm.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
bmread.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
cntrlcen.cpp Eliminate some uses of valptridx::operator-> 2018-06-24 05:06:15 +00:00
collide.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
config.cpp Make ADL MIDI runtime configurable 2018-10-18 02:18:56 +00:00
console.cpp Switch most in-tree http:// links to https:// 2018-09-02 00:57:29 +00:00
controls.cpp Move Guided_missile into d_level_object_state 2018-10-08 03:58:48 +00:00
credits.cpp Pass font to various drawing functions 2018-05-19 23:21:42 +00:00
digiobj.cpp Eliminate some uses of valptridx::operator-> 2018-06-24 05:06:15 +00:00
dumpmine.cpp Factor out piggy bitmap loading code 2018-08-26 18:10:36 +00:00
effects.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
endlevel.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
fireball.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
fuelcen.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
fvi.cpp Pass segments to find_point_seg 2018-09-19 02:13:30 +00:00
game.cpp Add experimental support for larger cooperative games 2018-12-03 04:25:11 +00:00
gamecntl.cpp Move Guided_missile into d_level_object_state 2018-10-08 03:58:48 +00:00
gamefont.cpp Enforce separation of font X/Y scaling 2018-06-08 04:04:05 +00:00
gamemine.cpp Pass d_level_shared_segment_state to validate_segment_all 2018-09-19 02:13:30 +00:00
gamerend.cpp Move Guided_missile into d_level_object_state 2018-10-08 03:58:48 +00:00
gamesave.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
gameseg.cpp Pass d_level_shared_segment_state to validate_segment_all 2018-09-19 02:13:30 +00:00
gameseq.cpp Hide game window when advancing a dead player to the next level 2018-12-08 19:16:01 +00:00
gauges.cpp Raise player life count storage from uint8_t to uint16_t 2018-12-01 01:58:37 +00:00
generate-kconfig-udlr.py Adapt to Python 3 strict bytes vs str rules 2018-04-30 05:31:16 +00:00
hostage.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
hud.cpp Fix bogus "Game Over" when dying with the maximum number of lives 2018-12-01 01:58:37 +00:00
iff.cpp Simplify test for corrupt IFF file 2018-04-03 03:20:08 +00:00
inferno.cpp Enable SHAREPATH for non-LinuxPlatformSettings 2018-09-14 02:20:55 +00:00
kconfig.cpp Pass font to various drawing functions 2018-05-19 23:21:42 +00:00
kconfig.ui-table.cpp Switch most in-tree http:// links to https:// 2018-09-02 00:57:29 +00:00
kmatrix.cpp Pass font to various drawing functions 2018-05-19 23:21:42 +00:00
laser.cpp Move Guided_missile into d_level_object_state 2018-10-08 03:58:48 +00:00
lighting.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
menu.cpp Enable building with SDL2 2018-07-28 23:22:58 +00:00
mglobal.cpp Pass segments to find_point_seg 2018-09-19 02:13:30 +00:00
mission.cpp Remove explicit std::move in prepare_mission_menu_state return 2018-10-20 17:25:59 +00:00
morph.cpp Eliminate some uses of valptridx::operator-> 2018-06-24 05:06:15 +00:00
multi.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
multibot.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
net_udp.cpp Add experimental support for larger cooperative games 2018-12-03 04:25:11 +00:00
newdemo.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
newmenu.cpp Remove use of -Wno-implicit-fallthrough 2018-08-24 02:58:21 +00:00
object.cpp Add experimental support for larger cooperative games 2018-12-03 04:25:11 +00:00
paging.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
physics.cpp Pass context to update_object_seg 2018-10-08 03:58:48 +00:00
piggy.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
player.cpp Switch most in-tree http:// links to https:// 2018-09-02 00:57:29 +00:00
playsave.cpp Warn users about tracker NAT hole punch feature 2018-06-21 03:08:36 +00:00
polyobj.cpp Split g3_start_instance_matrix usage 2017-08-26 19:47:51 +00:00
powerup.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
render.cpp Make Viewer const object * 2018-09-25 03:44:09 +00:00
robot.cpp Pass Robot_info, valptridx factories to more methods 2018-09-19 02:13:29 +00:00
scores.cpp Fix assertion on close of game over window 2018-06-15 02:58:01 +00:00
segment.cpp Switch most in-tree http:// links to https:// 2018-09-02 00:57:29 +00:00
slew.cpp Pass context to update_object_seg 2018-10-08 03:58:48 +00:00
songs.cpp Fix sdlmixer=0 build of songs.cpp 2018-07-30 00:49:59 +00:00
state.cpp Raise player life count storage from uint8_t to uint16_t 2018-12-01 01:58:37 +00:00
switch.cpp Consolidate stuck object state 2018-08-04 17:52:57 +00:00
terrain.cpp Move various SDL-only texture mapping functions to !DXX_USE_OGL 2017-11-01 02:01:21 +00:00
texmerge.cpp Make grs_bitmap::bm_flags private 2017-01-15 00:03:13 +00:00
text.cpp
titles.cpp Pass font to various drawing functions 2018-05-19 23:21:42 +00:00
vclip.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00
vers_id.cpp Switch most in-tree http:// links to https:// 2018-09-02 00:57:29 +00:00
wall.cpp Skip exploding walls during demo playback 2018-12-01 01:58:37 +00:00
weapon.cpp Pass Vclip as context 2018-10-21 00:24:07 +00:00