This probably the only *awful* patch in this series!
The right way to solve the problem is to make weapon physics independant
of Draw method and refresh rate. In a perfect world, all Weapon::Draw()
would be const and the same for WeaponProjectile::Draw().
Yea, I know it is not that easy with the grapple (I have already failed
on it), but I do not see why the footbomb is dependant of Drawing or
refresh rate.
Regards,
Matt (gentildemon)
Florian Köberle a écrit :
> 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);
>
_______________________________________________
Wormux-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wormux-dev