2022-07-05 13:09:48 +00:00
|
|
|
class CTI_RepInfo extends ReplicationInfo;
|
|
|
|
|
2022-08-24 15:29:25 +00:00
|
|
|
const Trader = class'Trader';
|
|
|
|
const LocalMessage = class'CTI_LocalMessage';
|
2022-07-05 13:09:48 +00:00
|
|
|
|
|
|
|
var public bool PendingSync;
|
|
|
|
|
|
|
|
var private CTI CTI;
|
|
|
|
var private E_LogLevel LogLevel;
|
|
|
|
var private Array<class<KFWeaponDefinition> > RemoveItems;
|
|
|
|
var private Array<class<KFWeaponDefinition> > AddItems;
|
|
|
|
var private bool ReplaceMode;
|
|
|
|
var private bool PreloadContent;
|
|
|
|
|
|
|
|
var private int Recieved;
|
|
|
|
var private int SyncSize;
|
2022-07-08 03:03:30 +00:00
|
|
|
|
|
|
|
var private KFPlayerController KFPC;
|
2022-07-05 13:09:48 +00:00
|
|
|
var private KFGFxWidget_PartyInGame PartyInGameWidget;
|
|
|
|
var private GFxObject Notification;
|
|
|
|
|
2022-07-10 02:49:38 +00:00
|
|
|
var private String NotificationHeaderText;
|
|
|
|
var private String NotificationLeftText;
|
|
|
|
var private String NotificationRightText;
|
|
|
|
var private int NotificationPercent;
|
2022-07-08 03:03:30 +00:00
|
|
|
|
2022-07-11 00:54:08 +00:00
|
|
|
var private int WaitingGRI;
|
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
replication
|
|
|
|
{
|
|
|
|
if (bNetInitial && Role == ROLE_Authority)
|
2022-07-11 00:54:08 +00:00
|
|
|
LogLevel, ReplaceMode, SyncSize;
|
2022-07-05 13:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public simulated function bool SafeDestroy()
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-11 12:56:21 +00:00
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
return (bPendingDelete || bDeleteMe || Destroy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function PrepareSync(
|
|
|
|
CTI _CTI,
|
|
|
|
E_LogLevel _LogLevel,
|
|
|
|
Array<class<KFWeaponDefinition> > _RemoveItems,
|
|
|
|
Array<class<KFWeaponDefinition> > _AddItems,
|
2022-07-11 00:54:08 +00:00
|
|
|
bool _ReplaceMode)
|
2022-07-05 13:09:48 +00:00
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-08 03:03:30 +00:00
|
|
|
|
|
|
|
CTI = _CTI;
|
2022-07-05 13:09:48 +00:00
|
|
|
LogLevel = _LogLevel;
|
|
|
|
RemoveItems = _RemoveItems;
|
|
|
|
AddItems = _AddItems;
|
|
|
|
ReplaceMode = _ReplaceMode;
|
|
|
|
SyncSize = RemoveItems.Length + AddItems.Length;
|
|
|
|
}
|
|
|
|
|
2022-07-08 03:03:30 +00:00
|
|
|
private simulated function KFPlayerController GetKFPC()
|
2022-07-05 13:09:48 +00:00
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-08 03:03:30 +00:00
|
|
|
|
|
|
|
if (KFPC != None) return KFPC;
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-08 03:03:30 +00:00
|
|
|
KFPC = KFPlayerController(Owner);
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-08 03:03:30 +00:00
|
|
|
if (KFPC == None && ROLE < ROLE_Authority)
|
2022-07-05 13:09:48 +00:00
|
|
|
{
|
2022-07-08 03:03:30 +00:00
|
|
|
KFPC = KFPlayerController(GetALocalPlayerController());
|
2022-07-05 13:09:48 +00:00
|
|
|
}
|
|
|
|
|
2022-07-08 03:03:30 +00:00
|
|
|
return KFPC;
|
2022-07-05 13:09:48 +00:00
|
|
|
}
|
|
|
|
|
2022-07-08 03:03:30 +00:00
|
|
|
private simulated function SetPartyInGameWidget()
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-08 03:03:30 +00:00
|
|
|
if (GetKFPC() == None) return;
|
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
if (KFPC.MyGFxManager == None) return;
|
|
|
|
if (KFPC.MyGFxManager.PartyWidget == None) return;
|
|
|
|
|
|
|
|
PartyInGameWidget = KFGFxWidget_PartyInGame(KFPC.MyGFxManager.PartyWidget);
|
|
|
|
Notification = PartyInGameWidget.Notification;
|
|
|
|
}
|
|
|
|
|
|
|
|
private simulated function bool CheckPartyInGameWidget()
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-08 03:03:30 +00:00
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
if (PartyInGameWidget == None)
|
|
|
|
{
|
|
|
|
SetPartyInGameWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (PartyInGameWidget != None);
|
|
|
|
}
|
|
|
|
|
2022-07-10 02:49:38 +00:00
|
|
|
private simulated function HideReadyButton()
|
2022-07-05 13:09:48 +00:00
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-08 03:03:30 +00:00
|
|
|
|
2022-07-06 19:53:45 +00:00
|
|
|
if (CheckPartyInGameWidget())
|
|
|
|
{
|
|
|
|
PartyInGameWidget.SetReadyButtonVisibility(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private simulated function ShowReadyButton()
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-08 03:03:30 +00:00
|
|
|
|
2022-07-06 19:53:45 +00:00
|
|
|
if (CheckPartyInGameWidget())
|
|
|
|
{
|
|
|
|
Notification.SetVisible(false);
|
|
|
|
PartyInGameWidget.SetReadyButtonVisibility(true);
|
|
|
|
PartyInGameWidget.UpdateReadyButtonText();
|
|
|
|
PartyInGameWidget.UpdateReadyButtonVisibility();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-24 15:29:25 +00:00
|
|
|
private simulated function UpdateNotification(String Title, String Left, String Right, int Percent)
|
2022-07-06 19:53:45 +00:00
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-08 03:03:30 +00:00
|
|
|
|
2022-07-06 19:53:45 +00:00
|
|
|
if (CheckPartyInGameWidget() && Notification != None)
|
2022-07-05 13:09:48 +00:00
|
|
|
{
|
|
|
|
Notification.SetString("itemName", Title);
|
|
|
|
Notification.SetFloat("percent", Percent);
|
|
|
|
Notification.SetInt("queue", 0);
|
2022-08-24 15:29:25 +00:00
|
|
|
Notification.SetString("downLoading", Left);
|
|
|
|
Notification.SetString("remaining", Right);
|
2022-07-05 13:09:48 +00:00
|
|
|
Notification.SetObject("notificationInfo", Notification);
|
|
|
|
Notification.SetVisible(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private reliable client function ClientSync(class<KFWeaponDefinition> WeapDef, optional bool Remove = false)
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-11 12:56:21 +00:00
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
if (WeapDef == None)
|
|
|
|
{
|
|
|
|
`Log_Fatal("WeapDef is:" @ WeapDef);
|
2022-07-11 12:56:21 +00:00
|
|
|
Cleanup();
|
|
|
|
ConsoleCommand("Disconnect");
|
2022-07-05 13:09:48 +00:00
|
|
|
SafeDestroy();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-10 02:49:38 +00:00
|
|
|
if (!IsTimerActive(nameof(KeepNotification)))
|
|
|
|
{
|
|
|
|
SetTimer(0.1f, true, nameof(KeepNotification));
|
|
|
|
}
|
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
if (Remove)
|
|
|
|
{
|
|
|
|
RemoveItems.AddItem(WeapDef);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AddItems.AddItem(WeapDef);
|
|
|
|
}
|
|
|
|
|
|
|
|
Recieved = RemoveItems.Length + AddItems.Length;
|
|
|
|
|
2022-08-24 15:29:25 +00:00
|
|
|
NotificationHeaderText = (Remove ? "-" : "+") @ WeapDef.static.GetItemName();
|
|
|
|
NotificationLeftText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_SyncItems);
|
|
|
|
NotificationRightText = Recieved @ "/" @ SyncSize;
|
2022-07-10 02:49:38 +00:00
|
|
|
if (SyncSize != 0)
|
|
|
|
{
|
|
|
|
NotificationPercent = (float(Recieved) / float(SyncSize)) * 100;
|
|
|
|
}
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Debug("ClientSync:" @ (Remove ? "-" : "+") @ String(WeapDef) @ NotificationRightText);
|
2022-07-11 00:54:08 +00:00
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
ServerSync();
|
|
|
|
}
|
|
|
|
|
2022-07-10 02:49:38 +00:00
|
|
|
private simulated function KeepNotification()
|
|
|
|
{
|
|
|
|
HideReadyButton();
|
|
|
|
UpdateNotification(
|
|
|
|
NotificationHeaderText,
|
|
|
|
NotificationLeftText,
|
|
|
|
NotificationRightText,
|
|
|
|
NotificationPercent);
|
|
|
|
}
|
|
|
|
|
2022-07-08 03:03:30 +00:00
|
|
|
private simulated reliable client function ClientSyncFinished()
|
2022-07-05 13:09:48 +00:00
|
|
|
{
|
|
|
|
local KFGameReplicationInfo KFGRI;
|
2022-07-11 12:56:21 +00:00
|
|
|
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
|
|
|
|
|
|
|
NotificationLeftText = "";
|
|
|
|
NotificationRightText = "";
|
|
|
|
NotificationPercent = 0;
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-08 18:18:58 +00:00
|
|
|
if (WorldInfo.GRI == None)
|
|
|
|
{
|
2022-07-11 12:56:21 +00:00
|
|
|
`Log_Debug("ClientSyncFinished: Waiting GRI");
|
2022-08-24 15:29:25 +00:00
|
|
|
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_WaitingGRI);
|
|
|
|
NotificationLeftText = String(++WaitingGRI) $ LocalMessage.static.GetLocalizedString(LogLevel, CTI_SecondsShort);
|
2022-07-18 17:27:51 +00:00
|
|
|
NotificationRightText = "";
|
2022-07-08 18:18:58 +00:00
|
|
|
SetTimer(1.0f, false, nameof(ClientSyncFinished));
|
2022-07-11 00:54:08 +00:00
|
|
|
return;
|
2022-07-08 18:18:58 +00:00
|
|
|
}
|
2022-07-05 13:09:48 +00:00
|
|
|
|
|
|
|
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
|
|
|
|
if (KFGRI == None)
|
|
|
|
{
|
2022-07-11 12:56:21 +00:00
|
|
|
`Log_Fatal("Incompatible Replication info:" @ String(WorldInfo.GRI));
|
2022-07-11 00:54:08 +00:00
|
|
|
ClearTimer(nameof(KeepNotification));
|
|
|
|
UpdateNotification(
|
2022-08-24 15:29:25 +00:00
|
|
|
LocalMessage.static.GetLocalizedString(LogLevel, CTI_IncompatibleGRI) @ String(WorldInfo.GRI),
|
|
|
|
LocalMessage.static.GetLocalizedString(LogLevel, CTI_Disconnect), "", 0);
|
2022-07-11 12:56:21 +00:00
|
|
|
Cleanup();
|
|
|
|
ConsoleCommand("Disconnect");
|
2022-07-05 13:09:48 +00:00
|
|
|
SafeDestroy();
|
|
|
|
return;
|
|
|
|
}
|
2022-07-18 17:27:51 +00:00
|
|
|
|
2022-08-24 15:29:25 +00:00
|
|
|
NotificationHeaderText = LocalMessage.static.GetLocalizedString(LogLevel, CTI_SyncFinished);
|
2022-07-18 17:27:51 +00:00
|
|
|
NotificationLeftText = "";
|
|
|
|
NotificationRightText = "";
|
|
|
|
NotificationPercent = 0;
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-18 17:27:51 +00:00
|
|
|
Trader.static.ModifyTrader(KFGRI, RemoveItems, AddItems, ReplaceMode, LogLevel);
|
|
|
|
`Log_Debug("ClientSyncFinished: Trader.static.ModifyTrader");
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-11 00:54:08 +00:00
|
|
|
ClearTimer(nameof(KeepNotification));
|
2022-07-06 19:53:45 +00:00
|
|
|
ShowReadyButton();
|
2022-07-05 13:09:48 +00:00
|
|
|
|
2022-07-11 12:56:21 +00:00
|
|
|
Cleanup();
|
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
SafeDestroy();
|
|
|
|
}
|
|
|
|
|
2022-07-11 12:56:21 +00:00
|
|
|
private reliable server function Cleanup()
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-11 12:56:21 +00:00
|
|
|
|
|
|
|
`Log_Debug("Cleanup");
|
2022-07-14 06:55:58 +00:00
|
|
|
if (!CTI.DestroyRepInfo(Controller(Owner)))
|
2022-07-11 12:56:21 +00:00
|
|
|
{
|
|
|
|
`Log_Debug("Cleanup (forced)");
|
|
|
|
SafeDestroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-05 13:09:48 +00:00
|
|
|
public reliable server function ServerSync()
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Trace();
|
2022-07-05 13:09:48 +00:00
|
|
|
|
|
|
|
PendingSync = false;
|
|
|
|
|
|
|
|
if (bPendingDelete || bDeleteMe) return;
|
|
|
|
|
|
|
|
if (SyncSize <= Recieved || WorldInfo.NetMode == NM_StandAlone)
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Debug("ServerSync: Finished");
|
2022-07-08 18:18:58 +00:00
|
|
|
ClientSyncFinished();
|
2022-07-05 13:09:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Recieved < RemoveItems.Length)
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Debug("ServerSync[-]:" @ (Recieved + 1) @ "/" @ SyncSize @ RemoveItems[Recieved]);
|
2022-07-05 13:09:48 +00:00
|
|
|
ClientSync(RemoveItems[Recieved++], true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-18 17:27:51 +00:00
|
|
|
`Log_Debug("ServerSync[+]:" @ (Recieved + 1) @ "/" @ SyncSize @ AddItems[Recieved - RemoveItems.Length]);
|
2022-07-05 13:09:48 +00:00
|
|
|
ClientSync(AddItems[Recieved++ - RemoveItems.Length], false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
bAlwaysRelevant = false
|
|
|
|
bOnlyRelevantToOwner = true
|
|
|
|
bSkipActorPropertyReplication = false
|
|
|
|
|
|
|
|
PendingSync = false
|
|
|
|
Recieved = 0
|
2022-07-10 02:49:38 +00:00
|
|
|
|
|
|
|
NotificationPercent = 0
|
2022-07-11 00:54:08 +00:00
|
|
|
WaitingGRI = 0
|
2022-07-05 13:09:48 +00:00
|
|
|
}
|