From 72841a51e6e9926d61201a5b218ebf74ff9e0ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 6 Mar 2013 16:05:31 +0100 Subject: [PATCH 1/3] add shroud, creates shroud and reveals shroud to syncreport --- OpenRA.Game/Actor.cs | 3 +-- OpenRA.Game/Traits/CreatesShroud.cs | 10 +++++----- OpenRA.Game/Traits/Player/PlayerResources.cs | 9 +++------ OpenRA.Game/Traits/RevealsShroud.cs | 4 ++-- OpenRA.Game/Traits/World/Shroud.cs | 8 ++++---- OpenRA.Mods.RA/Air/Aircraft.cs | 9 +++------ 6 files changed, 18 insertions(+), 25 deletions(-) diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 8bd5730a10..925c5b12fd 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -47,8 +47,7 @@ namespace OpenRA public Shroud.ActorVisibility Sight; - [Sync] - public Player Owner; + [Sync] public Player Owner; Activity currentActivity; public Group Group; diff --git a/OpenRA.Game/Traits/CreatesShroud.cs b/OpenRA.Game/Traits/CreatesShroud.cs index 9b1a22aa7b..cda91774ce 100644 --- a/OpenRA.Game/Traits/CreatesShroud.cs +++ b/OpenRA.Game/Traits/CreatesShroud.cs @@ -18,10 +18,10 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new CreatesShroud(this); } } - public class CreatesShroud : ITick + public class CreatesShroud : ITick, ISync { CreatesShroudInfo Info; - CPos previousLocation; + [Sync] CPos previousLocation; Shroud.ActorVisibility v; public CreatesShroud(CreatesShroudInfo info) @@ -37,20 +37,20 @@ namespace OpenRA.Traits if (previousLocation != self.Location && v != null) { previousLocation = self.Location; - var shrouds = self.World.ActorsWithTrait().Select(s => s.Actor.Owner.Shroud); + var shrouds = self.World.ActorsWithTrait().Select(s => s.Actor.Owner.Shroud); foreach (var shroud in shrouds) { shroud.UnhideActor(self, v, Info.Range); } } if (!self.TraitsImplementing().Any(d => d.Disabled)) { - var shrouds = self.World.ActorsWithTrait().Select(s => s.Actor.Owner.Shroud); + var shrouds = self.World.ActorsWithTrait().Select(s => s.Actor.Owner.Shroud); foreach (var shroud in shrouds) { shroud.HideActor(self, Info.Range); } } else { - var shrouds = self.World.ActorsWithTrait().Select(s => s.Actor.Owner.Shroud); + var shrouds = self.World.ActorsWithTrait().Select(s => s.Actor.Owner.Shroud); foreach (var shroud in shrouds) { shroud.UnhideActor(self, v, Info.Range); } diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index 9f0261e4d9..032be55465 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -75,13 +75,10 @@ namespace OpenRA.Traits AdviceInterval = info.AdviceInterval; } - [Sync] - public int Cash; + [Sync] public int Cash; - [Sync] - public int Ore; - [Sync] - public int OreCapacity; + [Sync] public int Ore; + [Sync] public int OreCapacity; public int DisplayCash; public int DisplayOre; diff --git a/OpenRA.Game/Traits/RevealsShroud.cs b/OpenRA.Game/Traits/RevealsShroud.cs index 17a9de7fe9..e20c5e53f8 100644 --- a/OpenRA.Game/Traits/RevealsShroud.cs +++ b/OpenRA.Game/Traits/RevealsShroud.cs @@ -16,10 +16,10 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new RevealsShroud(this); } } - public class RevealsShroud : ITick + public class RevealsShroud : ITick, ISync { RevealsShroudInfo Info; - CPos previousLocation; + [Sync] CPos previousLocation; public RevealsShroud(RevealsShroudInfo info) { diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 6392caef4c..4e94321c01 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -20,19 +20,19 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new Shroud(init.world); } } - public class Shroud + public class Shroud : ISync { Map map; World world; - public Player Owner; + [Sync] public Player Owner; public int[,] visibleCells; public bool[,] exploredCells; public bool[,] foggedCells; public Rectangle? exploredBounds; bool disabled = false; public bool dirty = true; - public bool Disabled + [Sync] public bool Disabled { get { return disabled; } set { disabled = value; Dirty(); } @@ -70,7 +70,7 @@ namespace OpenRA.Traits // cache of positions that were added, so no matter what crazy trait code does, it // can't make us invalid. - public class ActorVisibility { public int range; public CPos[] vis; } + public class ActorVisibility { [Sync] public int range; [Sync] public CPos[] vis; } public Dictionary vis = new Dictionary(); static IEnumerable FindVisibleTiles(World world, CPos a, int r) diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index 10aa762605..b1e3eda26a 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -102,12 +102,9 @@ namespace OpenRA.Mods.RA.Air protected readonly Actor self; - [Sync] - public int Facing { get; set; } - [Sync] - public int Altitude { get; set; } - [Sync] - public PSubPos SubPxPosition; + [Sync] public int Facing { get; set; } + [Sync] public int Altitude { get; set; } + [Sync] public PSubPos SubPxPosition; public PPos PxPosition { get { return SubPxPosition.ToPPos(); } } public CPos TopLeft { get { return PxPosition.ToCPos(); } } From 60923e34135b8d3a7d9085b9a17f129712c3bb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 7 Mar 2013 08:33:02 +0100 Subject: [PATCH 2/3] log panicking infantry to the syncreport.log --- OpenRA.Mods.RA/ScaredyCat.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/ScaredyCat.cs b/OpenRA.Mods.RA/ScaredyCat.cs index 086e8effb2..edf4e88a26 100644 --- a/OpenRA.Mods.RA/ScaredyCat.cs +++ b/OpenRA.Mods.RA/ScaredyCat.cs @@ -22,13 +22,13 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new ScaredyCat(init.self, this); } } - class ScaredyCat : ITick, INotifyIdle, INotifyDamage, INotifyAttack, ISpeedModifier + class ScaredyCat : ITick, INotifyIdle, INotifyDamage, INotifyAttack, ISpeedModifier, ISync { readonly ScaredyCatInfo Info; - readonly Actor Self; + [Sync] readonly Actor Self; - public int PanicStartedTick; - public bool Panicking { get { return PanicStartedTick > 0; } } + [Sync] public int PanicStartedTick; + [Sync] public bool Panicking { get { return PanicStartedTick > 0; } } public ScaredyCat(Actor self, ScaredyCatInfo info) { From 4a26d3f36ef532a9b64d78ae4ce41bb530c9db54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 7 Mar 2013 12:50:18 +0100 Subject: [PATCH 3/3] fix AutoTarget sync - ISync interface was missing - UnitStance enum was unhashable --- OpenRA.Mods.RA/AutoTarget.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/AutoTarget.cs b/OpenRA.Mods.RA/AutoTarget.cs index 7a3f5d936a..2e36b823eb 100644 --- a/OpenRA.Mods.RA/AutoTarget.cs +++ b/OpenRA.Mods.RA/AutoTarget.cs @@ -25,13 +25,14 @@ namespace OpenRA.Mods.RA public enum UnitStance { HoldFire, ReturnFire, Defend, AttackAnything }; - public class AutoTarget : INotifyIdle, INotifyDamage, ITick, IResolveOrder + public class AutoTarget : INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync { readonly AutoTargetInfo Info; readonly AttackBase attack; [Sync] int nextScanTime = 0; - [Sync] public UnitStance stance; + public UnitStance stance; + [Sync] public int stanceNumber { get { return (int)stance; } } public UnitStance predictedStance; /* NOT SYNCED: do not refer to this anywhere other than UI code */ public AutoTarget(Actor self, AutoTargetInfo info)