Update rate fluctuation?
-
So we’ve been attempting to debug some issues with varying maneuverability apparently tied to frame rates. Low frame rate (sub-30) makes ships much slower to turn, while very high frame rates (over 90) makes ships faster and also makes them stutter about.
Now, I’m not exactly sure what could be causing this, but one thing I noticed while debugging is that IServer::Update is being called with a varying spacing. In fact, I can get it myself to vary between 15-16 (the expected value) to 31-32 (double that) to even 46-47 and 0.
In windowed mode at 144Hz (framerate varying between 120 and 144), I get 50% of all ticks as 0 spacing and most of the rest at 16 and 15. At 60Hz, 15 and 16 make up well over 90% of all ticks. At 24Hz, it’s all over the place, with 31-32 leading, then 46-47, then 0 and 15-16, each making up between 20-40%.
Now, as far as I know, Freelancer expects this to be called 60 times per second flat. If my measurements are correct, this is most certainly not the case.
I’d rather not limit framerate to 60 at all times (though I will if that’s necessary), but I’d like to know what in the hell could possibly cause the update calls to change in such a manner because of frame rate differences?
EDIT: Some digging indicates that FL correctly uses the performance counter (that’s what the Timing class uses), so the base timer is accurate and reliable enough not to be the cause. This means that the likely source of the problem is the caller for IServer::Update, which appears to be sub_5A89B0 in Freelancer.exe. The logic resembles a standard game loop, but there’s a few things I’m not sure about yet.