replication

This commit is contained in:
GenZmeY 2021-12-09 07:34:12 +03:00
parent 3c2ac15e5b
commit ff23b17c54
8 changed files with 182 additions and 44 deletions

View File

@ -1,6 +1,6 @@
class KFGameInfoHelper extends object;
class KFGameInfoHelper extends Object;
static function UpdateGameSettings(KFGameInfo_Survival KFGI, bool bUsesStats, string GameModeClass)
public static function UpdateGameSettings(KFGameInfo_Survival KFGI, bool bUsesStats, string GameModeClass)
{
local name SessionName;
local KFOnlineGameSettings KFGameSettings;
@ -88,43 +88,47 @@ static function UpdateGameSettings(KFGameInfo_Survival KFGI, bool bUsesStats, st
}
}
static function class<KFPawn_Monster> PickProxyZed(class<KFPawn_Monster> MonsterClass, Controller Killer)
public static function class<KFPawn_Monster> PickProxyZed(class<KFPawn_Monster> MonsterClass, Controller Killer, MskGsMut Mut)
{
local class<KFPawn_Monster> ProxyClass;
ProxyClass = MonsterClass;
`log("[MSK-GS] DBG: Length:"@Mut.MskGsMemberList.Length);
if (Mut.MskGsMemberList.Find(Killer) == INDEX_NONE)
{
`log("[MSK-GS] DBG:"@MonsterClass);
return MonsterClass;
}
switch (MonsterClass)
{
case class'KFPawn_ZedBloat': ProxyClass = class'KFPawnProxy_ZedBloat'; break;
case class'KFPawn_ZedBloatKing': ProxyClass = class'KFPawnProxy_ZedBloatKing'; break;
case class'KFPawn_ZedBloatKing_SantasWorkshop': ProxyClass = class'KFPawnProxy_ZedBloatKing_SantasWorkshop'; break;
case class'KFPawn_ZedBloatKingSubspawn': ProxyClass = class'KFPawnProxy_ZedBloatKingSubspawn'; break;
case class'KFPawn_ZedClot_Alpha': ProxyClass = class'KFPawnProxy_ZedClot_Alpha'; break;
case class'KFPawn_ZedClot_AlphaKing': ProxyClass = class'KFPawnProxy_ZedClot_AlphaKing'; break;
case class'KFPawn_ZedClot_Cyst': ProxyClass = class'KFPawnProxy_ZedClot_Cyst'; break;
case class'KFPawn_ZedClot_Slasher': ProxyClass = class'KFPawnProxy_ZedClot_Slasher'; break;
case class'KFPawn_ZedCrawler': ProxyClass = class'KFPawnProxy_ZedCrawler'; break;
case class'KFPawn_ZedCrawlerKing': ProxyClass = class'KFPawnProxy_ZedCrawlerKing'; break;
case class'KFPawn_ZedDAR': ProxyClass = class'KFPawnProxy_ZedDAR'; break;
case class'KFPawn_ZedDAR_EMP': ProxyClass = class'KFPawnProxy_ZedDAR_EMP'; break;
case class'KFPawn_ZedDAR_Laser': ProxyClass = class'KFPawnProxy_ZedDAR_Laser'; break;
case class'KFPawn_ZedDAR_Rocket': ProxyClass = class'KFPawnProxy_ZedDAR_Rocket'; break;
case class'KFPawn_ZedFleshpound': ProxyClass = class'KFPawnProxy_ZedFleshpound'; break;
case class'KFPawn_ZedFleshpoundKing': ProxyClass = class'KFPawnProxy_ZedFleshpoundKing'; break;
case class'KFPawn_ZedFleshpoundMini': ProxyClass = class'KFPawnProxy_ZedFleshpoundMini'; break;
case class'KFPawn_ZedGorefast': ProxyClass = class'KFPawnProxy_ZedGorefast'; break;
case class'KFPawn_ZedGorefastDualBlade': ProxyClass = class'KFPawnProxy_ZedGorefastDualBlade'; break;
case class'KFPawn_ZedHans': ProxyClass = class'KFPawnProxy_ZedHans'; break;
case class'KFPawn_ZedHusk': ProxyClass = class'KFPawnProxy_ZedHusk'; break;
case class'KFPawn_ZedMatriarch': ProxyClass = class'KFPawnProxy_ZedMatriarch'; break;
case class'KFPawn_ZedPatriarch': ProxyClass = class'KFPawnProxy_ZedPatriarch'; break;
case class'KFPawn_ZedScrake': ProxyClass = class'KFPawnProxy_ZedScrake'; break;
case class'KFPawn_ZedSiren': ProxyClass = class'KFPawnProxy_ZedSiren'; break;
case class'KFPawn_ZedStalker': ProxyClass = class'KFPawnProxy_ZedStalker'; break;
case class'KFPawn_ZedBloat': MonsterClass = class'KFPawnProxy_ZedBloat'; break;
case class'KFPawn_ZedBloatKing': MonsterClass = class'KFPawnProxy_ZedBloatKing'; break;
case class'KFPawn_ZedBloatKing_SantasWorkshop': MonsterClass = class'KFPawnProxy_ZedBloatKing_SantasWorkshop'; break;
case class'KFPawn_ZedBloatKingSubspawn': MonsterClass = class'KFPawnProxy_ZedBloatKingSubspawn'; break;
case class'KFPawn_ZedClot_Alpha': MonsterClass = class'KFPawnProxy_ZedClot_Alpha'; break;
case class'KFPawn_ZedClot_AlphaKing': MonsterClass = class'KFPawnProxy_ZedClot_AlphaKing'; break;
case class'KFPawn_ZedClot_Cyst': MonsterClass = class'KFPawnProxy_ZedClot_Cyst'; break;
case class'KFPawn_ZedClot_Slasher': MonsterClass = class'KFPawnProxy_ZedClot_Slasher'; break;
case class'KFPawn_ZedCrawler': MonsterClass = class'KFPawnProxy_ZedCrawler'; break;
case class'KFPawn_ZedCrawlerKing': MonsterClass = class'KFPawnProxy_ZedCrawlerKing'; break;
case class'KFPawn_ZedDAR': MonsterClass = class'KFPawnProxy_ZedDAR'; break;
case class'KFPawn_ZedDAR_EMP': MonsterClass = class'KFPawnProxy_ZedDAR_EMP'; break;
case class'KFPawn_ZedDAR_Laser': MonsterClass = class'KFPawnProxy_ZedDAR_Laser'; break;
case class'KFPawn_ZedDAR_Rocket': MonsterClass = class'KFPawnProxy_ZedDAR_Rocket'; break;
case class'KFPawn_ZedFleshpound': MonsterClass = class'KFPawnProxy_ZedFleshpound'; break;
case class'KFPawn_ZedFleshpoundKing': MonsterClass = class'KFPawnProxy_ZedFleshpoundKing'; break;
case class'KFPawn_ZedFleshpoundMini': MonsterClass = class'KFPawnProxy_ZedFleshpoundMini'; break;
case class'KFPawn_ZedGorefast': MonsterClass = class'KFPawnProxy_ZedGorefast'; break;
case class'KFPawn_ZedGorefastDualBlade': MonsterClass = class'KFPawnProxy_ZedGorefastDualBlade'; break;
case class'KFPawn_ZedHans': MonsterClass = class'KFPawnProxy_ZedHans'; break;
case class'KFPawn_ZedHusk': MonsterClass = class'KFPawnProxy_ZedHusk'; break;
case class'KFPawn_ZedMatriarch': MonsterClass = class'KFPawnProxy_ZedMatriarch'; break;
case class'KFPawn_ZedPatriarch': MonsterClass = class'KFPawnProxy_ZedPatriarch'; break;
case class'KFPawn_ZedScrake': MonsterClass = class'KFPawnProxy_ZedScrake'; break;
case class'KFPawn_ZedSiren': MonsterClass = class'KFPawnProxy_ZedSiren'; break;
case class'KFPawn_ZedStalker': MonsterClass = class'KFPawnProxy_ZedStalker'; break;
}
return ProxyClass;
`log("[MSK-GS] DBG:"@MonsterClass);
return MonsterClass;
}
defaultproperties

View File

@ -14,6 +14,9 @@ var config int DoshDespawnTime;
var config array<string> KickProtectedList;
var config array<int> PerPlayerMaxMonsters;
var array<MskGsRepInfo> RepClients;
var array<Controller> MskGsMemberList;
function InitMutator(string Options, out string ErrorMessage)
{
local int MaxPlayers, MaxPlayersAllowed;
@ -126,6 +129,12 @@ function Initialize()
VoteCollector.bRandomizeNextMap = bRandomizeNextMap;
VoteCollector.SortPolicy = SortStats;
if (MskGs_Endless(MyKFGI) != None) MskGs_Endless(MyKFGI).Mut = Self;
if (MskGs_Objective(MyKFGI) != None) MskGs_Objective(MyKFGI).Mut = Self;
if (MskGs_Survival(MyKFGI) != None) MskGs_Survival(MyKFGI).Mut = Self;
if (MskGs_VersusSurvival(MyKFGI) != None) MskGs_VersusSurvival(MyKFGI).Mut = Self;
if (MskGs_WeeklySurvival(MyKFGI) != None) MskGs_WeeklySurvival(MyKFGI).Mut = Self;
steamworks = class'GameEngine'.static.GetOnlineSubsystem();
foreach KickProtectedList(Person)
@ -220,20 +229,48 @@ function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> dam
return Super.PreventDeath(Killed, Killer, damageType, HitLocation);
}
function NotifyLogin(Controller NewPlayer)
function NotifyLogin(Controller C)
{
super.NotifyLogin(NewPlayer);
local MskGsRepInfo RepInfo;
if (C == None) return;
`log("[MSK-GS] DBG1: NotifyLogin()"@RepInfo@RepInfo.Mut@RepInfo.C);
RepInfo = Spawn(class'MskGsRepInfo', KFPlayerController(C));
`log("[MSK-GS] DBG2: NotifyLogin()"@RepInfo@RepInfo.Mut@RepInfo.C);
RepInfo.C = C;
RepInfo.Mut = Self;
`log("[MSK-GS] DBG3: NotifyLogin()"@RepInfo@RepInfo.Mut@RepInfo.C);
RepClients.AddItem(RepInfo);
super.NotifyLogin(C);
}
function NotifyLogout(Controller Exiting)
function NotifyLogout(Controller C)
{
local MskGsVoteCollector VoteCollector;
local MskGsRepInfo RepInfo;
if (C == None) return;
VoteCollector = MskGsVoteCollector(MyKFGI.MyKFGRI.VoteCollector);
VoteCollector.NotifyLogout(C);
VoteCollector.NotifyLogout(Exiting);
super.NotifyLogout(Exiting);
MskGsMemberList.RemoveItem(C);
foreach RepClients(RepInfo) // TODO: rework this shit
{
if (RepInfo.C == C)
{
`log("[MSK-GS] DBG: Destroy()");
RepInfo.Destroy();
RepClients.RemoveItem(RepInfo);
return;
}
}
super.NotifyLogout(C);
}
defaultproperties

View File

@ -0,0 +1,83 @@
class MskGsRepInfo extends ReplicationInfo;
// Server vars
var public MskGsMut Mut;
var public Controller C;
// Client vars
var private OnlineSubsystemSteamworks SW;
simulated event PostBeginPlay()
{
`log("[MSK-GS] DBG: PostBeginPlay()");
super.PostBeginPlay();
if (bDeleteMe) return;
if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone)
{
`log("[MSK-GS] DBG: if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone)");
ClientGetOnlineSubsystem();
}
}
private reliable client function ClientGetOnlineSubsystem()
{
`log("[MSK-GS] DBG: ClientGetOnlineSubsystem()");
if (SW == None)
{
`log("[MSK-GS] DBG: 1");
SW = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
}
if (SW == None)
{
`log("[MSK-GS] DBG: 2");
SetTimer(0.1f, false, nameof(ClientGetOnlineSubsystem));
}
else
{
`log("[MSK-GS] DBG: 3");
ClearTimer(nameof(ClientGetOnlineSubsystem));
ClientGetMembership();
}
}
private reliable client function ClientGetMembership()
{
local UniqueNetId GroupID;
`log("[MSK-GS] DBG: ClientGetMembership()");
class'OnlineSubsystem'.Static.StringToUniqueNetId("0x017000000223386E", GroupID);
if (SW.CheckPlayerGroup(GroupID))
{
`log("[MSK-GS] DBG: ClientGetMembership() ServerApplyMembership()");
ServerApplyMembership();
}
}
private simulated reliable server function ServerApplyMembership()
{
`log("[MSK-GS] DBG: ServerApplyMembership() start");
if (Mut == None || C == None)
{
`log("[MSK-GS] DBG: ServerApplyMembership() timer");
SetTimer(1.0f, false, nameof(ServerApplyMembership));
return;
}
`log("[MSK-GS] DBG: ServerApplyMembership()"@Self@Mut@C);
ClearTimer(nameof(ServerApplyMembership));
Mut.MskGsMemberList.AddItem(C);
}
DefaultProperties
{
bAlwaysRelevant = false;
bOnlyRelevantToOwner = true;
Role = ROLE_Authority;
RemoteRole = ROLE_SimulatedProxy;
bSkipActorPropertyReplication = false; // This is needed, otherwise the client-to-server RPC fails
}

View File

@ -2,6 +2,9 @@ class MskGs_Endless extends KFGameInfo_Endless;
var const class<KFGameInfoHelper> KFGIH;
var public MskGsMut Mut;
simulated function ExileServerUsingKickBan()
{
return;
@ -14,7 +17,7 @@ function UpdateGameSettings()
protected function DistributeMoneyAndXP(class<KFPawn_Monster> MonsterClass, const out array<DamageInfo> DamageHistory, Controller Killer)
{
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer), DamageHistory, Killer);
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer, Mut), DamageHistory, Killer);
}
defaultproperties

View File

@ -2,6 +2,9 @@ class MskGs_Objective extends KFGameInfo_Objective;
var const class<KFGameInfoHelper> KFGIH;
var public MskGsMut Mut;
simulated function ExileServerUsingKickBan()
{
return;
@ -14,7 +17,7 @@ function UpdateGameSettings()
protected function DistributeMoneyAndXP(class<KFPawn_Monster> MonsterClass, const out array<DamageInfo> DamageHistory, Controller Killer)
{
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer), DamageHistory, Killer);
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer, Mut), DamageHistory, Killer);
}
defaultproperties

