wip
This commit is contained in:
parent
85c2fb65bb
commit
cf6b9cf6c8
@ -22,7 +22,7 @@ var private KFOnlineGameSettings KFOGS;
|
||||
|
||||
var private OnlineSubsystemSteamworks OSS;
|
||||
|
||||
var private Array<YAS_RepInfo> RepInfos;
|
||||
var private Array<YAS_OwnerRepInfo> RepInfos;
|
||||
|
||||
var private Array<CachedRankRelation> PlayerRelations;
|
||||
var private Array<CachedRankRelation> GroupRelations;
|
||||
@ -282,7 +282,7 @@ private function UpdateTimer()
|
||||
|
||||
public function NotifyLogin(Controller C)
|
||||
{
|
||||
local YAS_RepInfo RepInfo;
|
||||
local YAS_OwnerRepInfo RepInfo;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
@ -293,24 +293,16 @@ public function NotifyLogin(Controller C)
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyCurrentRankRelations(RepInfo);
|
||||
InitRank(RepInfo);
|
||||
}
|
||||
|
||||
public function NotifyLogout(Controller C)
|
||||
{
|
||||
local YAS_RepInfo RepInfo;
|
||||
local YAS_OwnerRepInfo RepInfo;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
RepInfo = FindRepInfo(C);
|
||||
if (RepInfo == None)
|
||||
{
|
||||
`Log_Error("Can't find repinfo for:" @ C);
|
||||
return;
|
||||
}
|
||||
|
||||
BroadcastRemoveRankRelation(RepInfo.ActiveRankRelation, C);
|
||||
|
||||
if (!DestroyRepInfo(RepInfo))
|
||||
{
|
||||
@ -318,30 +310,33 @@ public function NotifyLogout(Controller C)
|
||||
}
|
||||
}
|
||||
|
||||
public function YAS_RepInfo CreateRepInfo(Controller C)
|
||||
public function YAS_OwnerRepInfo CreateRepInfo(Controller C)
|
||||
{
|
||||
local YAS_RepInfo RepInfo;
|
||||
local YAS_OwnerRepInfo OwnerRepInfo;
|
||||
local YAS_RankRepInfo RankRepInfo;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
RepInfo = Spawn(class'YAS_RepInfo', C);
|
||||
OwnerRepInfo = Spawn(class'YAS_OwnerRepInfo', C);
|
||||
RankRepInfo = Spawn(class'YAS_RankRepInfo', C);
|
||||
|
||||
if (RepInfo != None)
|
||||
if (OwnerRepInfo != None && RankRepInfo != None)
|
||||
{
|
||||
RepInfos.AddItem(RepInfo);
|
||||
RepInfos.AddItem(OwnerRepInfo);
|
||||
|
||||
RepInfo.YAS = Self;
|
||||
RepInfo.LogLevel = LogLevel;
|
||||
RepInfo.RankPlayer = CfgRanks.default.Player;
|
||||
RepInfo.RankAdmin = CfgRanks.default.Admin;
|
||||
OwnerRepInfo.RankRepInfo = RankRepInfo;
|
||||
OwnerRepInfo.YAS = Self;
|
||||
OwnerRepInfo.LogLevel = LogLevel;
|
||||
OwnerRepInfo.RankPlayer = CfgRanks.default.Player;
|
||||
OwnerRepInfo.RankAdmin = CfgRanks.default.Admin;
|
||||
}
|
||||
|
||||
return RepInfo;
|
||||
return OwnerRepInfo;
|
||||
}
|
||||
|
||||
private function YAS_RepInfo FindRepInfo(Controller C)
|
||||
private function YAS_OwnerRepInfo FindRepInfo(Controller C)
|
||||
{
|
||||
local YAS_RepInfo RepInfo;
|
||||
local YAS_OwnerRepInfo RepInfo;
|
||||
|
||||
if (C == None) return None;
|
||||
|
||||
@ -356,30 +351,25 @@ private function YAS_RepInfo FindRepInfo(Controller C)
|
||||
return None;
|
||||
}
|
||||
|
||||
public function bool DestroyRepInfo(YAS_RepInfo RepInfo)
|
||||
public function bool DestroyRepInfo(YAS_OwnerRepInfo RepInfo)
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (RepInfo == None) return false;
|
||||
|
||||
RepInfos.RemoveItem(RepInfo);
|
||||
RepInfo.RankRepInfo.SafeDestroy();
|
||||
RepInfo.SafeDestroy();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function ApplyCurrentRankRelations(YAS_RepInfo RepInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function InitRank(YAS_RepInfo RepInfo)
|
||||
private function InitRank(YAS_OwnerRepInfo RepInfo)
|
||||
{
|
||||
local CachedRankRelation Rel;
|
||||
local String JoinedGroupIDs;
|
||||
local PlayerReplicationInfo PRI;
|
||||
local KFPlayerController KFPC;
|
||||
local bool HasPlayerRank;
|
||||
local Array<String> StringGroupIDs;
|
||||
|
||||
`Log_Trace();
|
||||
@ -391,22 +381,16 @@ private function InitRank(YAS_RepInfo RepInfo)
|
||||
PRI = KFPC.PlayerReplicationInfo;
|
||||
if (PRI == None) return;
|
||||
|
||||
HasPlayerRank = false;
|
||||
foreach PlayerRelations(Rel)
|
||||
{
|
||||
if (Rel.UID.Uid == PRI.UniqueID.Uid)
|
||||
{
|
||||
HasPlayerRank = true;
|
||||
RepInfo.ActiveRankRelation = Rel;
|
||||
RepInfo.RankRepInfo.Rank = Rel.Rank;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (HasPlayerRank)
|
||||
{
|
||||
BroadcastAddRankRelation(RepInfo.ActiveRankRelation);
|
||||
}
|
||||
else if (!KFPC.bIsEosPlayer)
|
||||
if (RepInfo.RankRepInfo.Rank.RankID <= 0 && !KFPC.bIsEosPlayer)
|
||||
{
|
||||
foreach GroupRelations(Rel)
|
||||
{
|
||||
@ -417,49 +401,13 @@ private function InitRank(YAS_RepInfo RepInfo)
|
||||
}
|
||||
}
|
||||
|
||||
public function ApplyMembership(UniqueNetId GroupUID, UniqueNetId PlayerUID)
|
||||
public function Rank RankByGroupID(UniqueNetId GroupUID)
|
||||
{
|
||||
local CachedRankRelation RR;
|
||||
local int Index;
|
||||
local CachedRankRelation Rel;
|
||||
|
||||
`Log_Trace();
|
||||
foreach GroupRelations(Rel) if (Rel.UID == GroupUID) break;
|
||||
|
||||
Index = GroupRelations.Find('UID', GroupUID);
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
RR.UID = PlayerUID;
|
||||
RR.Rank = GroupRelations[Index].Rank;
|
||||
BroadcastAddRankRelation(RR);
|
||||
}
|
||||
else
|
||||
{
|
||||
`Log_Error("Can't find related GroupID rank");
|
||||
}
|
||||
}
|
||||
|
||||
public function BroadcastAddRankRelation(CachedRankRelation RR)
|
||||
{
|
||||
local YAS_RepInfo RepInfo;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
foreach RepInfos(RepInfo)
|
||||
{
|
||||
RepInfo.AddRankRelation(RR);
|
||||
}
|
||||
}
|
||||
|
||||
public function BroadcastRemoveRankRelation(CachedRankRelation RR, optional Controller Except)
|
||||
{
|
||||
local YAS_RepInfo RepInfo;
|
||||
|
||||
foreach RepInfos(RepInfo)
|
||||
{
|
||||
if (RepInfo.Owner != Except)
|
||||
{
|
||||
RepInfo.RemoveRankRelation(RR);
|
||||
}
|
||||
}
|
||||
return Rel.Rank;
|
||||
}
|
||||
|
||||
DefaultProperties
|
||||
|
@ -1,4 +1,4 @@
|
||||
class YAS_RepInfo extends ReplicationInfo;
|
||||
class YAS_OwnerRepInfo extends ReplicationInfo;
|
||||
|
||||
var public YAS YAS;
|
||||
|
||||
@ -7,15 +7,13 @@ var public repnotify SystemRank RankPlayer, RankAdmin;
|
||||
var public repnotify String DynamicServerName;
|
||||
var public repnotify bool UsesStats, Custom, PasswordRequired;
|
||||
|
||||
var public CachedRankRelation ActiveRankRelation;
|
||||
var public YAS_RankRepInfo RankRepInfo;
|
||||
|
||||
var private KFPlayerController KFPC;
|
||||
var private YAS_ScoreBoard SC;
|
||||
var private OnlineSubsystemSteamworks OSS;
|
||||
|
||||
var private Array<UniqueNetID> PendingGroupIDs;
|
||||
var private Array<CachedRankRelation> PendingAddRankRelations;
|
||||
var private Array<CachedRankRelation> PendingRemoveRankRelations;
|
||||
|
||||
const CheckGroupTimer = 0.2f;
|
||||
const MaxRetries = 3;
|
||||
@ -30,6 +28,13 @@ replication
|
||||
DynamicServerName, UsesStats, Custom, PasswordRequired;
|
||||
}
|
||||
|
||||
public simulated function bool SafeDestroy()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
return (bPendingDelete || bDeleteMe || Destroy());
|
||||
}
|
||||
|
||||
public simulated event ReplicatedEvent(name VarName)
|
||||
{
|
||||
`Log_Trace();
|
||||
@ -70,13 +75,6 @@ public simulated event ReplicatedEvent(name VarName)
|
||||
}
|
||||
}
|
||||
|
||||
public simulated function bool SafeDestroy()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
return (bPendingDelete || bDeleteMe || Destroy());
|
||||
}
|
||||
|
||||
public simulated event PreBeginPlay()
|
||||
{
|
||||
`Log_Trace();
|
||||
@ -100,42 +98,6 @@ public simulated event PostBeginPlay()
|
||||
Super.PostBeginPlay();
|
||||
}
|
||||
|
||||
public reliable client function AddRankRelation(CachedRankRelation RR)
|
||||
{
|
||||
local int Index;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
if (SC == None)
|
||||
{
|
||||
PendingAddRankRelations.AddItem(RR);
|
||||
return;
|
||||
}
|
||||
|
||||
Index = SC.RankRelations.Find('UID', RR.UID);
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
SC.RankRelations[Index] = RR;
|
||||
}
|
||||
else
|
||||
{
|
||||
SC.RankRelations.AddItem(RR);
|
||||
}
|
||||
}
|
||||
|
||||
public reliable client function RemoveRankRelation(CachedRankRelation RR)
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (SC == None)
|
||||
{
|
||||
PendingRemoveRankRelations.AddItem(RR);
|
||||
return;
|
||||
}
|
||||
|
||||
SC.RankRelations.RemoveItem(RR);
|
||||
}
|
||||
|
||||
public reliable client function CheckGroupRanks(String JoinedGroupIDs)
|
||||
{
|
||||
local Array<String> StringGroupIDs;
|
||||
@ -191,15 +153,19 @@ private simulated function CheckGroupsCycle()
|
||||
|
||||
private reliable server function ServerApplyMembership(UniqueNetId GroupUID)
|
||||
{
|
||||
local Rank Rank;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
if (GetKFPC() != None && KFPC.PlayerReplicationInfo != None)
|
||||
Rank = YAS.RankByGroupID(GroupUID);
|
||||
if (Rank.RankID > 0)
|
||||
{
|
||||
YAS.ApplyMembership(GroupUID, KFPC.PlayerReplicationInfo.UniqueID);
|
||||
RankRepInfo.Rank = Rank;
|
||||
}
|
||||
else
|
||||
{
|
||||
`Log_Error("Can't apply membership for:" @ Self @ GetKFPC());
|
||||
`Log_Warn("Cant find related rank for groupUID");
|
||||
RankRepInfo.Rank = class'YAS_Types'.static.FromSystemRank(RankPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,8 +220,6 @@ private reliable client function GetScoreboard()
|
||||
|
||||
private simulated function InitScoreboard()
|
||||
{
|
||||
local CachedRankRelation RR;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
if (SC == None) return;
|
||||
@ -267,18 +231,6 @@ private simulated function InitScoreboard()
|
||||
SC.UsesStats = UsesStats;
|
||||
SC.Custom = Custom;
|
||||
SC.PasswordRequired = PasswordRequired;
|
||||
|
||||
foreach PendingRemoveRankRelations(RR)
|
||||
{
|
||||
RemoveRankRelation(RR);
|
||||
}
|
||||
PendingRemoveRankRelations.Length = 0;
|
||||
|
||||
foreach PendingAddRankRelations(RR)
|
||||
{
|
||||
AddRankRelation(RR);
|
||||
}
|
||||
PendingAddRankRelations.Length = 0;
|
||||
}
|
||||
|
||||
defaultproperties
|
42
YAS/Classes/YAS_RankRepInfo.uc
Normal file
42
YAS/Classes/YAS_RankRepInfo.uc
Normal file
@ -0,0 +1,42 @@
|
||||
class YAS_RankRepInfo extends ReplicationInfo;
|
||||
|
||||
var public UniqueNetID UID;
|
||||
var public Rank Rank;
|
||||
|
||||
replication
|
||||
{
|
||||
if (bNetInitial)
|
||||
UID;
|
||||
|
||||
if (bNetDirty)
|
||||
Rank;
|
||||
}
|
||||
|
||||
public simulated function bool SafeDestroy()
|
||||
{
|
||||
return (bPendingDelete || bDeleteMe || Destroy());
|
||||
}
|
||||
|
||||
public simulated event PreBeginPlay()
|
||||
{
|
||||
if (bPendingDelete || bDeleteMe) return;
|
||||
|
||||
Super.PreBeginPlay();
|
||||
|
||||
if (Role == ROLE_Authority || WorldInfo.NetMode == NM_StandAlone)
|
||||
{
|
||||
if (Controller(Owner) != None && Controller(Owner).PlayerReplicationInfo != None)
|
||||
{
|
||||
UID = Controller(Owner).PlayerReplicationInfo.UniqueID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
Role = ROLE_Authority
|
||||
RemoteRole = ROLE_SimulatedProxy
|
||||
|
||||
bAlwaysRelevant = true
|
||||
bSkipActorPropertyReplication = false
|
||||
}
|
@ -27,52 +27,71 @@ var localized String Players;
|
||||
var localized String Spectators;
|
||||
|
||||
// Cache
|
||||
var public Array<YAS_RankRepInfo> RepInfos;
|
||||
|
||||
var public YAS_Settings Settings;
|
||||
var public String DynamicServerName;
|
||||
var public bool UsesStats, Custom, PasswordRequired;
|
||||
|
||||
var public SystemRank RankPlayer;
|
||||
var public SystemRank RankAdmin;
|
||||
var public Array<CachedRankRelation> RankRelations;
|
||||
|
||||
function Rank PlayerRank(KFPlayerReplicationInfo KFPRI)
|
||||
{
|
||||
local CachedRankRelation RankRelation;
|
||||
local YAS_RankRepInfo RepInfo;
|
||||
local Rank Rank;
|
||||
local bool NeedClean, FoundRepInfo;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
Rank = FromSystemRank(RankPlayer);
|
||||
foreach RankRelations(RankRelation)
|
||||
Rank = class'YAS_Types'.static.FromSystemRank(RankPlayer);
|
||||
|
||||
NeedClean = false;
|
||||
FoundRepInfo = false;
|
||||
|
||||
foreach RepInfos(RepInfo)
|
||||
{
|
||||
if (RankRelation.UID.Uid == KFPRI.UniqueId.Uid)
|
||||
if (RepInfo == None)
|
||||
{
|
||||
Rank = RankRelation.Rank;
|
||||
NeedClean = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RepInfo.UID.Uid == KFPRI.UniqueId.Uid)
|
||||
{
|
||||
Rank = RepInfo.Rank;
|
||||
FoundRepInfo = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!FoundRepInfo)
|
||||
{
|
||||
foreach KFPRI.DynamicActors(class'YAS_RankRepInfo', RepInfo)
|
||||
{
|
||||
if (RepInfo.UID.Uid == KFPRI.UniqueId.Uid)
|
||||
{
|
||||
Rank = RepInfo.Rank;
|
||||
FoundRepInfo = true;
|
||||
RepInfos.AddItem(RepInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NeedClean)
|
||||
{
|
||||
RepInfos.RemoveItem(None);
|
||||
}
|
||||
|
||||
if (KFPRI.bAdmin && !Rank.OverrideAdmin)
|
||||
{
|
||||
Rank = FromSystemRank(RankAdmin);
|
||||
Rank = class'YAS_Types'.static.FromSystemRank(RankAdmin);
|
||||
}
|
||||
|
||||
return Rank;
|
||||
}
|
||||
|
||||
function Rank FromSystemRank(SystemRank SysRank)
|
||||
{
|
||||
local Rank Rank;
|
||||
|
||||
Rank.RankID = 0;
|
||||
Rank.RankName = SysRank.RankName;
|
||||
Rank.RankColor = SysRank.RankColor;
|
||||
Rank.PlayerColor = SysRank.PlayerColor;
|
||||
Rank.OverrideAdmin = false;
|
||||
|
||||
return Rank;
|
||||
}
|
||||
|
||||
function float MinPerkBoxWidth(float FontScalar)
|
||||
{
|
||||
local Array<String> PerkNames;
|
||||
|
@ -341,3 +341,20 @@ struct YAS_Settings
|
||||
var YAS_SettingsHealth Health;
|
||||
};
|
||||
|
||||
public static function Rank FromSystemRank(SystemRank SysRank)
|
||||
{
|
||||
local Rank RV;
|
||||
|
||||
RV.RankID = 0;
|
||||
RV.RankName = SysRank.RankName;
|
||||
RV.RankColor = SysRank.RankColor;
|
||||
RV.PlayerColor = SysRank.PlayerColor;
|
||||
RV.OverrideAdmin = false;
|
||||
|
||||
return RV;
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user