diff --git a/OpenRA.Game/Chrome/BackgroundWidget.cs b/OpenRA.Game/Chrome/BackgroundWidget.cs
index 97d98b8b6f..35dff566be 100644
--- a/OpenRA.Game/Chrome/BackgroundWidget.cs
+++ b/OpenRA.Game/Chrome/BackgroundWidget.cs
@@ -1,7 +1,25 @@
-using OpenRA.Graphics;
-using System.Drawing;
-using System.Collections.Generic;
-
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
+using OpenRA.Graphics;
+
namespace OpenRA.Widgets
{
class BackgroundWidget : Widget
diff --git a/OpenRA.Game/Chrome/ButtonWidget.cs b/OpenRA.Game/Chrome/ButtonWidget.cs
index 41ee2e530a..8a20eaed75 100644
--- a/OpenRA.Game/Chrome/ButtonWidget.cs
+++ b/OpenRA.Game/Chrome/ButtonWidget.cs
@@ -1,7 +1,26 @@
-using OpenRA.Graphics;
-using System.Drawing;
-using System.Collections.Generic;
-
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
+using System.Drawing;
+using OpenRA.Graphics;
+
namespace OpenRA.Widgets
{
class ButtonWidget : Widget
diff --git a/OpenRA.Game/Chrome/CheckboxWidget.cs b/OpenRA.Game/Chrome/CheckboxWidget.cs
index 329f709976..a74a63d394 100644
--- a/OpenRA.Game/Chrome/CheckboxWidget.cs
+++ b/OpenRA.Game/Chrome/CheckboxWidget.cs
@@ -1,7 +1,25 @@
-using OpenRA.Graphics;
-using System.Drawing;
-using System.Collections.Generic;
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+using OpenRA.Graphics;
+
namespace OpenRA.Widgets
{
class CheckboxWidget : Widget
diff --git a/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs b/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs
index ab9d77fd30..2f833ad836 100644
--- a/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs
+++ b/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs
@@ -1,9 +1,27 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Drawing;
-using System.Net;
-using OpenRA.FileFormats;
-using OpenRA.Graphics;
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Net;
using OpenRA.Server;
namespace OpenRA.Widgets.Delegates
diff --git a/OpenRA.Game/Chrome/LabelWidget.cs b/OpenRA.Game/Chrome/LabelWidget.cs
index fe36f5c877..b85875bdbb 100644
--- a/OpenRA.Game/Chrome/LabelWidget.cs
+++ b/OpenRA.Game/Chrome/LabelWidget.cs
@@ -1,7 +1,25 @@
-using OpenRA.Graphics;
-using System.Drawing;
-using System.Collections.Generic;
-
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
+using System.Drawing;
+
namespace OpenRA.Widgets
{
class LabelWidget : Widget
diff --git a/OpenRA.Game/Chrome/Widget.cs b/OpenRA.Game/Chrome/Widget.cs
index 8d815f57b4..d14e3871d0 100644
--- a/OpenRA.Game/Chrome/Widget.cs
+++ b/OpenRA.Game/Chrome/Widget.cs
@@ -1,9 +1,29 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
using OpenRA.FileFormats;
-using OpenRA.Widgets.Delegates;
-using System.Linq;
+using OpenRA.Widgets.Delegates;
namespace OpenRA.Widgets
{
diff --git a/OpenRA.Game/Chrome/WidgetLoader.cs b/OpenRA.Game/Chrome/WidgetLoader.cs
index b5c7ac9f21..e54eb74494 100644
--- a/OpenRA.Game/Chrome/WidgetLoader.cs
+++ b/OpenRA.Game/Chrome/WidgetLoader.cs
@@ -1,7 +1,27 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
using System;
+using System.Collections.Generic;
using OpenRA.FileFormats;
using OpenRA.Widgets;
-using System.Collections.Generic;
namespace OpenRA
{
diff --git a/OpenRA.Game/Traits/World/CrateSpawner.cs b/OpenRA.Game/Traits/World/CrateSpawner.cs
index f62376401d..bfd8089c5a 100644
--- a/OpenRA.Game/Traits/World/CrateSpawner.cs
+++ b/OpenRA.Game/Traits/World/CrateSpawner.cs
@@ -57,22 +57,23 @@ namespace OpenRA.Traits
}
}
+ const int ChooseCrateLocationAttempts = 100;
+
void SpawnCrate(Actor self, CrateSpawnerInfo info)
{
var inWater = self.World.SharedRandom.NextDouble() < info.WaterChance;
var umt = inWater ? UnitMovementType.Float : UnitMovementType.Wheel;
- int count = 0, threshold = 100;
- for (; ; )
+
+ for (var n = 0; n < ChooseCrateLocationAttempts; n++)
{
- var p = new int2(self.World.SharedRandom.Next(0, 127), self.World.SharedRandom.Next(0, 127));
+ var p = self.World.ChooseRandomCell(self.World.SharedRandom);
+
if (self.World.IsCellBuildable(p, umt))
{
self.World.AddFrameEndTask(
w => crates.Add(w.CreateActor("crate", p, self.Owner)));
break;
}
- if (count++ > threshold)
- break;
}
}
}
diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs
index 5396fb407b..a34cae41a8 100755
--- a/OpenRA.Game/WorldUtils.cs
+++ b/OpenRA.Game/WorldUtils.cs
@@ -212,6 +212,13 @@ namespace OpenRA
: (edge ? w.Map.YOffset : w.Map.YOffset + w.Map.Height));
}
+ public static int2 ChooseRandomCell(this World w, Thirdparty.Random r)
+ {
+ return new int2(
+ r.Next(w.Map.XOffset, w.Map.XOffset + w.Map.Width),
+ r.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height));
+ }
+
public static IEnumerable GetCountries(this World w)
{
return w.WorldActor.Info.Traits.WithInterface();
diff --git a/OpenRA.Mods.RA/RenderSpy.cs b/OpenRA.Mods.RA/RenderSpy.cs
index 10f120d760..2def8fc9b1 100644
--- a/OpenRA.Mods.RA/RenderSpy.cs
+++ b/OpenRA.Mods.RA/RenderSpy.cs
@@ -31,10 +31,7 @@ namespace OpenRA.Mods.RA
class RenderSpy : RenderInfantry, IRenderModifier
{
- public RenderSpy(Actor self)
- : base(self)
- {
- }
+ public RenderSpy(Actor self) : base(self) { }
public IEnumerable ModifyRender(Actor self, IEnumerable r)
{