View File

@ -2,6 +2,8 @@ class MskGs_Survival extends KFGameInfo_Survival;
var const class<KFGameInfoHelper> KFGIH;
var public MskGsMut Mut;
simulated function ExileServerUsingKickBan()
{
return;
@ -14,7 +16,7 @@ function UpdateGameSettings()
protected function DistributeMoneyAndXP(class<KFPawn_Monster> MonsterClass, const out array<DamageInfo> DamageHistory, Controller Killer)
{
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer), DamageHistory, Killer);
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer, Mut), DamageHistory, Killer);
}
defaultproperties

View File

@ -2,6 +2,9 @@ class MskGs_VersusSurvival extends KFGameInfo_VersusSurvival;
var const class<KFGameInfoHelper> KFGIH;
var public MskGsMut Mut;
simulated function ExileServerUsingKickBan()
{
return;
@ -14,7 +17,7 @@ function UpdateGameSettings()
protected function DistributeMoneyAndXP(class<KFPawn_Monster> MonsterClass, const out array<DamageInfo> DamageHistory, Controller Killer)
{
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer), DamageHistory, Killer);
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer, Mut), DamageHistory, Killer);
}
defaultproperties

View File

@ -2,6 +2,9 @@ class MskGs_WeeklySurvival extends KFGameInfo_WeeklySurvival;
var const class<KFGameInfoHelper> KFGIH;
var public MskGsMut Mut;
simulated function ExileServerUsingKickBan()
{
return;
@ -14,7 +17,7 @@ function UpdateGameSettings()
protected function DistributeMoneyAndXP(class<KFPawn_Monster> MonsterClass, const out array<DamageInfo> DamageHistory, Controller Killer)
{
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer), DamageHistory, Killer);
Super.DistributeMoneyAndXP(KFGIH.static.PickProxyZed(MonsterClass, Killer, Mut), DamageHistory, Killer);
}
defaultproperties