fix rank replication

This commit is contained in:
GenZmeY 2021-06-13 04:57:20 +03:00
parent 82fca1bfbc
commit 5f4e2fec5d
4 changed files with 36 additions and 29 deletions

View File

@ -334,8 +334,9 @@ function DrawPlayerEntry( Canvas C, int Index, float YOffset, float Height, floa
KFPRI = KFPRIArray[Index];
HasRank = false;
PlayerInfoIndex = RankRelations.Find('UID', KFPRI.UniqueId);
if (PlayerInfoIndex != INDEX_NONE )
if (PlayerInfoIndex != INDEX_NONE && RankRelations[PlayerInfoIndex].RankID != INDEX_NONE)
{
PlayerRankIndex = CustomRanks.Find('ID', RankRelations[PlayerInfoIndex].RankID);
if (PlayerRankIndex != INDEX_NONE)

View File

@ -202,23 +202,27 @@ 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);
foreach UIDRankRelationsActive(Relation) // For this player
foreach UIDRankRelationsActive(Relation)
RepClientNew.RepInfo.AddRankRelation(Relation);
RepClientNew.RepInfo.StartFirstTimeReplication();
foreach RepClients(RepClient) // For other players
RepClient.RepInfo.AddRankRelation(Relation);
if (RepClientNew.RepInfo.RankRelation.RankID != INDEX_NONE)
{
UIDRankRelationsActive.AddItem(RepClientNew.RepInfo.RankRelation);
foreach RepClients(RepClient)
RepClient.RepInfo.AddRankRelation(RepClientNew.RepInfo.RankRelation);
}
}
private function RemovePlayer(Controller C)
{
local KFPlayerController KFPC;
local int Index;
local int Index, i;
local UniqueNetId UID;
`callstack();
@ -226,8 +230,12 @@ private function RemovePlayer(Controller C)
if (KFPC == None)
return;
// UID = KFPC.PlayerReplicationInfo.UniqueId;
// Remove Rank Relation here
UID = KFPC.PlayerReplicationInfo.UniqueId;
Index = UIDRankRelationsActive.Find('UID', UID);
if (Index != INDEX_NONE)
for (i = 0; i < UIDRankRelationsActive.Length; ++i)
if (Index != i)
RepClients[i].RepInfo.RemoveRankRelation(UIDRankRelationsActive[Index]);
Index = RepClients.Find('KFPC', KFPC);
if (Index == INDEX_NONE)
@ -239,20 +247,6 @@ private function RemovePlayer(Controller C)
RepClients.Remove(Index, 1);
}
/*
private function RemoveRankRelationByUID(UniqueNetId UID)
{
local int Index;
Index = UIDRankRelationsActive.Find('UID', UID);
if (Index != INDEX_NONE)
{
Relation = UIDRankRelationsActive[Index];
for (i = 0; i < UIDRankRelationsActive.Length; ++i)
RepClients[Index].RepInfo.RemoveRankRelation(Relation);
}
}
*/
public function UpdatePlayerRank(UIDRankRelation Rel)
{
local SClient RepClient;
@ -261,9 +255,10 @@ public function UpdatePlayerRank(UIDRankRelation Rel)
`callstack();
Index = UIDRankRelationsActive.Find('UID', Rel.UID);
if (Index != INDEX_NONE)
UIDRankRelationsActive[Index] = Rel;
else
UIDRankRelationsActive.AddItem(Rel);
foreach RepClients(RepClient)
RepClient.RepInfo.UpdateRankRelation(Rel);

View File

@ -227,6 +227,8 @@ private reliable client function ClientUpdateRankRelation(UIDRankRelation Rel)
if (Index != INDEX_NONE)
RankRelations[Index] = Rel;
else
RankRelations.AddItem(Rel);
ClientApplyRankRelations();
}
@ -237,8 +239,7 @@ defaultproperties
bOnlyRelevantToOwner = true;
Role = ROLE_Authority;
RemoteRole = ROLE_SimulatedProxy;
// This is needed, otherwise the client-to-server RPC fails
bSkipActorPropertyReplication = false;
bSkipActorPropertyReplication = false; // This is needed, otherwise the client-to-server RPC fails
CustomRanksRepProgress = 0;
SteamGroupsRepProgress = 0;

View File

@ -55,12 +55,22 @@ struct RankRelation
{
var string ObjectID;
var int RankID;
StructDefaultProperties
{
RankID=-999
}
};
struct UIDRankRelation
{
var UniqueNetId UID;
var int RankID;
StructDefaultProperties
{
RankID=-999
}
};
struct SCESettingsAdmin