diff --git a/CTI/Classes/CTI.uc b/CTI/Classes/CTI.uc index 5becf2a..bb81dce 100644 --- a/CTI/Classes/CTI.uc +++ b/CTI/Classes/CTI.uc @@ -195,7 +195,7 @@ private function PostInit() if (bPreloadContent) { - InitPreload(AddItems); + Preload(AddItems); } ReadyToSync = true; @@ -209,7 +209,7 @@ private function PostInit() } } -private function InitPreload(Array > Content) +private function Preload(Array > Content) { local S_PreloadContent SPC; @@ -236,21 +236,9 @@ private function InitPreload(Array > Content) } } - `Log_Debug("PreloadContent:" @ PreloadContent.Length); -} - -public function StartPreload(class KFWeapDef) -{ - local S_PreloadContent SPC; - foreach PreloadContent(SPC) { - if (SPC.KFWD == KFWeapDef) - { - SPC.KFWA.KFW_StartLoadWeaponContent(); - `Log_Debug("Preload:" @ SPC.KFW); - break; - } + SPC.KFWA.KFW_StartLoadWeaponContent(); } } @@ -285,8 +273,7 @@ public function bool CreateRepLink(Controller C) LogLevel, RemoveItems, AddItems, - CfgRemoveItems.default.bAll, - bPreloadContent); + CfgRemoveItems.default.bAll); RepInfos.AddItem(RepLink); diff --git a/CTI/Classes/CTI_RepInfo.uc b/CTI/Classes/CTI_RepInfo.uc index ea735ab..817a439 100644 --- a/CTI/Classes/CTI_RepInfo.uc +++ b/CTI/Classes/CTI_RepInfo.uc @@ -23,10 +23,12 @@ var private String NotificationLeftText; var private String NotificationRightText; var private int NotificationPercent; +var private int WaitingGRI; + replication { if (bNetInitial && Role == ROLE_Authority) - LogLevel, ReplaceMode, PreloadContent, SyncSize; + LogLevel, ReplaceMode, SyncSize; } public simulated function bool SafeDestroy() @@ -41,8 +43,7 @@ public function PrepareSync( E_LogLevel _LogLevel, Array > _RemoveItems, Array > _AddItems, - bool _ReplaceMode, - bool _PreloadContent) + bool _ReplaceMode) { `Log_Trace(`Location); @@ -51,7 +52,6 @@ public function PrepareSync( RemoveItems = _RemoveItems; AddItems = _AddItems; ReplaceMode = _ReplaceMode; - PreloadContent = _PreloadContent; SyncSize = RemoveItems.Length + AddItems.Length; } @@ -169,6 +169,8 @@ private reliable client function ClientSync(class WeapDef, o NotificationPercent = (float(Recieved) / float(SyncSize)) * 100; } + `Log_Debug("ClientSync:" @ NotificationLeftText @ NotificationRightText); + ServerSync(); } @@ -188,23 +190,31 @@ private simulated reliable client function ClientSyncFinished() `Log_Trace(`Location); - ClearTimer(nameof(KeepNotification)); - if (WorldInfo.GRI == None) { + `Log_Debug("ClientSyncFinished: WorldInfo.GRI == None"); + NotificationHeaderText = "Waiting for GameReplicationInfo..."; + NotificationLeftText = String(++WaitingGRI) $ "s"; SetTimer(1.0f, false, nameof(ClientSyncFinished)); + return; } KFGRI = KFGameReplicationInfo(WorldInfo.GRI); if (KFGRI == None) { `Log_Fatal("Incompatible Replication info:" @ WorldInfo.GRI); + ClearTimer(nameof(KeepNotification)); + UpdateNotification( + "Error: Incompatible Replication info:" @ WorldInfo.GRI, + "", "", 0); SafeDestroy(); return; } Helper.static.ModifyTrader(KFGRI, RemoveItems, AddItems, ReplaceMode); + `Log_Debug("ClientSyncFinished: Helper.static.ModifyTrader"); + ClearTimer(nameof(KeepNotification)); ShowReadyButton(); SafeDestroy(); @@ -218,8 +228,11 @@ public reliable server function ServerSync() if (bPendingDelete || bDeleteMe) return; + `Log_Debug("ServerSync:" @ Recieved @ "/" @ SyncSize); if (SyncSize <= Recieved || WorldInfo.NetMode == NM_StandAlone) { + `Log_Debug("ServerSync: SyncFinished"); + ClientSyncFinished(); if (!CTI.DestroyRepLink(Controller(Owner))) @@ -235,7 +248,6 @@ public reliable server function ServerSync() } else { - if (PreloadContent) CTI.StartPreload(AddItems[Recieved]); ClientSync(AddItems[Recieved++ - RemoveItems.Length], false); } } @@ -252,4 +264,6 @@ defaultproperties NotificationHeaderText = "Sync trader items, please wait..." NotificationPercent = 0 + + WaitingGRI = 0 } diff --git a/PublicationContent/description.txt b/PublicationContent/description.txt index b5e7ba1..457437d 100644 --- a/PublicationContent/description.txt +++ b/PublicationContent/description.txt @@ -1,5 +1,5 @@ [h1]Features[/h1] -- remove and/or add items; +- remove/add items to trader; - can preload weapon models (no lags when someone buys weapons); - unlock DLC weapons; - correct items sorting (by price); diff --git a/README.md b/README.md index 8503796..8e9a2b0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Add/Remove Items in the Trader's Inventory # Features -- remove and/or add items; +- remove/add items to trader; - can preload weapon models (no lags when buying weapons); - unlock DLC weapons; - correct items sorting (by price);