From aabbbcb2ff3df60a56310d4c7eaf916df29c93c8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 2 Sep 2020 10:00:07 +0200 Subject: [PATCH] - reset the network timer after lengthy operations. This includes loading a level and busy-waiting for a sound to play. Also block these loops and the sounds they wait for in network games to avoid problems from longer delays here. The problem seems to be directly inherited from ZDoom which shows the same issue with screen wipes. Fixes #297 --- source/core/d_net.cpp | 5 ++++- source/exhumed/src/gameloop.cpp | 4 +++- source/games/duke/src/d_menu.cpp | 3 ++- source/games/duke/src/premap.cpp | 1 - source/games/duke/src/savegame.cpp | 1 - source/sw/src/d_menu.cpp | 31 +++++++++++++++++------------- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/source/core/d_net.cpp b/source/core/d_net.cpp index 1c9865ea4..dbfd1b32b 100644 --- a/source/core/d_net.cpp +++ b/source/core/d_net.cpp @@ -1972,9 +1972,12 @@ void Net_SkipCommand (int type, uint8_t **stream) #endif } +// Reset the network ticker after finishing a lengthy operation. +// Q: How does this affect network sync? Only allowed in SP games? void Net_ClearFifo(void) { - // Q: Do we need this? + I_SetFrameTime(); + gametime = I_GetTime(); } diff --git a/source/exhumed/src/gameloop.cpp b/source/exhumed/src/gameloop.cpp index 8dd15c217..2ff76975d 100644 --- a/source/exhumed/src/gameloop.cpp +++ b/source/exhumed/src/gameloop.cpp @@ -46,6 +46,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "statistics.h" #include "g_input.h" #include "core/menu/menu.h" +#include "d_net.h" BEGIN_PS_NS @@ -78,7 +79,7 @@ static int FinishLevel(TArray &jobs) STAT_Update(lnum == kMap20); if (lnum != kMap20) { - if (EndLevel != 2) + if (EndLevel != 2 && !netgame) { // There's really no choice but to enter an active wait loop here to make the sound play out. PlayLocalSound(StaticSound[59], 0, true, CHANF_UI); @@ -88,6 +89,7 @@ static int FinishLevel(TArray &jobs) I_GetEvent(); soundEngine->UpdateSounds(I_GetTime()); } + Net_ClearFifo(); } } else nPlayerLives[0] = 0; diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 364d597d7..535d82eed 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -274,7 +274,7 @@ void GameInterface::StartGame(FNewGameStartup& gs) if (gs.Skill >=0 && gs.Skill <= 5) skillsound = isRR()? sounds_r[gs.Skill] : sounds_d[gs.Skill]; ud.m_player_skill = gs.Skill + 1; - if (menu_sounds && skillsound >= 0 && SoundEnabled()) + if (menu_sounds && skillsound >= 0 && SoundEnabled() && !netgame) { S_PlaySound(skillsound, CHAN_AUTO, CHANF_UI); @@ -284,6 +284,7 @@ void GameInterface::StartGame(FNewGameStartup& gs) soundEngine->UpdateSounds(I_GetTime()); I_GetEvent(); } + Net_ClearFifo(); } ud.m_respawn_monsters = (gs.Skill == 3); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index cd3edfcc3..bb82b815c 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -1011,7 +1011,6 @@ int enterlevel(MapRecord *mi, int gamemode) global_random = 0; ud.last_level = currentLevel->levelNumber; - Net_ClearFifo(); for (int i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; ps[myconnectindex].over_shoulder_on = 0; clearfrags(); diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index c88e46b37..f55dc8f95 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -517,7 +517,6 @@ void GameInterface::SerializeGameState(FSerializer& arc) recreateinterpolations(); show_shareware = 0; everyothertime = 0; - Net_ClearFifo(); // should be unnecessary with the sounds getting serialized as well. #if 0 diff --git a/source/sw/src/d_menu.cpp b/source/sw/src/d_menu.cpp index 4c01b0fe5..20d3df284 100644 --- a/source/sw/src/d_menu.cpp +++ b/source/sw/src/d_menu.cpp @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "menus.h" #include "pal.h" #include "keydef.h" +#include "d_net.h" #include "gamecontrol.h" #include "misc.h" @@ -218,20 +219,24 @@ void GameInterface::StartGame(FNewGameStartup& gs) //InitNewGame(); - if (Skill == 0) - PlaySound(DIGI_TAUNTAI3, v3df_none, CHAN_VOICE, CHANF_UI); - else if (Skill == 1) - PlaySound(DIGI_NOFEAR, v3df_none, CHAN_VOICE, CHANF_UI); - else if (Skill == 2) - PlaySound(DIGI_WHOWANTSWANG, v3df_none, CHAN_VOICE, CHANF_UI); - else if (Skill == 3) - PlaySound(DIGI_NOPAIN, v3df_none, CHAN_VOICE, CHANF_UI); - - while (soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE)) + if (!netgame) { - gi->UpdateSounds(); - soundEngine->UpdateSounds(I_GetTime()); - I_GetEvent(); + if (Skill == 0) + PlaySound(DIGI_TAUNTAI3, v3df_none, CHAN_VOICE, CHANF_UI); + else if (Skill == 1) + PlaySound(DIGI_NOFEAR, v3df_none, CHAN_VOICE, CHANF_UI); + else if (Skill == 2) + PlaySound(DIGI_WHOWANTSWANG, v3df_none, CHAN_VOICE, CHANF_UI); + else if (Skill == 3) + PlaySound(DIGI_NOPAIN, v3df_none, CHAN_VOICE, CHANF_UI); + + while (soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE)) + { + gi->UpdateSounds(); + soundEngine->UpdateSounds(I_GetTime()); + I_GetEvent(); + } + Net_ClearFifo(); } }