This commit is contained in:
GenZmeY 2021-06-13 03:02:17 +03:00
parent 7cbf4833db
commit 82fca1bfbc
5 changed files with 91 additions and 30 deletions

View File

@ -1,2 +1,2 @@
`define bEnableCallstack true `define bEnableCallstack true
`define CurrentVersion 1 `define bEnableDebug true

View File

@ -5,6 +5,8 @@ class ScoreboardExtMut extends KFMutator
`include(Build.uci) `include(Build.uci)
`include(Logger.uci) `include(Logger.uci)
const CurrentVersion = 1;
var config int ConfigVersion; var config int ConfigVersion;
var private OnlineSubsystem Steamworks; var private OnlineSubsystem Steamworks;
@ -119,23 +121,23 @@ private function InitConfig()
class'SteamGroupRankRelations'.static.StaticSaveConfig(); class'SteamGroupRankRelations'.static.StaticSaveConfig();
case 2147483647: case 2147483647:
`info("Config updated to version"@`CurrentVersion); `info("Config updated to version"@CurrentVersion);
break; break;
case `CurrentVersion: case CurrentVersion:
`info("Config is up-to-date"); `info("Config is up-to-date");
break; break;
default: default:
`warning("The config version is higher than the current version (are you using an old mutator?)"); `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("Config version is"@ConfigVersion@"but current version is"@CurrentVersion);
`warning("The config version will be changed to "@`CurrentVersion); `warning("The config version will be changed to "@CurrentVersion);
break; break;
} }
if (ConfigVersion != `CurrentVersion) if (ConfigVersion != CurrentVersion)
{ {
ConfigVersion = `CurrentVersion; ConfigVersion = CurrentVersion;
SaveConfig(); SaveConfig();
} }
} }
@ -200,7 +202,6 @@ private function AddPlayer(Controller C)
RepClientNew.RepInfo.Settings = Settings; RepClientNew.RepInfo.Settings = Settings;
RepClientNew.RepInfo.RankRelation.UID = KFPC.PlayerReplicationInfo.UniqueId; RepClientNew.RepInfo.RankRelation.UID = KFPC.PlayerReplicationInfo.UniqueId;
RepClientNew.RepInfo.RankRelation.RankID = UIDRankRelationsPlayers.Find('UID', RepClientNew.RepInfo.RankRelation.UID); RepClientNew.RepInfo.RankRelation.RankID = UIDRankRelationsPlayers.Find('UID', RepClientNew.RepInfo.RankRelation.UID);
UIDRankRelationsActive.AddItem(RepClientNew.RepInfo.RankRelation); UIDRankRelationsActive.AddItem(RepClientNew.RepInfo.RankRelation);
RepClients.AddItem(RepClientNew); RepClients.AddItem(RepClientNew);

View File

@ -12,6 +12,7 @@ var private OnlineSubsystemSteamworks SW;
// Fitst time replication // Fitst time replication
var public array<UIDRankRelation> SteamGroupRelations; var public array<UIDRankRelation> SteamGroupRelations;
var private array<UIDRankRelation> RankRelations;
var public array<RankInfo> CustomRanks; var public array<RankInfo> CustomRanks;
var public SCESettings Settings; var public SCESettings Settings;
var public UIDRankRelation RankRelation; // Current player rank relation var public UIDRankRelation RankRelation; // Current player rank relation
@ -26,48 +27,95 @@ simulated event PostBeginPlay()
if (bDeleteMe) return; 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(); `callstack();
if (SC == None) if (SC == None)
SC = ScoreboardExtHUD(GetALocalPlayerController().myHUD).Scoreboard; 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) if (SW == None)
SW = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem()); SW = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
if (SC == None || SW == None) if (SW == None)
SetTimer(0.1f, false, nameof(ClientInit)); SetTimer(0.1f, false, nameof(GetOnlineSubsystem));
else else
ClearTimer(nameof(ClientInit)); ClearTimer(nameof(GetOnlineSubsystem));
} }
public function StartFirstTimeReplication() public function StartFirstTimeReplication()
{ {
`callstack(); `callstack();
ClientApplySettings();
SetTimer(0.01f, true, nameof(ReplicateCustomRanks)); SetTimer(0.01f, true, nameof(ReplicateCustomRanks));
SetTimer(0.01f, true, nameof(ReplicateSteamGroupRelations)); SetTimer(0.01f, true, nameof(ReplicateSteamGroupRelations));
} }
private reliable client function ClientSetSettings(SCESettings Set) private reliable client function ClientApplySettings()
{ {
`callstack(); `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() private function ReplicateCustomRanks()
{ {
`callstack(); `callstack();
if (CustomRanksRepProgress < CustomRanks.Length) if (WorldInfo.NetMode != NM_StandAlone && CustomRanksRepProgress < CustomRanks.Length)
{ {
ClientAddCustomRank(CustomRanks[CustomRanksRepProgress]); ClientAddCustomRank(CustomRanks[CustomRanksRepProgress]);
++CustomRanksRepProgress; ++CustomRanksRepProgress;
@ -75,6 +123,7 @@ private function ReplicateCustomRanks()
else else
{ {
ClearTimer(nameof(ReplicateCustomRanks)); ClearTimer(nameof(ReplicateCustomRanks));
ClientApplyCustomRanks();
} }
} }
@ -89,7 +138,7 @@ private function ReplicateSteamGroupRelations()
{ {
`callstack(); `callstack();
if (SteamGroupsRepProgress < SteamGroupRelations.Length) if (WorldInfo.NetMode != NM_StandAlone && SteamGroupsRepProgress < SteamGroupRelations.Length)
{ {
ClientAddSteamGroupRelation(SteamGroupRelations[SteamGroupsRepProgress]); ClientAddSteamGroupRelation(SteamGroupRelations[SteamGroupsRepProgress]);
++SteamGroupsRepProgress; ++SteamGroupsRepProgress;
@ -114,11 +163,11 @@ private reliable client function FindMyRankInSteamGroups()
local UIDRankRelation SteamGroupRel; local UIDRankRelation SteamGroupRel;
`callstack(); `callstack();
foreach SteamGroupRelations(SteamGroupRel) foreach SteamGroupRelations(SteamGroupRel)
if (SW.CheckPlayerGroup(SteamGroupRel.UID)) if (SW.CheckPlayerGroup(SteamGroupRel.UID))
RankRelation.RankID = SteamGroupRel.RankID; RankRelation.RankID = SteamGroupRel.RankID;
if (RankRelation.RankID != INDEX_NONE) if (RankRelation.RankID != INDEX_NONE)
ServerApplyRank(RankRelation.RankID); ServerApplyRank(RankRelation.RankID);
} }
@ -142,7 +191,8 @@ private reliable client function ClientAddRankRelation(UIDRankRelation Rel)
{ {
`callstack(); `callstack();
SC.RankRelations.AddItem(Rel); RankRelations.AddItem(Rel);
ClientApplyRankRelations();
} }
public function RemoveRankRelation(UIDRankRelation Rel) public function RemoveRankRelation(UIDRankRelation Rel)
@ -152,11 +202,12 @@ public function RemoveRankRelation(UIDRankRelation Rel)
ClientRemoveRankRelation(Rel); ClientRemoveRankRelation(Rel);
} }
private unreliable client function ClientRemoveRankRelation(UIDRankRelation Rel) private reliable client function ClientRemoveRankRelation(UIDRankRelation Rel)
{ {
`callstack(); `callstack();
SC.RankRelations.RemoveItem(Rel); RankRelations.RemoveItem(Rel);
ClientApplyRankRelations();
} }
public function UpdateRankRelation(UIDRankRelation Rel) public function UpdateRankRelation(UIDRankRelation Rel)
@ -172,14 +223,23 @@ private reliable client function ClientUpdateRankRelation(UIDRankRelation Rel)
`callstack(); `callstack();
Index = SC.RankRelations.Find('UID', Rel.UID); Index = RankRelations.Find('UID', Rel.UID);
if (Index != INDEX_NONE) if (Index != INDEX_NONE)
SC.RankRelations[Index] = Rel; RankRelations[Index] = Rel;
ClientApplyRankRelations();
} }
defaultproperties 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; CustomRanksRepProgress = 0;
SteamGroupsRepProgress = 0; SteamGroupsRepProgress = 0;
} }

