WIP
This commit is contained in:
parent
7cbf4833db
commit
82fca1bfbc
@ -1,2 +1,2 @@
|
||||
`define bEnableCallstack true
|
||||
`define CurrentVersion 1
|
||||
`define bEnableDebug true
|
@ -5,6 +5,8 @@ class ScoreboardExtMut extends KFMutator
|
||||
`include(Build.uci)
|
||||
`include(Logger.uci)
|
||||
|
||||
const CurrentVersion = 1;
|
||||
|
||||
var config int ConfigVersion;
|
||||
|
||||
var private OnlineSubsystem Steamworks;
|
||||
@ -119,23 +121,23 @@ private function InitConfig()
|
||||
class'SteamGroupRankRelations'.static.StaticSaveConfig();
|
||||
|
||||
case 2147483647:
|
||||
`info("Config updated to version"@`CurrentVersion);
|
||||
`info("Config updated to version"@CurrentVersion);
|
||||
break;
|
||||
|
||||
case `CurrentVersion:
|
||||
case CurrentVersion:
|
||||
`info("Config is up-to-date");
|
||||
break;
|
||||
|
||||
default:
|
||||
`warning("The config version is higher than the current version (are you using an old mutator?)");
|
||||
`warning("Config version is"@ConfigVersion@"but current version is"@`CurrentVersion);
|
||||
`warning("The config version will be changed to "@`CurrentVersion);
|
||||
`warning("Config version is"@ConfigVersion@"but current version is"@CurrentVersion);
|
||||
`warning("The config version will be changed to "@CurrentVersion);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ConfigVersion != `CurrentVersion)
|
||||
if (ConfigVersion != CurrentVersion)
|
||||
{
|
||||
ConfigVersion = `CurrentVersion;
|
||||
ConfigVersion = CurrentVersion;
|
||||
SaveConfig();
|
||||
}
|
||||
}
|
||||
@ -200,7 +202,6 @@ private function AddPlayer(Controller C)
|
||||
RepClientNew.RepInfo.Settings = Settings;
|
||||
RepClientNew.RepInfo.RankRelation.UID = KFPC.PlayerReplicationInfo.UniqueId;
|
||||
RepClientNew.RepInfo.RankRelation.RankID = UIDRankRelationsPlayers.Find('UID', RepClientNew.RepInfo.RankRelation.UID);
|
||||
|
||||
UIDRankRelationsActive.AddItem(RepClientNew.RepInfo.RankRelation);
|
||||
|
||||
RepClients.AddItem(RepClientNew);
|
||||
|
@ -12,6 +12,7 @@ var private OnlineSubsystemSteamworks SW;
|
||||
|
||||
// Fitst time replication
|
||||
var public array<UIDRankRelation> SteamGroupRelations;
|
||||
var private array<UIDRankRelation> RankRelations;
|
||||
var public array<RankInfo> CustomRanks;
|
||||
var public SCESettings Settings;
|
||||
var public UIDRankRelation RankRelation; // Current player rank relation
|
||||
@ -26,48 +27,95 @@ simulated event PostBeginPlay()
|
||||
|
||||
if (bDeleteMe) return;
|
||||
|
||||
if (Role < ROLE_Authority)
|
||||
if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone)
|
||||
{
|
||||
ClientInit();
|
||||
GetScoreboard();
|
||||
GetOnlineSubsystem();
|
||||
}
|
||||
}
|
||||
|
||||
private reliable client function ClientInit()
|
||||
private reliable client function GetScoreboard()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
if (SC == None)
|
||||
SC = ScoreboardExtHUD(GetALocalPlayerController().myHUD).Scoreboard;
|
||||
|
||||
if (SC == None)
|
||||
SetTimer(0.1f, false, nameof(GetScoreboard));
|
||||
else
|
||||
ClearTimer(nameof(GetScoreboard));
|
||||
}
|
||||
|
||||
private reliable client function GetOnlineSubsystem()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
if (SW == None)
|
||||
SW = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
|
||||
|
||||
if (SC == None || SW == None)
|
||||
SetTimer(0.1f, false, nameof(ClientInit));
|
||||
if (SW == None)
|
||||
SetTimer(0.1f, false, nameof(GetOnlineSubsystem));
|
||||
else
|
||||
ClearTimer(nameof(ClientInit));
|
||||
ClearTimer(nameof(GetOnlineSubsystem));
|
||||
}
|
||||
|
||||
public function StartFirstTimeReplication()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
ClientApplySettings();
|
||||
SetTimer(0.01f, true, nameof(ReplicateCustomRanks));
|
||||
SetTimer(0.01f, true, nameof(ReplicateSteamGroupRelations));
|
||||
}
|
||||
|
||||
private reliable client function ClientSetSettings(SCESettings Set)
|
||||
private reliable client function ClientApplySettings()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
SC.Settings = Set;
|
||||
if (SC == None)
|
||||
{
|
||||
SetTimer(0.1f, false, nameof(ClientApplySettings));
|
||||
return;
|
||||
}
|
||||
|
||||
ClearTimer(nameof(ClientApplySettings));
|
||||
SC.Settings = Settings;
|
||||
}
|
||||
|
||||
private reliable client function ClientApplyCustomRanks()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
if (SC == None)
|
||||
{
|
||||
SetTimer(0.1f, false, nameof(ClientApplyCustomRanks));
|
||||
return;
|
||||
}
|
||||
|
||||
ClearTimer(nameof(ClientApplyCustomRanks));
|
||||
SC.CustomRanks = CustomRanks;
|
||||
}
|
||||
|
||||
private reliable client function ClientApplyRankRelations()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
if (SC == None)
|
||||
{
|
||||
SetTimer(0.1f, false, nameof(ClientApplyRankRelations));
|
||||
return;
|
||||
}
|
||||
|
||||
ClearTimer(nameof(ClientApplyRankRelations));
|
||||
SC.RankRelations = RankRelations;
|
||||
}
|
||||
|
||||
private function ReplicateCustomRanks()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
if (CustomRanksRepProgress < CustomRanks.Length)
|
||||
if (WorldInfo.NetMode != NM_StandAlone && CustomRanksRepProgress < CustomRanks.Length)
|
||||
{
|
||||
ClientAddCustomRank(CustomRanks[CustomRanksRepProgress]);
|
||||
++CustomRanksRepProgress;
|
||||
@ -75,6 +123,7 @@ private function ReplicateCustomRanks()
|
||||
else
|
||||
{
|
||||
ClearTimer(nameof(ReplicateCustomRanks));
|
||||
ClientApplyCustomRanks();
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +138,7 @@ private function ReplicateSteamGroupRelations()
|
||||
{
|
||||
`callstack();
|
||||
|
||||
if (SteamGroupsRepProgress < SteamGroupRelations.Length)
|
||||
if (WorldInfo.NetMode != NM_StandAlone && SteamGroupsRepProgress < SteamGroupRelations.Length)
|
||||
{
|
||||
ClientAddSteamGroupRelation(SteamGroupRelations[SteamGroupsRepProgress]);
|
||||
++SteamGroupsRepProgress;
|
||||
@ -142,7 +191,8 @@ private reliable client function ClientAddRankRelation(UIDRankRelation Rel)
|
||||
{
|
||||
`callstack();
|
||||
|
||||
SC.RankRelations.AddItem(Rel);
|
||||
RankRelations.AddItem(Rel);
|
||||
ClientApplyRankRelations();
|
||||
}
|
||||
|
||||
public function RemoveRankRelation(UIDRankRelation Rel)
|
||||
@ -152,11 +202,12 @@ public function RemoveRankRelation(UIDRankRelation Rel)
|
||||
ClientRemoveRankRelation(Rel);
|
||||
}
|
||||
|
||||
private unreliable client function ClientRemoveRankRelation(UIDRankRelation Rel)
|
||||
private reliable client function ClientRemoveRankRelation(UIDRankRelation Rel)
|
||||
{
|
||||
`callstack();
|
||||
|
||||
SC.RankRelations.RemoveItem(Rel);
|
||||
RankRelations.RemoveItem(Rel);
|
||||
ClientApplyRankRelations();
|
||||
}
|
||||
|
||||
public function UpdateRankRelation(UIDRankRelation Rel)
|
||||
@ -172,14 +223,23 @@ private reliable client function ClientUpdateRankRelation(UIDRankRelation Rel)
|
||||
|
||||
`callstack();
|
||||
|
||||
Index = SC.RankRelations.Find('UID', Rel.UID);
|
||||
Index = RankRelations.Find('UID', Rel.UID);
|
||||
|
||||
if (Index != INDEX_NONE)
|
||||
SC.RankRelations[Index] = Rel;
|
||||
RankRelations[Index] = Rel;
|
||||
|
||||
ClientApplyRankRelations();
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
bAlwaysRelevant = false;
|
||||
bOnlyRelevantToOwner = true;
|
||||
Role = ROLE_Authority;
|
||||
RemoteRole = ROLE_SimulatedProxy;
|
||||
// This is needed, otherwise the client-to-server RPC fails
|
||||
bSkipActorPropertyReplication = false;
|
||||
|
||||
CustomRanksRepProgress = 0;
|
||||
SteamGroupsRepProgress = 0;
|
||||
}
|
@ -13,7 +13,7 @@ public static function SCESettingsPlayer DefaultSettings()
|
||||
{
|
||||
local SCESettingsPlayer Settings;
|
||||
|
||||
`callstack_static("abc");
|
||||
`callstack_static("DefaultSettings");
|
||||
|
||||
return Settings;
|
||||
}
|
||||
@ -22,7 +22,7 @@ public static function SCESettingsPlayer Settings()
|
||||
{
|
||||
local SCESettingsPlayer Settings;
|
||||
|
||||
`callstack_static("abc");
|
||||
`callstack_static("Settings");
|
||||
|
||||
Settings.Rank = default.Rank;
|
||||
Settings.TextColor = default.TextColor;
|
||||
@ -33,7 +33,7 @@ public static function SCESettingsPlayer Settings()
|
||||
|
||||
public static function WriteSettings(SCESettingsPlayer Settings)
|
||||
{
|
||||
`callstack_static("abc");
|
||||
`callstack_static("WriteSettings");
|
||||
|
||||
default.Rank = Settings.Rank;
|
||||
default.TextColor = Settings.TextColor;
|
||||
|
@ -4,6 +4,6 @@
|
||||
`define warning(text) `scelog("[WARNING]"@`text, true)
|
||||
`define error(text) `scelog("[ERROR]"@`text, true)
|
||||
|
||||
`define debug(text, cond) `scelog("[DEBUG]"@`text, true)
|
||||
`define debug(text) `scelog("[DEBUG]"@`text, `bEnableDebug)
|
||||
`define callstack() `scelog("[CALLSTACK]"@`Location@"ROLE="$ROLE, `bEnableCallstack)
|
||||
`define callstack_static(text) `scelog("[CALLSTACK]"@`text, `bEnableCallstack)
|
Loading…
Reference in New Issue
Block a user