Fix a desync during runtime join (GH-58)

This is a workaround for a more complex engine-side issue. See #1953
install-platforms
Lukas Werling 2017-11-05 13:24:47 +01:00
parent fb87db1579
commit c0047bdc53
1 changed files with 6 additions and 2 deletions

View File

@ -26,8 +26,12 @@ public func IsHUDAdapter()
private func GetHUDController()
{
var plr = GetOwner();
if (GetPlayerType(plr) != C4PT_User) return nil;
// During runtime join, plr isn't a valid player in the joining client yet
// when this function is called from OnSynchronized(). This code previously
// checked player validity before returning a cached HUD object which would
// cause a desync.
if (HUDcontroller) return HUDcontroller;
if (GetPlayerType(plr) != C4PT_User) return nil;
var controllerDef = Library_HUDController->GetGUIControllerID();
HUDcontroller = FindObject(Find_ID(controllerDef), Find_Owner(plr));
if (!HUDcontroller)
@ -231,4 +235,4 @@ public func ControlContents()
if (HUDcontroller)
HUDcontroller->~ScheduleUpdateInventory();
return _inherited(...);
}
}