View File

@ -13,7 +13,7 @@ public static function SCESettingsPlayer DefaultSettings()
{ {
local SCESettingsPlayer Settings; local SCESettingsPlayer Settings;
`callstack_static("abc"); `callstack_static("DefaultSettings");
return Settings; return Settings;
} }
@ -22,7 +22,7 @@ public static function SCESettingsPlayer Settings()
{ {
local SCESettingsPlayer Settings; local SCESettingsPlayer Settings;
`callstack_static("abc"); `callstack_static("Settings");
Settings.Rank = default.Rank; Settings.Rank = default.Rank;
Settings.TextColor = default.TextColor; Settings.TextColor = default.TextColor;
@ -33,7 +33,7 @@ public static function SCESettingsPlayer Settings()
public static function WriteSettings(SCESettingsPlayer Settings) public static function WriteSettings(SCESettingsPlayer Settings)
{ {
`callstack_static("abc"); `callstack_static("WriteSettings");
default.Rank = Settings.Rank; default.Rank = Settings.Rank;
default.TextColor = Settings.TextColor; default.TextColor = Settings.TextColor;

View File

@ -4,6 +4,6 @@
`define warning(text) `scelog("[WARNING]"@`text, true) `define warning(text) `scelog("[WARNING]"@`text, true)
`define error(text) `scelog("[ERROR]"@`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() `scelog("[CALLSTACK]"@`Location@"ROLE="$ROLE, `bEnableCallstack)
`define callstack_static(text) `scelog("[CALLSTACK]"@`text, `bEnableCallstack) `define callstack_static(text) `scelog("[CALLSTACK]"@`text, `bEnableCallstack)