diff --git a/CTI/Classes/CTI.uc b/CTI/Classes/CTI.uc index d7501c9..4cd4e61 100644 --- a/CTI/Classes/CTI.uc +++ b/CTI/Classes/CTI.uc @@ -9,9 +9,8 @@ const Helper = class'Helper'; var private config int Version; var private config E_LogLevel LogLevel; -var private config bool bPreloadContent; -var private config bool bForcePreloadContent; var private config bool UnlockDLC; +var private config bool bPreloadContent; var private KFGameInfo KFGI; var private KFGameReplicationInfo KFGRI; @@ -67,7 +66,6 @@ private function PreInit() { LogLevel = LL_Info; bPreloadContent = true; - bForcePreloadContent = false; UnlockDLC = false; SaveConfig(); } @@ -233,8 +231,7 @@ public function bool CreateRepLink(Controller C) RemoveItems, AddItems, CfgRemoveItems.default.bAll, - bPreloadContent, - bForcePreloadContent); + bPreloadContent); RepInfos.AddItem(RepLink); diff --git a/CTI/Classes/CTI_RepInfo.uc b/CTI/Classes/CTI_RepInfo.uc index 93f8158..56842c8 100644 --- a/CTI/Classes/CTI_RepInfo.uc +++ b/CTI/Classes/CTI_RepInfo.uc @@ -10,11 +10,9 @@ var private Array > RemoveItems; var private Array > AddItems; var private bool ReplaceMode; var private bool PreloadContent; -var private bool ForcePreloadContent; var private int Recieved; var private int SyncSize; -var private int Preloaded; var private KFPlayerController KFPC; var private KFPawn KFP; @@ -29,7 +27,7 @@ var private float PreloadWeaponTime; replication { if (bNetInitial && Role == ROLE_Authority) - LogLevel, ReplaceMode, PreloadContent, ForcePreloadContent, SyncSize; + LogLevel, ReplaceMode, PreloadContent, SyncSize; } public simulated function bool SafeDestroy() @@ -45,8 +43,7 @@ public function PrepareSync( Array > _RemoveItems, Array > _AddItems, bool _ReplaceMode, - bool _PreloadContent, - bool _ForcePreloadContent) + bool _PreloadContent) { `Log_Trace(`Location); @@ -56,7 +53,6 @@ public function PrepareSync( AddItems = _AddItems; ReplaceMode = _ReplaceMode; PreloadContent = _PreloadContent; - ForcePreloadContent = _ForcePreloadContent; SyncSize = RemoveItems.Length + AddItems.Length; } @@ -76,46 +72,6 @@ private simulated function KFPlayerController GetKFPC() return KFPC; } -private simulated function KFPawn GetKFP() -{ - local Pawn P; - - `Log_Trace(`Location); - - if (KFP != None) return KFP; - - if (GetKFPC() != None) - { - P = GetKFPC().Pawn; - if (P != None) - { - KFP = KFPawn(P); - } - } - - return KFP; -} - -private simulated function KFInventoryManager GetKFIM() -{ - local InventoryManager IM; - - `Log_Trace(`Location); - - if (KFIM != None) return KFIM; - - if (GetKFP() != None) - { - IM = GetKFP().InvManager; - if (IM != None) - { - KFIM = KFInventoryManager(IM); - } - } - - return KFIM; -} - private simulated function SetPartyInGameWidget() { `Log_Trace(`Location); @@ -223,8 +179,10 @@ private simulated reliable client function ClientSyncFinished() `Log_Trace(`Location); - ClearTimer(nameof(KeepPreloadNotification)); - ClearTimer(nameof(WaitForPreloadWeapon)); + if (WorldInfo.GRI == None) + { + SetTimer(1.0f, false, nameof(ClientSyncFinished)); + } KFGRI = KFGameReplicationInfo(WorldInfo.GRI); if (KFGRI == None) @@ -251,13 +209,11 @@ public reliable server function ServerSync() if (SyncSize <= Recieved || WorldInfo.NetMode == NM_StandAlone) { - if (ForcePreloadContent) + ClientSyncFinished(); + + if (!CTI.DestroyRepLink(Controller(Owner))) { - ServerPreloadWeaponWorkaround(); - } - else - { - ServerSyncFinished(); + SafeDestroy(); } } else @@ -273,145 +229,6 @@ public reliable server function ServerSync() } } -private function ServerSyncFinished() -{ - `Log_Trace(`Location); - - ClientSyncFinished(); - - if (!CTI.DestroyRepLink(Controller(Owner))) - { - SafeDestroy(); - } -} - -private reliable server function ServerPreloadWeaponWorkaround() -{ - local class WC; - - `Log_Trace(`Location); - - RemovePreloadWeapon(); - - if (AddItems.Length <= Preloaded) - { - ServerSyncFinished(); - } - else - { - WC = class (DynamicLoadObject(AddItems[Preloaded++].default.WeaponClassPath, class'Class')); - if (WC != None) - { - PreloadWeaponTime = WorldInfo.TimeSeconds - 1.0f; - PreloadWeaponClass = WC; - ClientPreloadWeapon(WC); - if (!AddPreloadWeapon(WC)) - { - ServerPreloadWeaponWorkaround(); - } - } - } -} - -private reliable server function bool AddPreloadWeapon(class WC) -{ - local Weapon W; - - `Log_Trace(`Location); - - if (GetKFIM() == None || WC == None) return false; - - KFIM.bInfiniteWeight = true; - W = Weapon(KFP.FindInventoryType(WC)); - if (W == None) - { - W = Weapon(KFP.CreateInventory(WC)); - } - - if (W != None) - { - KFIM.SetCurrentWeapon(W); - } - KFIM.bInfiniteWeight = false; - - if (W == None) `Log_Warn("Can't preload" @ WC @ "for some reason (skip)"); - - return (W != None); -} - -private function RemovePreloadWeapon() -{ - local DroppedPickup DP; - local Weapon W; - - `Log_Trace(`Location); - - if (GetKFIM() == None || PreloadWeaponClass == None) return; - - foreach KFIM.InventoryActors(class'Weapon', W) - { - if (W != None && W.class == PreloadWeaponClass) - { - if (W.CanThrow()) - { - KFP.TossInventory(W); - W.Destroy(); - } - } - } - - foreach WorldInfo.DynamicActors(class'DroppedPickup', DP) - { - if (DP.Instigator == KFP && DP.CreationTime > PreloadWeaponTime) - { - DP.Destroy(); - } - } -} - -private reliable client function ClientPreloadWeapon(class WC) -{ - `Log_Trace(`Location); - - Preloaded++; - PreloadWeaponClass = WC; - - if (!IsTimerActive(nameof(KeepPreloadNotification))) - { - SetTimer(0.1f, true, nameof(KeepPreloadNotification)); - } - - SetTimer(0.5f, false, nameof(WaitForPreloadWeapon)); -} - -private simulated function KeepPreloadNotification() -{ - HideReadyButton(); - UpdateNotification( - "Preload weapon models, please wait...", - Repl(String(PreloadWeaponClass), "KFWeap_", ""), - Preloaded @ "/" @ AddItems.Length, - (float(Preloaded) / float(AddItems.Length)) * 100); -} - -private simulated function WaitForPreloadWeapon() -{ - `Log_Trace(`Location); - - KeepPreloadNotification(); - - if (GetKFIM() != None - && KFIM.Instigator.Weapon != None - && KFIM.Instigator.Weapon.Class == PreloadWeaponClass) - { - ServerPreloadWeaponWorkaround(); - } - else - { - SetTimer(0.5f, false, nameof(WaitForPreloadWeapon)); - } -} - defaultproperties { bAlwaysRelevant = false @@ -420,5 +237,4 @@ defaultproperties PendingSync = false Recieved = 0 - Preloaded = 0 } diff --git a/PublicationContent/description.txt b/PublicationContent/description.txt index 0a0a265..b3a5079 100644 --- a/PublicationContent/description.txt +++ b/PublicationContent/description.txt @@ -2,7 +2,6 @@ - remove and/or add items; - unlock DLC weapons; - correct items sorting (by price); -- can preload weapon models (no lags during trader time); - don't have to worry about adding new guns after each Tripware update. [h1]Whitelisted?[/h1] @@ -30,8 +29,6 @@ Config will be created at the first start. Set [b]UnlockDLC=True[/b] to allow all players to buy DLC weapons. -Set [b]bForcePreloadContent=True[/b] to preload weapon models and have no lags during trader time. - Use [b][CTI.RemoveItems][/b] to remove items from the trader inventory. For example: [b]Item=KFGame.KFWeapDef_Mac10[/b] will remove MAC10 from sale. Set [b]bAll=True[/b] if you want to remove all items (can be useful if you want to set the entire sale list in the [b][CTI.AddItems][/b] section yourself). diff --git a/PublicationContent/preview.png b/PublicationContent/preview.png index 7e25b61..95b3d31 100644 Binary files a/PublicationContent/preview.png and b/PublicationContent/preview.png differ diff --git a/README.md b/README.md index 5c67601..54e4b9c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ Add/Remove Items in the Trader's Inventory - remove and/or add items; - unlock DLC weapons; - correct items sorting (by price); -- can preload weapon models (no lags during trader time); - don't have to worry about adding new guns after each Tripware update. # Usage & Setup