Permalink
Browse files

git-svn-id: https://pdinklag.de/svn/titanrpg@37 c0513002-0cab-42c9-a8…

…ae-037f75ac7604
  • Loading branch information...
1 parent b962407 commit 5900a4442cf4196708012fb8e04f312b72e313bc pdinklag committed Apr 11, 2011
View
@@ -7,7 +7,7 @@ var array<HealingBeamEffect> HealEmitters;
replication
{
- reliable if(Role == ROLE_Authority)
+ reliable if(Role == ROLE_Authority && !bNetSyncComplete)
HealInterval, HealRadius;
}
@@ -39,6 +39,7 @@ simulated event PreBeginPlay()
MonsterTypesRepl.StringArray[i] = MonsterTypes[i].DisplayName;
}
MonsterTypesRepl.Replicate();
+ FinalSyncState++;
}
}
@@ -49,7 +50,7 @@ simulated event PostNetReceive()
Super.PostNetReceive();
- if(Role < ROLE_Authority && MonsterTypesRepl != None)
+ if(ShouldReceive() && MonsterTypesRepl != None)
{
MonsterTypes.Length = MonsterTypesRepl.ObjectArray.Length;
for(i = 0; i < MonsterTypes.Length; i++)
@@ -63,6 +64,7 @@ simulated event PostNetReceive()
MonsterTypesRepl.SetOwner(Owner);
MonsterTypesRepl.ServerDestroy();
+ ClientSyncState++;
}
}
@@ -88,6 +90,7 @@ function ModifyPawn(Pawn Other)
Artifact = Other.Spawn(class'ArtifactMonsterSummon');
if(Artifact != None)
{
+ Artifact.bCanBeTossed = false;
Artifact.MonsterTypes.Length = 0;
for(i = 0; i < MonsterTypes.Length; i++)
{
@@ -42,6 +42,7 @@ simulated event PreBeginPlay()
TurretTypesRepl.FloatArray[i] = TurretTypes[i].DrawScale;
}
TurretTypesRepl.Replicate();
+ FinalSyncState++;
}
}
@@ -52,7 +53,7 @@ simulated event PostNetReceive()
Super.PostNetReceive();
- if(Role < ROLE_Authority && TurretTypesRepl != None)
+ if(ShouldReceive() && TurretTypesRepl != None)
{
TurretTypes.Length = TurretTypesRepl.Length;
for(i = 0; i < TurretTypes.Length; i++)
@@ -67,6 +68,7 @@ simulated event PostNetReceive()
TurretTypesRepl.SetOwner(Owner);
TurretTypesRepl.ServerDestroy();
+ ClientSyncState++;
}
}
@@ -23,6 +23,7 @@ simulated event PreBeginPlay()
LevelCapRepl.IntArray[i] = LevelCap[i];
LevelCapRepl.Replicate();
+ FinalSyncState++;
}
}
@@ -32,14 +33,15 @@ simulated event PostNetReceive()
Super.PostNetReceive();
- if(Role < ROLE_Authority && LevelCapRepl != None)
+ if(ShouldReceive() && LevelCapRepl != None)
{
LevelCap.Length = LevelCapRepl.IntArray.Length;
for(i = 0; i < LevelCap.Length; i++)
LevelCap[i] = LevelCapRepl.IntArray[i];
LevelCapRepl.SetOwner(Owner);
LevelCapRepl.ServerDestroy();
+ ClientSyncState++;
}
}
@@ -4,7 +4,7 @@ var config int RepairLinkLevel;
replication
{
- reliable if(Role == ROLE_Authority)
+ reliable if(Role == ROLE_Authority && !bNetSyncComplete)
RepairLinkLevel;
}
@@ -33,6 +33,7 @@ simulated event PreBeginPlay()
WeaponsRepl.IntArray[i] = Weapons[i].Level;
}
WeaponsRepl.Replicate();
+ FinalSyncState++;
}
}
@@ -43,7 +44,7 @@ simulated event PostNetReceive()
Super.PostNetReceive();
- if(Role < ROLE_Authority && WeaponsRepl != None)
+ if(ShouldReceive() && WeaponsRepl != None)
{
Weapons.Length = WeaponsRepl.Length;
for(i = 0; i < Weapons.Length; i++)
@@ -55,6 +56,7 @@ simulated event PostNetReceive()
WeaponsRepl.SetOwner(Owner);
WeaponsRepl.ServerDestroy();
+ ClientSyncState++;
}
}
View
@@ -7,7 +7,7 @@ var int KillCount; //Kill count in current spawn
replication
{
- reliable if(Role == ROLE_Authority)
+ reliable if(Role == ROLE_Authority && !bNetSyncComplete)
BaseDelay;
reliable if(Role == ROLE_Authority && bNetDirty)
@@ -6,7 +6,7 @@ var localized string MaxBonusText;
replication
{
- reliable if(Role == ROLE_Authority)
+ reliable if(Role == ROLE_Authority && !bNetSyncComplete)
MaxHealthBonus;
}
View
@@ -50,18 +50,31 @@ var int AbilityLevel;
var bool bClientReceived;
+var int ClientSyncCounter;
+var int FinalSyncState, ClientSyncState;
+var bool bNetSyncComplete;
+
var ReplicatedArray RequiredRepl, ForbiddenRepl, ItemsRepl, LevelCostRepl;
replication
{
reliable if(Role == ROLE_Authority && bNetInitial)
- RPRI, AbilityLevel, Index, BuyOrderIndex, bAllowed,
+ RPRI, AbilityLevel, Index, BuyOrderIndex, bAllowed, FinalSyncState,
RequiredRepl, ForbiddenRepl, ItemsRepl, LevelCostRepl;
- reliable if(Role == ROLE_Authority)
+ reliable if(Role == ROLE_Authority && !bNetSyncComplete)
StartingCost, CostAddPerLevel, MaxLevel, bUseLevelCost,
RequiredLevel,
BonusPerLevel, bIsStat;
+
+ reliable if(Role < ROLE_Authority)
+ ServerSyncComplete;
+}
+
+function ServerSyncComplete()
+{
+ bNetSyncComplete = true;
+ bNetNotify = false;
}
function bool ShouldReplicateInfo()
@@ -85,6 +98,8 @@ simulated event PreBeginPlay()
Super.PreBeginPlay();
+ FinalSyncState = 1; //initial sync
+
if(ShouldReplicateInfo())
{
//Required
@@ -98,6 +113,7 @@ simulated event PreBeginPlay()
RequiredRepl.IntArray[i] = RequiredAbilities[i].Level;
}
RequiredRepl.Replicate();
+ FinalSyncState++;
}
//Forbidden
@@ -111,6 +127,7 @@ simulated event PreBeginPlay()
ForbiddenRepl.IntArray[i] = ForbiddenAbilities[i].Level;
}
ForbiddenRepl.Replicate();
+ FinalSyncState++;
}
//Items
@@ -124,6 +141,7 @@ simulated event PreBeginPlay()
ItemsRepl.IntArray[i] = GrantItem[i].Level;
}
ItemsRepl.Replicate();
+ FinalSyncState++;
}
//LevelCost
@@ -135,22 +153,28 @@ simulated event PreBeginPlay()
LevelCostRepl.IntArray[i] = LevelCost[i];
LevelCostRepl.Replicate();
+ FinalSyncState++;
}
}
}
+simulated function bool ShouldReceive()
+{
+ return Role < ROLE_Authority && !bNetSyncComplete;
+}
+
simulated event PostNetReceive()
{
local AbilityStruct A;
local GrantItemStruct Grant;
local int i;
- if(Role < ROLE_Authority)
+ if(ShouldReceive())
{
if(RPRI != None && !bClientReceived)
{
- RPRI.ReceiveAbility(Self);
bClientReceived = true;
+ ClientSyncState++;
}
//Required
@@ -165,6 +189,7 @@ simulated event PostNetReceive()
}
RequiredRepl.SetOwner(Owner);
RequiredRepl.ServerDestroy();
+ ClientSyncState++;
}
//Forbidden
@@ -179,6 +204,7 @@ simulated event PostNetReceive()
}
ForbiddenRepl.SetOwner(Owner);
ForbiddenRepl.ServerDestroy();
+ ClientSyncState++;
}
//Items
@@ -193,6 +219,7 @@ simulated event PostNetReceive()
}
ItemsRepl.SetOwner(Owner);
ItemsRepl.ServerDestroy();
+ ClientSyncState++;
}
//LevelCost
@@ -204,6 +231,29 @@ simulated event PostNetReceive()
LevelCostRepl.SetOwner(Owner);
LevelCostRepl.ServerDestroy();
+ ClientSyncState++;
+ }
+
+ ClientSyncCounter++;
+
+ if(ClientSyncState >= FinalSyncState && !bNetSyncComplete)
+ {
+ RPRI.ReceiveAbility(Self);
+ ServerSyncComplete();
+ bNetSyncComplete = true;
+ }
+ else if(ClientSyncCounter > 20)
+ {
+ /*
+ in case something goes wrong, make sure the ability gets marked as received anyway,
+ so the menu becomes available.
+
+ Should never happen.
+ */
+ Log(Self @ "Failed to complete sync after" @ ClientSyncCounter @ "net receptions!", 'TitanRPG');
+ RPRI.ReceiveAbility(Self);
+ ServerSyncComplete();
+ bNetSyncComplete = true;
}
}
}
@@ -260,6 +310,15 @@ simulated function bool Buy(optional int Amount)
return true;
}
+//Get the ability's name
+simulated function string GetName()
+{
+ if(bIsStat)
+ return StatName;
+ else
+ return AbilityName;
+}
+
/*
Automatically generates a description text for this ability.
Includes the Description string, items granted at certain levels, requirements, forbidden abilities, max level and
@@ -312,7 +371,7 @@ simulated function string DescriptionText()
for(x = 0; x < RequiredAbilities.Length && RequiredAbilities[x].AbilityClass != None; x++)
{
i = list.Length;
- list[i] = RequiredAbilities[x].AbilityClass.default.AbilityName;
+ list[i] = RPRI.GetAbility(RequiredAbilities[x].AbilityClass).GetName();
if(RequiredAbilities[x].Level > 1)
list[i] @= string(RequiredAbilities[x].Level);
@@ -339,7 +398,7 @@ simulated function string DescriptionText()
for(x = 0; x < ForbiddenAbilities.Length && ForbiddenAbilities[x].AbilityClass != None; x++)
{
i = list.Length;
- list[i] = ForbiddenAbilities[x].AbilityClass.default.AbilityName;
+ list[i] = RPRI.GetAbility(ForbiddenAbilities[x].AbilityClass).GetName();
if(ForbiddenAbilities[x].Level > 1)
list[i] @= string(ForbiddenAbilities[x].Level);
Oops, something went wrong.

0 comments on commit 5900a44

Please sign in to comment.