diff --git a/BarotraumaClient/BarotraumaClient.csproj b/BarotraumaClient/BarotraumaClient.csproj
index 6e8bfaaec..1e5bf3c1d 100644
--- a/BarotraumaClient/BarotraumaClient.csproj
+++ b/BarotraumaClient/BarotraumaClient.csproj
@@ -97,6 +97,7 @@
+
@@ -157,6 +158,7 @@
+
diff --git a/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundCreatureManager.cs b/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundCreatureManager.cs
index ed2974c81..3f9b7a8ba 100644
--- a/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundCreatureManager.cs
+++ b/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundCreatureManager.cs
@@ -64,14 +64,14 @@ namespace Barotrauma
var wayPoints = WayPoint.WayPointList.FindAll(wp => wp.Submarine==null);
if (wayPoints.Any())
{
- WayPoint wp = wayPoints[Rand.Int(wayPoints.Count, false)];
+ WayPoint wp = wayPoints[Rand.Int(wayPoints.Count, Rand.RandSync.ClientOnly)];
pos = new Vector2(wp.Rect.X, wp.Rect.Y);
- pos += Rand.Vector(200.0f, false);
+ pos += Rand.Vector(200.0f, Rand.RandSync.ClientOnly);
}
else
{
- pos = Rand.Vector(2000.0f, false);
+ pos = Rand.Vector(2000.0f, Rand.RandSync.ClientOnly);
}
}
else
@@ -80,9 +80,9 @@ namespace Barotrauma
}
- var prefab = prefabs[Rand.Int(prefabs.Count, false)];
+ var prefab = prefabs[Rand.Int(prefabs.Count, Rand.RandSync.ClientOnly)];
- int amount = Rand.Range(prefab.SwarmMin, prefab.SwarmMax, false);
+ int amount = Rand.Range(prefab.SwarmMin, prefab.SwarmMax, Rand.RandSync.ClientOnly);
List swarmMembers = new List();
for (int n = 0; n < amount; n++)
diff --git a/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs b/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs
index 9236b2c73..0d722798b 100644
--- a/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs
+++ b/BarotraumaClient/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs
@@ -101,10 +101,10 @@ namespace Barotrauma
rotation = MathUtils.VectorToAngle(new Vector2(edgeNormal.Y, edgeNormal.X));
}
- rotation += Rand.Range(prefab.RandomRotation.X, prefab.RandomRotation.Y, false);
+ rotation += Rand.Range(prefab.RandomRotation.X, prefab.RandomRotation.Y, Rand.RandSync.ClientOnly);
var newSprite = new BackgroundSprite(prefab,
- new Vector3((Vector2)pos, Rand.Range(prefab.DepthRange.X, prefab.DepthRange.Y, false)), Rand.Range(prefab.Scale.X, prefab.Scale.Y, false), rotation);
+ new Vector3((Vector2)pos, Rand.Range(prefab.DepthRange.X, prefab.DepthRange.Y, Rand.RandSync.ClientOnly)), Rand.Range(prefab.Scale.X, prefab.Scale.Y, Rand.RandSync.ClientOnly), rotation);
//calculate the positions of the corners of the rotated sprite
Vector2 halfSize = newSprite.Prefab.Sprite.size * newSprite.Scale / 2;
@@ -155,8 +155,8 @@ namespace Barotrauma
edgeNormal = Vector2.One;
Vector2 randomPos = new Vector2(
- Rand.Range(0.0f, level.Size.X, false),
- Rand.Range(0.0f, level.Size.Y, false));
+ Rand.Range(0.0f, level.Size.X, Rand.RandSync.ClientOnly),
+ Rand.Range(0.0f, level.Size.Y, Rand.RandSync.ClientOnly));
if (!prefab.SpawnOnWalls) return randomPos;
@@ -167,7 +167,7 @@ namespace Barotrauma
if (cells.Any())
{
- VoronoiCell cell = cells[Rand.Int(cells.Count, false)];
+ VoronoiCell cell = cells[Rand.Int(cells.Count, Rand.RandSync.ClientOnly)];
foreach (GraphEdge edge in cell.edges)
{
@@ -220,13 +220,13 @@ namespace Barotrauma
if (!edges.Any()) return null;
- int index = Rand.Int(edges.Count, false);
+ int index = Rand.Int(edges.Count, Rand.RandSync.ClientOnly);
closestEdge = edges[index];
edgeNormal = normals[index];
float length = Vector2.Distance(closestEdge.point1, closestEdge.point2);
Vector2 dir = (closestEdge.point1 - closestEdge.point2) / length;
- Vector2 pos = closestEdge.point2 + dir * Rand.Range(prefab.Sprite.size.X / 2.0f, length - prefab.Sprite.size.X / 2.0f, false);
+ Vector2 pos = closestEdge.point2 + dir * Rand.Range(prefab.Sprite.size.X / 2.0f, length - prefab.Sprite.size.X / 2.0f, Rand.RandSync.ClientOnly);
return pos;
}
@@ -331,7 +331,7 @@ namespace Barotrauma
totalCommonness += prefab.GetCommonness(levelType);
}
- float randomNumber = Rand.Int(totalCommonness+1, false);
+ float randomNumber = Rand.Int(totalCommonness+1, Rand.RandSync.ClientOnly);
foreach (BackgroundSpritePrefab prefab in prefabs)
{
diff --git a/BarotraumaClient/Source/DebugConsole.cs b/BarotraumaClient/Source/DebugConsole.cs
index 60ff53d55..32cf07e5c 100644
--- a/BarotraumaClient/Source/DebugConsole.cs
+++ b/BarotraumaClient/Source/DebugConsole.cs
@@ -29,13 +29,7 @@ namespace Barotrauma
static GUIFrame frame;
static GUIListBox listBox;
static GUITextBox textBox;
-
- private static string InputText
- {
- get { return textBox.Text; }
- set { textBox.Text = value; }
- }
-
+
public static void Init(GameWindow window)
{
int x = 20, y = 20;
diff --git a/BarotraumaClient/Source/GameSession/CrewManager.cs b/BarotraumaClient/Source/GameSession/CrewManager.cs
index bc5dbef82..b1f11e76a 100644
--- a/BarotraumaClient/Source/GameSession/CrewManager.cs
+++ b/BarotraumaClient/Source/GameSession/CrewManager.cs
@@ -281,7 +281,7 @@ namespace Barotrauma
listBox.ClearChildren();
characters.Clear();
- WayPoint[] waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub);
+ WayPoint[] waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub, false);
for (int i = 0; i < waypoints.Length; i++)
{
diff --git a/BarotraumaShared/Source/GameSession/HireManager.cs b/BarotraumaClient/Source/GameSession/HireManager.cs
similarity index 100%
rename from BarotraumaShared/Source/GameSession/HireManager.cs
rename to BarotraumaClient/Source/GameSession/HireManager.cs
diff --git a/BarotraumaClient/Source/Map/Map/Location.cs b/BarotraumaClient/Source/Map/Map/Location.cs
new file mode 100644
index 000000000..98f463cdc
--- /dev/null
+++ b/BarotraumaClient/Source/Map/Map/Location.cs
@@ -0,0 +1,15 @@
+using Microsoft.Xna.Framework;
+using System.Collections.Generic;
+
+namespace Barotrauma
+{
+ partial class Location
+ {
+ private HireManager hireManager;
+
+ public HireManager HireManager
+ {
+ get { return hireManager; }
+ }
+ }
+}
diff --git a/BarotraumaClient/Source/Networking/GameClient.cs b/BarotraumaClient/Source/Networking/GameClient.cs
index 121601014..31e8be477 100644
--- a/BarotraumaClient/Source/Networking/GameClient.cs
+++ b/BarotraumaClient/Source/Networking/GameClient.cs
@@ -92,7 +92,7 @@ namespace Barotrauma.Networking
fileReceiver = new FileReceiver("Submarines/Downloaded");
fileReceiver.OnFinished += OnFileReceived;
- characterInfo = new CharacterInfo(Character.HumanConfigFile, name);
+ characterInfo = new CharacterInfo(Character.HumanConfigFile, name,Gender.None,null);
characterInfo.Job = null;
otherClients = new List();
diff --git a/BarotraumaClient/Source/Screens/NetLobbyScreen.cs b/BarotraumaClient/Source/Screens/NetLobbyScreen.cs
index ce488fc57..50d540681 100644
--- a/BarotraumaClient/Source/Screens/NetLobbyScreen.cs
+++ b/BarotraumaClient/Source/Screens/NetLobbyScreen.cs
@@ -565,7 +565,7 @@ namespace Barotrauma
{
if (tickBox.Selected)
{
- GameMain.Server.CharacterInfo = new CharacterInfo(Character.HumanConfigFile, GameMain.Server.Name);
+ GameMain.Server.CharacterInfo = new CharacterInfo(Character.HumanConfigFile, GameMain.Server.Name,Gender.None,null);
UpdatePlayerFrame(GameMain.Server.CharacterInfo);
}
else
diff --git a/BarotraumaServer/BarotraumaServer.csproj b/BarotraumaServer/BarotraumaServer.csproj
index e274e5bb5..7eeeb0ffa 100644
--- a/BarotraumaServer/BarotraumaServer.csproj
+++ b/BarotraumaServer/BarotraumaServer.csproj
@@ -51,7 +51,7 @@
False
- C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll
+ C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll
..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll
@@ -90,6 +90,7 @@
+
diff --git a/BarotraumaServer/Source/DebugConsole.cs b/BarotraumaServer/Source/DebugConsole.cs
index 00f6c1bcc..29575e84b 100644
--- a/BarotraumaServer/Source/DebugConsole.cs
+++ b/BarotraumaServer/Source/DebugConsole.cs
@@ -13,11 +13,41 @@ namespace Barotrauma
{
static partial class DebugConsole
{
- private static string InputText;
+ public static List QueuedCommands = new List();
+
+ public static void Update()
+ {
+ lock (QueuedCommands)
+ {
+ while (QueuedCommands.Count>0)
+ {
+ ExecuteCommand(QueuedCommands[0], GameMain.Instance);
+ QueuedCommands.RemoveAt(0);
+ }
+ }
+ }
private static bool ExecProjSpecific(string[] commands)
{
- return false; //command not found
+ switch (commands[0].ToLower())
+ {
+ case "startgame":
+ case "startround":
+ case "start":
+ if (Screen.Selected == GameMain.GameScreen) break;
+ if (!GameMain.Server.StartGame()) NewMessage("Failed to start server",Color.Yellow);
+ break;
+ case "endgame":
+ case "endround":
+ case "end":
+ if (Screen.Selected == GameMain.NetLobbyScreen) break;
+ GameMain.Server.EndGame();
+ break;
+ default:
+ return false;
+ break;
+ }
+ return true; //command found
}
}
}
diff --git a/BarotraumaServer/Source/GameMain.cs b/BarotraumaServer/Source/GameMain.cs
index 527f5dcf9..55d7ad710 100644
--- a/BarotraumaServer/Source/GameMain.cs
+++ b/BarotraumaServer/Source/GameMain.cs
@@ -58,6 +58,12 @@ namespace Barotrauma
{
Instance = this;
+ World = new World(new Vector2(0, -9.82f));
+ FarseerPhysics.Settings.AllowSleep = true;
+ FarseerPhysics.Settings.ContinuousPhysics = false;
+ FarseerPhysics.Settings.VelocityIterations = 1;
+ FarseerPhysics.Settings.PositionIterations = 1;
+
Config = new GameSettings("serverconfig.xml");
if (Config.WasGameUpdated)
{
@@ -65,6 +71,8 @@ namespace Barotrauma
Config.WasGameUpdated = false;
Config.Save("serverconfig.xml");
}
+
+ GameScreen = new GameScreen();
}
public void Run()
@@ -91,9 +99,10 @@ namespace Barotrauma
NetLobbyScreen = new NetLobbyScreen();
- Server = new GameServer("Dedicated Server Test", 14242, true, "asd", false, 10);
+ Server = new GameServer("Dedicated Server Test", 14242, false, "asd", false, 10);
while (true)
{
+ DebugConsole.Update();
NetLobbyScreen.Update((float)Timing.Step);
Server.Update((float)Timing.Step);
CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);
@@ -107,7 +116,10 @@ namespace Barotrauma
while (true)
{
string input = Console.ReadLine();
- DebugConsole.ExecuteCommand(input, this);
+ lock (DebugConsole.QueuedCommands)
+ {
+ DebugConsole.QueuedCommands.Add(input);
+ }
}
}
diff --git a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs
index 3c4cc0409..386d62ec5 100644
--- a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs
+++ b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs
@@ -33,16 +33,24 @@ namespace Barotrauma
}
}
-
- public override void Select()
+ public NetLobbyScreen()
{
- List subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList();
+ LevelSeed = ToolBox.RandomSeed(8);
- SelectedSub = subsToShow[0];
- SelectedShuttle = subsToShow[0]; //TODO: don't use the same sub as a shuttle by default
+ subs = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList();
+
+ SelectedSub = subs[0];
+ SelectedShuttle = subs[0]; //TODO: don't use the same sub as a shuttle by default
DebugConsole.NewMessage("Selected sub: " + SelectedSub.Name, Color.White);
DebugConsole.NewMessage("Selected shuttle: " + SelectedShuttle.Name, Color.White);
+
+ GameModes = GameModePreset.list.ToArray();
+ }
+
+ public override void Select()
+ {
+
}
private List subs = new List();
@@ -62,6 +70,7 @@ namespace Barotrauma
if (levelSeed == value) return;
levelSeed = value;
+ LocationType.Random(levelSeed); //call to sync up with clients
}
}
diff --git a/BarotraumaServer/Source/Utils/XnaToConsoleColor.cs b/BarotraumaServer/Source/Utils/XnaToConsoleColor.cs
new file mode 100644
index 000000000..e6a11aa8e
--- /dev/null
+++ b/BarotraumaServer/Source/Utils/XnaToConsoleColor.cs
@@ -0,0 +1,41 @@
+using Microsoft.Xna.Framework;
+using System;
+using System.Collections.Generic;
+
+namespace Barotrauma
+{
+ public static class XnaToConsoleColor
+ {
+ static Dictionary dictionary;
+
+ public static ConsoleColor Convert(Color xnaCol)
+ {
+ if (dictionary == null)
+ {
+ dictionary = new Dictionary();
+ dictionary.Add(Color.White, ConsoleColor.White);
+ dictionary.Add(Color.Gray, ConsoleColor.Gray);
+ dictionary.Add(Color.LightGray, ConsoleColor.Gray);
+ dictionary.Add(Color.DarkGray, ConsoleColor.Gray);
+ dictionary.Add(Color.Red, ConsoleColor.Red);
+ dictionary.Add(Color.DarkRed, ConsoleColor.DarkRed);
+ dictionary.Add(Color.Yellow, ConsoleColor.Yellow);
+ dictionary.Add(Color.Orange, ConsoleColor.Yellow);
+ dictionary.Add(Color.Green, ConsoleColor.Green);
+ dictionary.Add(Color.Lime, ConsoleColor.Green);
+ dictionary.Add(Color.Blue, ConsoleColor.Blue);
+ dictionary.Add(Color.Cyan, ConsoleColor.Cyan);
+ dictionary.Add(Color.DarkBlue, ConsoleColor.DarkBlue);
+ dictionary.Add(Color.Pink, ConsoleColor.Magenta);
+ }
+
+ ConsoleColor val = ConsoleColor.White;
+ if (dictionary.TryGetValue(xnaCol, out val))
+ {
+ return val;
+ }
+
+ return ConsoleColor.White;
+ }
+ }
+}
diff --git a/BarotraumaShared/BarotraumaShared.projitems b/BarotraumaShared/BarotraumaShared.projitems
index c9c00d860..eb6f72557 100644
--- a/BarotraumaShared/BarotraumaShared.projitems
+++ b/BarotraumaShared/BarotraumaShared.projitems
@@ -1343,7 +1343,6 @@
-
diff --git a/BarotraumaShared/Source/Characters/CharacterInfo.cs b/BarotraumaShared/Source/Characters/CharacterInfo.cs
index a4ca802de..c63d9ae10 100644
--- a/BarotraumaShared/Source/Characters/CharacterInfo.cs
+++ b/BarotraumaShared/Source/Characters/CharacterInfo.cs
@@ -113,7 +113,7 @@ namespace Barotrauma
if (gender == Gender.None)
{
float femaleRatio = ToolBox.GetAttributeFloat(doc.Root, "femaleratio", 0.5f);
- this.gender = (Rand.Range(0.0f, 1.0f, false) < femaleRatio) ? Gender.Female : Gender.Male;
+ this.gender = (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < femaleRatio) ? Gender.Female : Gender.Male;
}
else
{
diff --git a/BarotraumaShared/Source/Characters/Jobs/Job.cs b/BarotraumaShared/Source/Characters/Jobs/Job.cs
index 1f975bf72..99ea1cb83 100644
--- a/BarotraumaShared/Source/Characters/Jobs/Job.cs
+++ b/BarotraumaShared/Source/Characters/Jobs/Job.cs
@@ -71,7 +71,7 @@ namespace Barotrauma
public static Job Random()
{
- JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, false)];
+ JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, Rand.RandSync.Server)];
return new Job(prefab);
}
diff --git a/BarotraumaShared/Source/DebugConsole.cs b/BarotraumaShared/Source/DebugConsole.cs
index 1ef8632ae..11810ca22 100644
--- a/BarotraumaShared/Source/DebugConsole.cs
+++ b/BarotraumaShared/Source/DebugConsole.cs
@@ -40,7 +40,7 @@ namespace Barotrauma
if (!commands[0].ToLowerInvariant().Equals("admin"))
{
- NewMessage(InputText, Color.White);
+ NewMessage(command, Color.White);
}
#if !DEBUG
@@ -499,6 +499,7 @@ namespace Barotrauma
Messages.Add(new ColoredText(msg, color));
#if SERVER
//TODO: REMOVE
+ Console.ForegroundColor = XnaToConsoleColor.Convert(color);
Console.WriteLine(msg);
#endif
diff --git a/BarotraumaShared/Source/Events/Missions/CargoMission.cs b/BarotraumaShared/Source/Events/Missions/CargoMission.cs
index acb048d58..839f09298 100644
--- a/BarotraumaShared/Source/Events/Missions/CargoMission.cs
+++ b/BarotraumaShared/Source/Events/Missions/CargoMission.cs
@@ -69,7 +69,7 @@ namespace Barotrauma
}
Vector2 position = new Vector2(
- cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
+ cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, Rand.RandSync.Server),
cargoRoom.Rect.Y - cargoRoom.Rect.Height + itemPrefab.Size.Y / 2);
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
diff --git a/BarotraumaShared/Source/Events/MonsterEvent.cs b/BarotraumaShared/Source/Events/MonsterEvent.cs
index bdc894828..b5e72edc8 100644
--- a/BarotraumaShared/Source/Events/MonsterEvent.cs
+++ b/BarotraumaShared/Source/Events/MonsterEvent.cs
@@ -76,7 +76,7 @@ namespace Barotrauma
Vector2 spawnPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType, true);
- int amount = Rand.Range(minAmount, maxAmount, false);
+ int amount = Rand.Range(minAmount, maxAmount, Rand.RandSync.Server);
monsters = new Character[amount];
@@ -84,8 +84,8 @@ namespace Barotrauma
for (int i = 0; i < amount; i++)
{
- spawnPos.X += Rand.Range(-0.5f, 0.5f, false);
- spawnPos.Y += Rand.Range(-0.5f, 0.5f, false);
+ spawnPos.X += Rand.Range(-0.5f, 0.5f, Rand.RandSync.Server);
+ spawnPos.Y += Rand.Range(-0.5f, 0.5f, Rand.RandSync.Server);
monsters[i] = Character.Create(characterFile, spawnPos, null, GameMain.Client != null);
}
}
diff --git a/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs b/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs
index 542ba571c..bb9a182f6 100644
--- a/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs
+++ b/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs
@@ -41,9 +41,9 @@ namespace Barotrauma
{
for (float y = edges.Y + siteInterval; y < edges.W - siteInterval; y += siteInterval)
{
- if (Rand.Int(5, false) == 0) continue; //skip some positions to make the cells more irregular
+ if (Rand.Int(5, Rand.RandSync.Server) == 0) continue; //skip some positions to make the cells more irregular
- sites.Add(new Vector2(x, y) + Rand.Vector(siteVariance, false));
+ sites.Add(new Vector2(x, y) + Rand.Vector(siteVariance, Rand.RandSync.Server));
}
}
@@ -126,10 +126,10 @@ namespace Barotrauma
}
//randomly pick one of the adjacent cells as the next cell
- pathCell = allowedNextCells[Rand.Int(allowedNextCells.Count, false)];
+ pathCell = allowedNextCells[Rand.Int(allowedNextCells.Count, Rand.RandSync.Server)];
//randomly take steps further away from the startpoint to make the cave expand further
- if (Rand.Int(4, false) == 0)
+ if (Rand.Int(4, Rand.RandSync.Server) == 0)
{
float furthestDist = 0.0f;
foreach (VoronoiCell nextCell in allowedNextCells)
@@ -300,7 +300,7 @@ namespace Barotrauma
}
//steer towards target
- if (Rand.Range(0.0f, 1.0f, false) > wanderAmount || allowedEdges.Count == 0)
+ if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) > wanderAmount || allowedEdges.Count == 0)
{
for (int i = 0; i < currentCell.edges.Count; i++)
{
@@ -321,7 +321,7 @@ namespace Barotrauma
//}
//else
//{
- edgeIndex = Rand.Int(allowedEdges.Count, false);
+ edgeIndex = Rand.Int(allowedEdges.Count, Rand.RandSync.Server);
if (mirror && edgeIndex > 0) edgeIndex = allowedEdges.Count - edgeIndex;
edgeIndex = currentCell.edges.IndexOf(allowedEdges[edgeIndex]);
//}
diff --git a/BarotraumaShared/Source/Map/Levels/Level.cs b/BarotraumaShared/Source/Map/Levels/Level.cs
index 5101c526f..9207704f8 100644
--- a/BarotraumaShared/Source/Map/Levels/Level.cs
+++ b/BarotraumaShared/Source/Map/Levels/Level.cs
@@ -148,12 +148,12 @@ namespace Barotrauma
{
if (seed == "")
{
- seed = Rand.Range(0, int.MaxValue, false).ToString();
+ seed = Rand.Range(0, int.MaxValue, Rand.RandSync.Server).ToString();
}
Rand.SetSyncedSeed(ToolBox.StringToInt(seed));
- return new Level(seed, Rand.Range(30.0f, 80.0f, false), LevelGenerationParams.GetRandom(seed));
+ return new Level(seed, Rand.Range(30.0f, 80.0f, Rand.RandSync.Server), LevelGenerationParams.GetRandom(seed));
}
public void Generate(bool mirror = false)
@@ -190,12 +190,12 @@ namespace Barotrauma
}
startPosition = new Vector2(
- Rand.Range(minWidth, minWidth * 2, false),
- Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, false));
+ Rand.Range(minWidth, minWidth * 2, Rand.RandSync.Server),
+ Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, Rand.RandSync.Server));
endPosition = new Vector2(
- borders.Width - Rand.Range(minWidth, minWidth * 2, false),
- Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, false));
+ borders.Width - Rand.Range(minWidth, minWidth * 2, Rand.RandSync.Server),
+ Rand.Range(borders.Height * 0.5f, borders.Height - minWidth * 2, Rand.RandSync.Server));
List pathNodes = new List();
Rectangle pathBorders = borders;// new Rectangle((int)minWidth, (int)minWidth, borders.Width - (int)minWidth * 2, borders.Height - (int)minWidth);
@@ -205,11 +205,11 @@ namespace Barotrauma
Vector2 nodeInterval = generationParams.MainPathNodeIntervalRange;
- for (float x = startPosition.X + Rand.Range(nodeInterval.X, nodeInterval.Y, false);
- x < endPosition.X - Rand.Range(nodeInterval.X, nodeInterval.Y, false);
- x += Rand.Range(nodeInterval.X, nodeInterval.Y, false))
+ for (float x = startPosition.X + Rand.Range(nodeInterval.X, nodeInterval.Y, Rand.RandSync.Server);
+ x < endPosition.X - Rand.Range(nodeInterval.X, nodeInterval.Y, Rand.RandSync.Server);
+ x += Rand.Range(nodeInterval.X, nodeInterval.Y, Rand.RandSync.Server))
{
- pathNodes.Add(new Vector2(x, Rand.Range(pathBorders.Y, pathBorders.Bottom, false)));
+ pathNodes.Add(new Vector2(x, Rand.Range(pathBorders.Y, pathBorders.Bottom, Rand.RandSync.Server)));
}
pathNodes.Add(new Vector2(endPosition.X, borders.Height));
@@ -222,17 +222,17 @@ namespace Barotrauma
List> smallTunnels = new List>();
for (int i = 0; i < generationParams.SmallTunnelCount; i++)
{
- var tunnelStartPos = pathNodes[Rand.Range(2, pathNodes.Count - 2, false)];
+ var tunnelStartPos = pathNodes[Rand.Range(2, pathNodes.Count - 2, Rand.RandSync.Server)];
tunnelStartPos.X = MathHelper.Clamp(tunnelStartPos.X, pathBorders.X, pathBorders.Right);
float tunnelLength = Rand.Range(
generationParams.SmallTunnelLengthRange.X,
generationParams.SmallTunnelLengthRange.Y,
- false);
+ Rand.RandSync.Server);
var tunnelNodes = MathUtils.GenerateJaggedLine(
tunnelStartPos,
- new Vector2(tunnelStartPos.X, pathBorders.Bottom)+Rand.Vector(tunnelLength,false),
+ new Vector2(tunnelStartPos.X, pathBorders.Bottom)+Rand.Vector(tunnelLength, Rand.RandSync.Server),
4, 1000.0f);
List tunnel = new List();
@@ -252,8 +252,8 @@ namespace Barotrauma
for (float y = siteInterval.Y / 2; y < borders.Height; y += siteInterval.Y)
{
Vector2 site = new Vector2(
- x + Rand.Range(-siteVariance.X, siteVariance.X, false),
- y + Rand.Range(-siteVariance.Y, siteVariance.Y, false));
+ x + Rand.Range(-siteVariance.X, siteVariance.X, Rand.RandSync.Server),
+ y + Rand.Range(-siteVariance.Y, siteVariance.Y, Rand.RandSync.Server));
if (smallTunnels.Any(t => t.Any(node => Vector2.Distance(node, site) < siteInterval.Length())))
{
@@ -359,7 +359,7 @@ namespace Barotrauma
int maxTries = 5, tries = 0;
while (tries toBeRemoved = new List();
foreach (VoronoiCell cell in cells)
{
- if (Rand.Range(0.0f, 1.0f, false) > holeProbability) continue;
+ if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) > holeProbability) continue;
if (!limits.Contains(cell.Center)) continue;
@@ -665,10 +665,10 @@ namespace Barotrauma
private void GenerateRuin(List mainPath)
{
- Vector2 ruinSize = new Vector2(Rand.Range(5000.0f, 8000.0f, false), Rand.Range(5000.0f, 8000.0f, false));
+ Vector2 ruinSize = new Vector2(Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server), Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server));
float ruinRadius = Math.Max(ruinSize.X, ruinSize.Y) * 0.5f;
- Vector2 ruinPos = cells[Rand.Int(cells.Count, false)].Center;
+ Vector2 ruinPos = cells[Rand.Int(cells.Count, Rand.RandSync.Server)].Center;
int iter = 0;
@@ -762,7 +762,7 @@ namespace Barotrauma
{
Vector2 startPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType, true);
- startPos += Rand.Vector(Rand.Range(0.0f, randomSpread, false), false);
+ startPos += Rand.Vector(Rand.Range(0.0f, randomSpread, Rand.RandSync.Server), Rand.RandSync.Server);
Vector2 endPos = startPos - Vector2.UnitY * Size.Y;
@@ -804,10 +804,10 @@ namespace Barotrauma
if (!matchingPositions.Any())
{
- return positionsOfInterest[Rand.Int(positionsOfInterest.Count, !useSyncedRand)].Position;
+ return positionsOfInterest[Rand.Int(positionsOfInterest.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position;
}
- return matchingPositions[Rand.Int(matchingPositions.Count, !useSyncedRand)].Position;
+ return matchingPositions[Rand.Int(matchingPositions.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position;
}
public void Update(float deltaTime)
diff --git a/BarotraumaShared/Source/Map/Levels/LevelGenerationParams.cs b/BarotraumaShared/Source/Map/Levels/LevelGenerationParams.cs
index e55ea1242..f9f33e5d9 100644
--- a/BarotraumaShared/Source/Map/Levels/LevelGenerationParams.cs
+++ b/BarotraumaShared/Source/Map/Levels/LevelGenerationParams.cs
@@ -144,7 +144,7 @@ namespace Barotrauma
return new LevelGenerationParams(null);
}
- return presets[Rand.Range(0, presets.Count, false)];
+ return presets[Rand.Range(0, presets.Count, Rand.RandSync.Server)];
}
private LevelGenerationParams(XElement element)
diff --git a/BarotraumaShared/Source/Map/Levels/Ruins/BTRoom.cs b/BarotraumaShared/Source/Map/Levels/Ruins/BTRoom.cs
index ec494c04b..4b9cdef63 100644
--- a/BarotraumaShared/Source/Map/Levels/Ruins/BTRoom.cs
+++ b/BarotraumaShared/Source/Map/Levels/Ruins/BTRoom.cs
@@ -46,7 +46,7 @@ namespace Barotrauma.RuinGeneration
{
subRooms = new BTRoom[2];
- if (Rand.Range(0.0f, 1.0f, false) < verticalProbability &&
+ if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < verticalProbability &&
rect.Width * minDivRatio >= minWidth)
{
SplitVertical(minDivRatio);
@@ -65,7 +65,7 @@ namespace Barotrauma.RuinGeneration
private void SplitHorizontal(float minDivRatio)
{
- float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, false);
+ float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, Rand.RandSync.Server);
subRooms[0] = new BTRoom(new Rectangle(rect.X, rect.Y, rect.Width, (int)(rect.Height * div)));
subRooms[1] = new BTRoom(new Rectangle(rect.X, rect.Y + subRooms[0].rect.Height, rect.Width, rect.Height - subRooms[0].rect.Height));
@@ -73,7 +73,7 @@ namespace Barotrauma.RuinGeneration
private void SplitVertical(float minDivRatio)
{
- float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, false);
+ float div = Rand.Range(minDivRatio, 1.0f - minDivRatio, Rand.RandSync.Server);
subRooms[0] = new BTRoom(new Rectangle(rect.X, rect.Y, (int)(rect.Width * div), rect.Height));
subRooms[1] = new BTRoom(new Rectangle(rect.X + subRooms[0].rect.Width, rect.Y, rect.Width - subRooms[0].rect.Width, rect.Height));
}
@@ -118,7 +118,7 @@ namespace Barotrauma.RuinGeneration
{
if (Adjacent != null && Corridor == null)
{
- Corridor = new Corridor(this, Rand.Range(minWidth, maxWidth, false), corridors);
+ Corridor = new Corridor(this, Rand.Range(minWidth, maxWidth, Rand.RandSync.Server), corridors);
}
if (subRooms != null)
diff --git a/BarotraumaShared/Source/Map/Levels/Ruins/Corridor.cs b/BarotraumaShared/Source/Map/Levels/Ruins/Corridor.cs
index 48e086267..0131fb698 100644
--- a/BarotraumaShared/Source/Map/Levels/Ruins/Corridor.cs
+++ b/BarotraumaShared/Source/Map/Levels/Ruins/Corridor.cs
@@ -72,7 +72,7 @@ namespace Barotrauma.RuinGeneration
int top = Math.Max(room1.Y, room2.Y);
int bottom = Math.Min(room1.Bottom, room2.Bottom);
- int yPos = Rand.Range(top, bottom - width, false);
+ int yPos = Rand.Range(top, bottom - width, Rand.RandSync.Server);
rect = new Rectangle(left, yPos, right - left, width);
}
@@ -84,7 +84,7 @@ namespace Barotrauma.RuinGeneration
int top = Math.Min(room1.Bottom, room2.Bottom);
int bottom = Math.Max(room1.Y, room2.Y);
- int xPos = Rand.Range(left, right - width, false);
+ int xPos = Rand.Range(left, right - width, Rand.RandSync.Server);
rect = new Rectangle(xPos, top, width, bottom - top);
}
@@ -146,8 +146,8 @@ namespace Barotrauma.RuinGeneration
///
private BTRoom[] GetSuitableLeafRooms(List leaves1, List leaves2, int width, bool isHorizontal)
{
- int iOffset = Rand.Int(leaves1.Count, false);
- int jOffset = Rand.Int(leaves2.Count, false);
+ int iOffset = Rand.Int(leaves1.Count, Rand.RandSync.Server);
+ int jOffset = Rand.Int(leaves2.Count, Rand.RandSync.Server);
for (int iCount = 0; iCount < leaves1.Count; iCount++)
diff --git a/BarotraumaShared/Source/Map/Levels/Ruins/RuinGenerator.cs b/BarotraumaShared/Source/Map/Levels/Ruins/RuinGenerator.cs
index 9ae3e6d3e..8b439b67f 100644
--- a/BarotraumaShared/Source/Map/Levels/Ruins/RuinGenerator.cs
+++ b/BarotraumaShared/Source/Map/Levels/Ruins/RuinGenerator.cs
@@ -202,9 +202,9 @@ namespace Barotrauma.RuinGeneration
//area = new Rectangle(area.X, area.Y - area.Height, area.Width, area.Height);
- int iterations = Rand.Range(3, 4, false);
+ int iterations = Rand.Range(3, 4, Rand.RandSync.Server);
- float verticalProbability = Rand.Range(0.4f, 0.6f, false);
+ float verticalProbability = Rand.Range(0.4f, 0.6f, Rand.RandSync.Server);
BTRoom baseRoom = new BTRoom(area);
@@ -221,7 +221,7 @@ namespace Barotrauma.RuinGeneration
{
leaf.Scale
(
- new Vector2(Rand.Range(0.5f, 0.9f, false), Rand.Range(0.5f, 0.9f, false))
+ new Vector2(Rand.Range(0.5f, 0.9f, Rand.RandSync.Server), Rand.Range(0.5f, 0.9f, Rand.RandSync.Server))
);
}
@@ -304,7 +304,7 @@ namespace Barotrauma.RuinGeneration
wallType = RuinStructureType.CorridorWall;
}
//rooms further from the entrance are more likely to have hard-to-break walls
- else if (Rand.Range(0.0f, leaf.DistanceFromEntrance, false) > 1.5f)
+ else if (Rand.Range(0.0f, leaf.DistanceFromEntrance, Rand.RandSync.Server) > 1.5f)
{
wallType = RuinStructureType.HeavyWall;
}
@@ -352,28 +352,28 @@ namespace Barotrauma.RuinGeneration
{
Alignment[] alignments = new Alignment[] { Alignment.Top, Alignment.Bottom, Alignment.Right, Alignment.Left, Alignment.Center };
- var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, false)]);
+ var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, Rand.RandSync.Server)]);
Vector2 size = (prop.Prefab is StructurePrefab) ? ((StructurePrefab)prop.Prefab).Size : Vector2.Zero;
- var shape = shapes[Rand.Int(shapes.Count, false)];
+ var shape = shapes[Rand.Int(shapes.Count, Rand.RandSync.Server)];
Vector2 position = shape.Rect.Center.ToVector2();
if (prop.Alignment.HasFlag(Alignment.Top))
{
- position = new Vector2(Rand.Range(shape.Rect.X+size.X, shape.Rect.Right - size.X, false), shape.Rect.Bottom - 64);
+ position = new Vector2(Rand.Range(shape.Rect.X+size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Bottom - 64);
}
else if (prop.Alignment.HasFlag(Alignment.Bottom))
{
- position = new Vector2(Rand.Range(shape.Rect.X + size.X, shape.Rect.Right - size.X, false), shape.Rect.Top + 64);
+ position = new Vector2(Rand.Range(shape.Rect.X + size.X, shape.Rect.Right - size.X, Rand.RandSync.Server), shape.Rect.Top + 64);
}
else if (prop.Alignment.HasFlag(Alignment.Right))
{
- position = new Vector2(shape.Rect.Right - 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, false));
+ position = new Vector2(shape.Rect.Right - 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
}
else if (prop.Alignment.HasFlag(Alignment.Left))
{
- position = new Vector2(shape.Rect.X + 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, false));
+ position = new Vector2(shape.Rect.X + 64, Rand.Range(shape.Rect.Y + size.X, shape.Rect.Bottom - size.Y, Rand.RandSync.Server));
}
if (prop.Prefab is ItemPrefab)
@@ -410,7 +410,7 @@ namespace Barotrauma.RuinGeneration
Vector2 doorPos = corridor.Center;
//choose a random wall to place the door next to
- var wall = suitableWalls[Rand.Int(suitableWalls.Count, false)];
+ var wall = suitableWalls[Rand.Int(suitableWalls.Count, Rand.RandSync.Server)];
if (corridor.IsHorizontal)
{
doorPos.X = (wall.A.X + wall.B.X) / 2.0f;
@@ -423,7 +423,7 @@ namespace Barotrauma.RuinGeneration
var door = new Item(doorPrefab.Prefab as ItemPrefab, doorPos, null);
door.MoveWithLevel = true;
- door.GetComponent().IsOpen = Rand.Range(0.0f, 1.0f, false) < 0.8f;
+ door.GetComponent().IsOpen = Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < 0.8f;
if (sensorPrefab == null || wirePrefab == null) continue;
@@ -431,8 +431,8 @@ namespace Barotrauma.RuinGeneration
if (sensorRoom == null) continue;
var sensor = new Item(sensorPrefab, new Vector2(
- Rand.Range(sensorRoom.Rect.X, sensorRoom.Rect.Right, false),
- Rand.Range(sensorRoom.Rect.Y, sensorRoom.Rect.Bottom,false)), null);
+ Rand.Range(sensorRoom.Rect.X, sensorRoom.Rect.Right, Rand.RandSync.Server),
+ Rand.Range(sensorRoom.Rect.Y, sensorRoom.Rect.Bottom, Rand.RandSync.Server)), null);
sensor.MoveWithLevel = true;
var wire = new Item(wirePrefab, sensorRoom.Center, null).GetComponent();
diff --git a/BarotraumaShared/Source/Map/Levels/Ruins/RuinStructure.cs b/BarotraumaShared/Source/Map/Levels/Ruins/RuinStructure.cs
index cf16af530..dd0b8143e 100644
--- a/BarotraumaShared/Source/Map/Levels/Ruins/RuinStructure.cs
+++ b/BarotraumaShared/Source/Map/Levels/Ruins/RuinStructure.cs
@@ -84,7 +84,7 @@ namespace Barotrauma.RuinGeneration
int totalCommonness = matchingStructures.Sum(m => m.commonness);
- int randomNumber = Rand.Int(totalCommonness + 1, false);
+ int randomNumber = Rand.Int(totalCommonness + 1, Rand.RandSync.Server);
foreach (RuinStructure ruinStructure in matchingStructures)
{
diff --git a/BarotraumaShared/Source/Map/Levels/WrappingWall.cs b/BarotraumaShared/Source/Map/Levels/WrappingWall.cs
index 8ce7d6ab3..d4f98fc46 100644
--- a/BarotraumaShared/Source/Map/Levels/WrappingWall.cs
+++ b/BarotraumaShared/Source/Map/Levels/WrappingWall.cs
@@ -68,7 +68,7 @@ namespace Barotrauma
float normalizedDist = distFromEdge / (WallWidth / 2);
float variance = 1000.0f * normalizedDist;
- bottomVertices.Add(center + new Vector2(Rand.Range(-variance, variance, false), Rand.Range(-variance, variance, false)*2.0f));
+ bottomVertices.Add(center + new Vector2(Rand.Range(-variance, variance, Rand.RandSync.Server), Rand.Range(-variance, variance, Rand.RandSync.Server) *2.0f));
}
for (int i = 1; i < bottomVertices.Count; i++)
diff --git a/BarotraumaShared/Source/Map/Map/Location.cs b/BarotraumaShared/Source/Map/Map/Location.cs
index 5b3b193c2..6bbdc3522 100644
--- a/BarotraumaShared/Source/Map/Map/Location.cs
+++ b/BarotraumaShared/Source/Map/Map/Location.cs
@@ -3,8 +3,7 @@ using System.Collections.Generic;
namespace Barotrauma
{
-
- class Location
+ partial class Location
{
private string name;
@@ -12,8 +11,6 @@ namespace Barotrauma
private LocationType type;
- private HireManager hireManager;
-
public List Connections;
public string Name
@@ -33,11 +30,6 @@ namespace Barotrauma
get { return type; }
}
- public HireManager HireManager
- {
- get { return hireManager; }
- }
-
public Location(Vector2 mapPosition)
{
this.type = LocationType.Random();
@@ -46,11 +38,13 @@ namespace Barotrauma
this.mapPosition = mapPosition;
+#if CLIENT
if (type.HasHireableCharacters)
{
hireManager = new HireManager();
hireManager.GenerateCharacters(this, HireManager.MaxAvailableCharacters);
}
+#endif
Connections = new List();
}
@@ -63,7 +57,7 @@ namespace Barotrauma
private string RandomName(LocationType type)
{
string randomName = ToolBox.GetRandomLine("Content/Map/locationNames.txt");
- int nameFormatIndex = Rand.Int(type.NameFormats.Count, false);
+ int nameFormatIndex = Rand.Int(type.NameFormats.Count, Rand.RandSync.Server);
return type.NameFormats[nameFormatIndex].Replace("[name]", randomName);
}
}
diff --git a/BarotraumaShared/Source/Map/Map/LocationType.cs b/BarotraumaShared/Source/Map/Map/LocationType.cs
index 2fd6dc864..f34f1e2e6 100644
--- a/BarotraumaShared/Source/Map/Map/LocationType.cs
+++ b/BarotraumaShared/Source/Map/Map/LocationType.cs
@@ -116,7 +116,7 @@ namespace Barotrauma
Rand.SetSyncedSeed(ToolBox.StringToInt(seed));
}
- int randInt = Rand.Int(totalWeight, false);
+ int randInt = Rand.Int(totalWeight, Rand.RandSync.Server);
foreach (LocationType type in list)
{
diff --git a/BarotraumaShared/Source/Map/Map/Map.cs b/BarotraumaShared/Source/Map/Map/Map.cs
index 18aff8f67..4157e85e0 100644
--- a/BarotraumaShared/Source/Map/Map/Map.cs
+++ b/BarotraumaShared/Source/Map/Map/Map.cs
@@ -122,7 +122,7 @@ namespace Barotrauma
List sites = new List();
for (int i = 0; i < 50; i++)
{
- sites.Add(new Vector2(Rand.Range(0.0f, size, false), Rand.Range(0.0f, size, false)));
+ sites.Add(new Vector2(Rand.Range(0.0f, size, Rand.RandSync.Server), Rand.Range(0.0f, size, Rand.RandSync.Server)));
}
List edges = voronoi.MakeVoronoiGraph(sites, size, size);
@@ -148,7 +148,7 @@ namespace Barotrauma
Vector2[] points = new Vector2[] { edge.point1, edge.point2 };
- int positionIndex = Rand.Int(1, false);
+ int positionIndex = Rand.Int(1, Rand.RandSync.Server);
Vector2 position = points[positionIndex];
if (newLocations[1 - i] != null && newLocations[1 - i].MapPosition == position) position = points[1 - positionIndex];
@@ -215,8 +215,8 @@ namespace Barotrauma
private void GenerateDifficulties(Location start, List locations, float currDifficulty)
{
//start.Difficulty = currDifficulty;
- currDifficulty += Rand.Range(difficultyIncrease.X, difficultyIncrease.Y, false);
- if (currDifficulty > Rand.Range(difficultyCutoff.X, difficultyCutoff.Y, false)) currDifficulty = 10.0f;
+ currDifficulty += Rand.Range(difficultyIncrease.X, difficultyIncrease.Y, Rand.RandSync.Server);
+ if (currDifficulty > Rand.Range(difficultyCutoff.X, difficultyCutoff.Y, Rand.RandSync.Server)) currDifficulty = 10.0f;
foreach (LocationConnection connection in start.Connections)
{
diff --git a/BarotraumaShared/Source/Map/WayPoint.cs b/BarotraumaShared/Source/Map/WayPoint.cs
index 5332d845f..725559a18 100644
--- a/BarotraumaShared/Source/Map/WayPoint.cs
+++ b/BarotraumaShared/Source/Map/WayPoint.cs
@@ -475,10 +475,10 @@ namespace Barotrauma
if (!wayPoints.Any()) return null;
- return wayPoints[Rand.Int(wayPoints.Count, !useSyncedRand)];
+ return wayPoints[Rand.Int(wayPoints.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))];
}
- public static WayPoint[] SelectCrewSpawnPoints(List crew, Submarine submarine)
+ public static WayPoint[] SelectCrewSpawnPoints(List crew, Submarine submarine, bool tryAssignWayPoint = true)
{
List subWayPoints = WayPointList.FindAll(wp => wp.Submarine == submarine);
@@ -515,12 +515,15 @@ namespace Barotrauma
if (assignedWayPoints[i] != null) continue;
- //try to assign a spawnpoint that isn't meant for any specific job
- var nonJobSpecificPoints = subWayPoints.FindAll(wp => wp.spawnType == SpawnType.Human && wp.assignedJob == null);
-
- if (nonJobSpecificPoints.Any())
+ if (tryAssignWayPoint)
{
- assignedWayPoints[i] = nonJobSpecificPoints[Rand.Int(nonJobSpecificPoints.Count, false)];
+ //try to assign a spawnpoint that isn't meant for any specific job
+ var nonJobSpecificPoints = subWayPoints.FindAll(wp => wp.spawnType == SpawnType.Human && wp.assignedJob == null);
+
+ if (nonJobSpecificPoints.Any())
+ {
+ assignedWayPoints[i] = nonJobSpecificPoints[Rand.Int(nonJobSpecificPoints.Count, Rand.RandSync.Server)];
+ }
}
if (assignedWayPoints[i] != null) continue;
diff --git a/BarotraumaShared/Source/Screens/GameScreen.cs b/BarotraumaShared/Source/Screens/GameScreen.cs
index cb66eb057..8a03909a5 100644
--- a/BarotraumaShared/Source/Screens/GameScreen.cs
+++ b/BarotraumaShared/Source/Screens/GameScreen.cs
@@ -14,6 +14,12 @@ namespace Barotrauma
get { return cam; }
}
+ public GameScreen()
+ {
+ cam = new Camera();
+ cam.Translate(new Vector2(-10.0f, 50.0f));
+ }
+
public override void Select()
{
base.Select();
diff --git a/BarotraumaShared/Source/Screens/NetLobbyScreen.cs b/BarotraumaShared/Source/Screens/NetLobbyScreen.cs
index 144a69297..7839f669e 100644
--- a/BarotraumaShared/Source/Screens/NetLobbyScreen.cs
+++ b/BarotraumaShared/Source/Screens/NetLobbyScreen.cs
@@ -27,7 +27,7 @@ namespace Barotrauma
return ServerName;
}
- private string levelSeed;
+ private string levelSeed = "";
private float autoRestartTimer;
diff --git a/BarotraumaShared/Source/Utils/MathUtils.cs b/BarotraumaShared/Source/Utils/MathUtils.cs
index fbd29da62..48d73b9df 100644
--- a/BarotraumaShared/Source/Utils/MathUtils.cs
+++ b/BarotraumaShared/Source/Utils/MathUtils.cs
@@ -445,7 +445,7 @@ namespace Barotrauma
Vector2 normal = Vector2.Normalize(endSegment - startSegment);
normal = new Vector2(-normal.Y, normal.X);
- midPoint += normal * Rand.Range(-offsetAmount, offsetAmount, false);
+ midPoint += normal * Rand.Range(-offsetAmount, offsetAmount, Rand.RandSync.Server);
segments.Insert(i, new Vector2[] { startSegment, midPoint });
segments.Insert(i + 1, new Vector2[] { midPoint, endSegment });
diff --git a/BarotraumaShared/Source/Utils/Rand.cs b/BarotraumaShared/Source/Utils/Rand.cs
index 49df98208..610b43e3f 100644
--- a/BarotraumaShared/Source/Utils/Rand.cs
+++ b/BarotraumaShared/Source/Utils/Rand.cs
@@ -5,37 +5,61 @@ namespace Barotrauma
{
static class Rand
{
+ public enum RandSync
+ {
+ Unsynced = -1, //not synced, used for unimportant details like minor particle properties
+ Server = 0, //synced with the server (used for gameplay elements that the players can interact with)
+ ClientOnly = 1 //set to match between clients (used for misc elements that the server doesn't track, but clients want to match anyway)
+ }
+
private static Random localRandom = new Random();
- private static Random syncedRandom = new MTRandom();
+ private static Random[] syncedRandom = new MTRandom[] {
+ new MTRandom(), new MTRandom()
+ };
public static void SetSyncedSeed(int seed)
{
- syncedRandom = new MTRandom(seed);
+ syncedRandom[(int)RandSync.Server] = new MTRandom(seed);
+ syncedRandom[(int)RandSync.ClientOnly] = new MTRandom(seed);
+ }
+
+ private static void Assert(RandSync sync)
+ {
+ //TODO: REMOVE AFTER FINDING ALL WRONG RNG USAGE
+#if CLIENT
+ string trace = Environment.StackTrace.ToString();
+ if (sync != RandSync.Server) return;
+ if (trace.ToLower().Contains("barotraumaclient\\source")) DebugConsole.NewMessage("WARNING: Client code using RandSync.Server\n"+trace,Color.Yellow);
+#endif
}
- public static float Range(float minimum, float maximum, bool local = true)
+ public static float Range(float minimum, float maximum, RandSync sync=RandSync.Unsynced)
{
- return (float)(local ? localRandom : syncedRandom).NextDouble() * (maximum - minimum) + minimum;
+ Assert(sync);
+ return (float)(sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).NextDouble() * (maximum - minimum) + minimum;
}
- public static int Range(int minimum, int maximum, bool local = true)
+ public static int Range(int minimum, int maximum, RandSync sync = RandSync.Unsynced)
{
- return (local ? localRandom : syncedRandom).Next(maximum - minimum) + minimum;
+ Assert(sync);
+ return (sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).Next(maximum - minimum) + minimum;
}
- public static int Int(int max = int.MaxValue, bool local = true)
+ public static int Int(int max, RandSync sync = RandSync.Unsynced)
{
- return (local ? localRandom : syncedRandom).Next(max);
+ Assert(sync);
+ return (sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).Next(max);
}
- public static Vector2 Vector(float length = 1.0f, bool local = true)
+ public static Vector2 Vector(float length, RandSync sync = RandSync.Unsynced)
{
- Vector2 randomVector = new Vector2(Range(-1.0f, 1.0f, local), Range(-1.0f, 1.0f, local));
+ Assert(sync);
+ Vector2 randomVector = new Vector2(Range(-1.0f, 1.0f, sync), Range(-1.0f, 1.0f, sync));
if (randomVector == Vector2.Zero) return new Vector2(0.0f, length);
return Vector2.Normalize(randomVector) * length;
- }
+ }
}
}
diff --git a/BarotraumaShared/Source/Utils/ToolBox.cs b/BarotraumaShared/Source/Utils/ToolBox.cs
index 5b01841f7..b1f6fd7ec 100644
--- a/BarotraumaShared/Source/Utils/ToolBox.cs
+++ b/BarotraumaShared/Source/Utils/ToolBox.cs
@@ -482,7 +482,7 @@ namespace Barotrauma
return "";
}
- int lineNumber = Rand.Int(lineCount, false);
+ int lineNumber = Rand.Int(lineCount, Rand.RandSync.Server);
int i = 0;