From edc6d889934d27dfc1949d22b0bed1f8cd5a9867 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Tue, 13 Apr 2021 23:41:57 +0100 Subject: [PATCH] src/AIModel/AIMultiplayer.*: Improve behaviour if simple-time enabled. Moved interpolation code into new method FGAIMultiplayer::FGAIMultiplayerInterpolate(). FGAIMultiplayer::update(): If simple-time is enabled, always use getMPProtocolClockSec() (or /sim/replay/time if replaying) as current time, so that multiple instances of Flightgear all using simple-time will all show user and MP aircraft in the same relative positions. When interpolating, don't special-case single iterator, instead pass the single iterator as both args to FGAIMultiplayerInterpolate(). Fixed removal of outdated frames using mMotionInfo.erase() - previously this was not done if we had done extrapolation, and with interpolation we left one too many frames in place. FGAIMultiplayer::addMotionInfo(): If simple-time is enabled, apply compensation to MP aircraft's .time fields if incoming packets' .time field differs significantly from our local UTC time. This allows simple-time to work with non-simple-time MP aircraft, or with simple-time MP aircraft whose UTC clocks differ from local UTC clock. But without the guarantee of consistent rendering across Flightgear instances. We don't calculate lag when compensating in this way. With these changes, scripts/python/recordreplay.py --test-motion-mp passes (the test sets /sim/replay/simple-time"). --- src/AIModel/AIMultiplayer.cxx | 930 +++++++++++++++++++++------------- src/AIModel/AIMultiplayer.hxx | 84 ++- 2 files changed, 640 insertions(+), 374 deletions(-) diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index f8e7e42a7..4066df05e 100644 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -28,6 +28,7 @@ #include #include +#include #include
#include
#include