Fix #56: Fix CommnetNetwork.Update performance#58
Conversation
The throttling logic that was supposed to update it once every 5 seconds was broken
|
For reference, the original logic is : if (!queueRebuild && !commNet.IsDirty)
{
double currentTime = Time.timeSinceLevelLoad;
double activeVesselInterval =
(FlightGlobals.ActiveVessel == null || FlightGlobals.ActiveVessel.packed)
? packedInterval
: unpackedInterval;
if (prevUpdate + activeVesselInterval > currentTime)
{
double focusedVesselInterval = focusedVessel == null ? 0.0 : packedInterval;
if (prevUpdate + focusedVesselInterval > currentTime)
{
graphDirty = true;
return;
}
}
}You patch is entirely bypassing the first two checks ( I think the rest kinda works, although rate-limiting based on real-time instead of in-game time is quite questionable, but I guess that's beyond the point. |
|
I can add those checks back in, but those two fields are never set to true in the stock code. Yeah, I'm guessing the packed vs unpacked distinction is meant for timewarp, but shrug. |
|
Hey, not sure if new commits automatically ping or not. I added in the checks. |
|
I will make the patch disabled by default. Even if the throttling mechanism is originally intended, this patch introduce a breaking change from CommNet usually being in sync with the game loop to it using potentially vastly outdated data. 0.5 RL seconds updates at 100000x warp means essentially garbage results, and while this doesn't matter too much in stock, there are mods relying on CommNet for various stuff. |
|
Thanks! But note the stock code ALSO can do 0.5 second intervals, if focusedVessel is not null. |
The throttling logic that was supposed to update it once every 5 seconds was broken