diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp index e7365d722..f5300a734 100644 --- a/source/duke3d/src/d_menu.cpp +++ b/source/duke3d/src/d_menu.cpp @@ -427,6 +427,12 @@ void GameInterface::MenuOpened() totalclock = ototalclock; screenpeek = myconnectindex; } + + auto& gm = g_player[myconnectindex].ps->gm; + if (gm & MODE_GAME) + { + gm |= MODE_MENU; + } } void GameInterface::MenuSound(::GameInterface::EMenuSounds snd) @@ -450,8 +456,32 @@ void GameInterface::MenuSound(::GameInterface::EMenuSounds snd) void GameInterface::MenuClosed() { S_PlaySound(EXITMENUSOUND); - if (!ud.pause_on) + + auto& gm = g_player[myconnectindex].ps->gm; + if (gm & MODE_GAME) + { + if (gm & MODE_MENU) + I_ClearAllInput(); + + // The following lines are here so that you cannot close the menu when no game is running. + gm &= ~MODE_MENU; + + if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + CAMERACLOCK = (int32_t)totalclock; + CAMERADIST = 65536; + + // Reset next-viewscreen-redraw counter. + // XXX: are there any other cases like that in need of handling? + if (g_curViewscreen >= 0) + actor[g_curViewscreen].t_data[0] = (int32_t)totalclock; + } + + G_UpdateScreenArea(); S_PauseSounds(false); + } } bool GameInterface::CanSave() diff --git a/source/rr/src/d_menu.cpp b/source/rr/src/d_menu.cpp index 017c03485..7055bb9a8 100644 --- a/source/rr/src/d_menu.cpp +++ b/source/rr/src/d_menu.cpp @@ -355,6 +355,12 @@ void GameInterface::MenuOpened() totalclock = ototalclock; screenpeek = myconnectindex; } + + auto& gm = g_player[myconnectindex].ps->gm; + if (gm & MODE_GAME) + { + gm |= MODE_MENU; + } } void GameInterface::MenuSound(::GameInterface::EMenuSounds snd) @@ -378,8 +384,32 @@ void GameInterface::MenuSound(::GameInterface::EMenuSounds snd) void GameInterface::MenuClosed() { S_PlaySound(EXITMENUSOUND); - if (!ud.pause_on) + + auto& gm = g_player[myconnectindex].ps->gm; + if (gm & MODE_GAME) + { + if (gm & MODE_MENU) + I_ClearAllInput(); + + // The following lines are here so that you cannot close the menu when no game is running. + gm &= ~MODE_MENU; + + if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + CAMERACLOCK = (int32_t)totalclock; + CAMERADIST = 65536; + + // Reset next-viewscreen-redraw counter. + // XXX: are there any other cases like that in need of handling? + if (g_curViewscreen >= 0) + actor[g_curViewscreen].t_data[0] = (int32_t)totalclock; + } + + G_UpdateScreenArea(); S_PauseSounds(false); + } } bool GameInterface::CanSave()