fix single player mode

This commit is contained in:
GenZmeY 2024-01-08 03:14:41 +03:00
parent 643c721ade
commit 6d7f0552db
Signed by: GenZmeY
GPG Key ID: 424DA4BC3CB2CF39
3 changed files with 44 additions and 12 deletions

View File

@ -230,6 +230,7 @@ private function PostInit()
{ {
if (RepInfo.PendingSync) if (RepInfo.PendingSync)
{ {
RepInfo.PrepareSync(Self, LogLevel, KFGI.KFGFxManagerClass, DLCSkinUpdateRequired.Value, bApplyPatch);
RepInfo.Replicate(WeapDefs); RepInfo.Replicate(WeapDefs);
} }
} }
@ -348,12 +349,11 @@ public function bool CreateRepInfo(Controller C)
if (RepInfo == None) return false; if (RepInfo == None) return false;
RepInfo.PrepareSync(Self, KFPlayerController(C), LogLevel, DLCSkinUpdateRequired.Value, bApplyPatch);
RepInfos.AddItem(RepInfo); RepInfos.AddItem(RepInfo);
if (ReadyToSync) if (ReadyToSync)
{ {
RepInfo.PrepareSync(Self, LogLevel, KFGI.KFGFxManagerClass, DLCSkinUpdateRequired.Value, bApplyPatch);
RepInfo.Replicate(WeapDefs); RepInfo.Replicate(WeapDefs);
} }
else else

View File

@ -137,7 +137,7 @@ public reliable server function CTI_ServerBuyWeapon(int ItemIndex, optional int
if (CurrentCarryBlocks > CurrentCarryBlocks + BlocksRequired) return; if (CurrentCarryBlocks > CurrentCarryBlocks + BlocksRequired) return;
if (!CTI_ProcessWeaponDosh(PurchasedItem)) return; if (!CTI_ProcessWeaponDosh(PurchasedItem)) return;
CTI_AddTransactionItem( PurchasedItem, WeaponUpgrade); CTI_AddTransactionItem(PurchasedItem, WeaponUpgrade);
} }
// final function AddTransactionItem( const out STraderItem ItemToAdd, optional byte WeaponUpgrade ) // final function AddTransactionItem( const out STraderItem ItemToAdd, optional byte WeaponUpgrade )

View File

@ -23,6 +23,8 @@ var public bool PendingSync;
var private CTI CTI; var private CTI CTI;
var private E_LogLevel LogLevel; var private E_LogLevel LogLevel;
var private class<KFGFxMoviePlayer_Manager> FrontEndClass;
var private GameReplicationInfo GRI; var private GameReplicationInfo GRI;
var private KFPlayerController KFPC; var private KFPlayerController KFPC;
var private KFPlayerReplicationInfo KFPRI; var private KFPlayerReplicationInfo KFPRI;
@ -49,7 +51,7 @@ var private bool ClientReady, ServerReady;
replication replication
{ {
if (bNetInitial && Role == ROLE_Authority) if (bNetInitial && Role == ROLE_Authority)
LogLevel, SkinUpdateRequired, PatchRequired; LogLevel, SkinUpdateRequired, PatchRequired, FrontEndClass;
} }
public simulated function bool SafeDestroy() public simulated function bool SafeDestroy()
@ -60,24 +62,50 @@ public simulated function bool SafeDestroy()
} }
public function PrepareSync( public function PrepareSync(
CTI _CTI, KFPlayerController _KFPC, E_LogLevel _LogLevel, CTI _CTI, E_LogLevel _LogLevel,
class<KFGFxMoviePlayer_Manager> _FrontEndClass,
bool _SkinUpdateRequired, bool _PatchRequired) bool _SkinUpdateRequired, bool _PatchRequired)
{ {
`Log_Trace(); `Log_Trace();
CTI = _CTI; CTI = _CTI;
KFPC = _KFPC;
LogLevel = _LogLevel; LogLevel = _LogLevel;
FrontEndClass = _FrontEndClass;
SkinUpdateRequired = _SkinUpdateRequired; SkinUpdateRequired = _SkinUpdateRequired;
PatchRequired = _PatchRequired; PatchRequired = _PatchRequired;
} }
private reliable client function ClientSetFrontEnd()
{
if (FrontEndClass == None || GetKFPRI() == None)
{
`Log_Debug("Wait for frontend");
SetTimer(1.0f, false, nameof(ClientSetFrontEnd));
return;
}
if (KFPC.MyGFxManager != None && KFPC.MyGFxManager.class == FrontEndClass)
{
`Log_Debug("MyGFxManager is ok:" @ String(KFPC.MyGFxManager.class));
return;
}
KFPC.MyGFxManager.CloseMenus(true);
KFPC.MyGFxManager = None;
KFPC.ClientSetFrontEnd(FrontEndClass, KFPRI.bOnlySpectator);
`Log_Debug(String(FrontEndClass) @ "initialized.");
}
public function Replicate(const out Array<class<KFWeaponDefinition> > WeapDefs) public function Replicate(const out Array<class<KFWeaponDefinition> > WeapDefs)
{ {
`Log_Trace(); `Log_Trace();
ServerReady = !PatchRequired; ServerReady = !PatchRequired;
ClientSetFrontEnd();
if (PatchRequired) if (PatchRequired)
{ {
if (GetKFPC() != None) if (GetKFPC() != None)
@ -92,13 +120,14 @@ public function Replicate(const out Array<class<KFWeaponDefinition> > WeapDefs)
RepArray = WeapDefs; RepArray = WeapDefs;
RepData.Size = RepArray.Length; RepData.Size = RepArray.Length;
if (WorldInfo.NetMode == NM_StandAlone) if (WorldInfo.NetMode != NM_StandAlone)
{ {
Progress(RepArray.Length, RepArray.Length);
return;
}
Sync(); Sync();
}
else
{
Finished();
}
} }
private reliable server function Sync() private reliable server function Sync()
@ -179,7 +208,10 @@ private simulated function Finished()
if (KFGRI != None) if (KFGRI != None)
{ {
`Log_Debug("Finished: Trader.static.OverwriteTraderItems"); `Log_Debug("Finished: Trader.static.OverwriteTraderItems");
if (WorldInfo.NetMode != NM_StandAlone)
{
Trader.static.OverwriteTraderItems(KFGRI, RepArray, PatchRequired, LogLevel); Trader.static.OverwriteTraderItems(KFGRI, RepArray, PatchRequired, LogLevel);
}
`Log_Info("Trader items successfully synchronized!"); `Log_Info("Trader items successfully synchronized!");
} }
else else