Games could get out of sync at footbomb and grapple usage. It looks like these weapons require that all network participants draw after the same physic frames.
A better physics engine may fix the issues with these weapons and make this workaround superfluous. --- src/game/game.cpp | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 16c5ebf..b8a25b4 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -531,24 +531,29 @@ void Game::MainLoop() Action a(Action::ACTION_GAME_CALCULATE_FRAME); Network::GetInstance()->SendActionToAll(a); - // try to adjust to max Frame by seconds + bool draw = false; #ifndef USE_VALGRIND - if (time_of_next_frame < Time::GetInstance()->ReadRealTime()) { + if (Network::GetInstance()->IsLocal()) { + // try to adjust to max Frame by seconds + draw = time_of_next_frame < Time::GetInstance()->ReadRealTime(); // Only display if the physic engine isn't late - if (time_of_next_phy_frame > Time::GetInstance()->ReadRealTime()) - { -#endif - StatStart("Game:Draw()"); - CallDraw(); - // How many frame by seconds ? - fps->Refresh(); - StatStop("Game:Draw()"); - time_of_next_frame += AppWormux::GetInstance()->video->GetMaxDelay(); -#ifndef USE_VALGRIND - } + draw = draw && time_of_next_phy_frame > Time::GetInstance()->ReadRealTime(); + } else { + // A bug causes the players to get out of sync if they don't draw a the same time. + // This is a simple workaroud which let all players draw every 100 game milliseconds. + draw = (Time::GetInstance()->Read() % 100 == 0); } #endif + if (draw) { + StatStart("Game:Draw()"); + CallDraw(); + // How many frame by seconds ? + fps->Refresh(); + StatStop("Game:Draw()"); + time_of_next_frame += AppWormux::GetInstance()->video->GetMaxDelay(); + } + delay = time_of_next_phy_frame - Time::GetInstance()->ReadRealTime(); if (delay >= 0) SDL_Delay(delay); -- 1.6.0.4 _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev