(3dc4135ce) v0.9.5.1
This commit is contained in:
@@ -18,7 +18,9 @@ namespace Barotrauma.Networking
|
||||
public const int MaxMessagesPerPacket = 10;
|
||||
|
||||
public const float SpeakRange = 2000.0f;
|
||||
|
||||
|
||||
private static readonly string dateTimeFormatLongTimePattern = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
|
||||
|
||||
public static Color[] MessageColor =
|
||||
{
|
||||
new Color(190, 198, 205), //default
|
||||
@@ -66,6 +68,11 @@ namespace Barotrauma.Networking
|
||||
get { return MessageColor[(int)Type]; }
|
||||
}
|
||||
|
||||
public static string GetTimeStamp()
|
||||
{
|
||||
return $"[{DateTime.Now.ToString(dateTimeFormatLongTimePattern)}] ";
|
||||
}
|
||||
|
||||
public string TextWithSender
|
||||
{
|
||||
get
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace Barotrauma.Networking
|
||||
public byte ID;
|
||||
public UInt64 SteamID;
|
||||
|
||||
public string PreferredJob;
|
||||
|
||||
public Character.TeamType TeamID;
|
||||
|
||||
private Character character;
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Barotrauma
|
||||
{
|
||||
partial class EntitySpawner : Entity, IServerSerializable
|
||||
{
|
||||
const int MaxEntitiesPerWrite = 10;
|
||||
|
||||
private enum SpawnableType { Item, Character };
|
||||
|
||||
interface IEntitySpawnInfo
|
||||
@@ -53,7 +51,7 @@ namespace Barotrauma
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Item spawnedItem = null;
|
||||
Item spawnedItem;
|
||||
if (Inventory != null)
|
||||
{
|
||||
spawnedItem = new Item(Prefab, Vector2.Zero, null);
|
||||
@@ -67,6 +65,41 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
class CharacterSpawnInfo : IEntitySpawnInfo
|
||||
{
|
||||
public readonly string identifier;
|
||||
|
||||
public readonly Vector2 Position;
|
||||
public readonly Submarine Submarine;
|
||||
|
||||
private readonly Action<Character> onSpawn;
|
||||
|
||||
public CharacterSpawnInfo(string identifier, Vector2 worldPosition, Action<Character> onSpawn = null)
|
||||
{
|
||||
this.identifier = identifier ?? throw new ArgumentException("ItemSpawnInfo prefab cannot be null.");
|
||||
Position = worldPosition;
|
||||
this.onSpawn = onSpawn;
|
||||
}
|
||||
|
||||
public CharacterSpawnInfo(string identifier, Vector2 position, Submarine sub, Action<Character> onSpawn = null)
|
||||
{
|
||||
this.identifier = identifier ?? throw new ArgumentException("ItemSpawnInfo prefab cannot be null.");
|
||||
Position = position;
|
||||
Submarine = sub;
|
||||
this.onSpawn = onSpawn;
|
||||
}
|
||||
|
||||
public Entity Spawn()
|
||||
{
|
||||
var character = string.IsNullOrEmpty(identifier) ? null :
|
||||
Character.Create(identifier,
|
||||
Submarine == null ? Position : Submarine.Position + Position,
|
||||
ToolBox.RandomSeed(8), createNetworkEvent: false);
|
||||
onSpawn?.Invoke(character);
|
||||
return character;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Queue<IEntitySpawnInfo> spawnQueue;
|
||||
private readonly Queue<Entity> removeQueue;
|
||||
|
||||
@@ -134,6 +167,32 @@ namespace Barotrauma
|
||||
spawnQueue.Enqueue(new ItemSpawnInfo(itemPrefab, inventory, condition));
|
||||
}
|
||||
|
||||
public void AddToSpawnQueue(string speciesName, Vector2 worldPosition, Action<Character> onSpawn = null)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
if (string.IsNullOrEmpty(speciesName))
|
||||
{
|
||||
string errorMsg = "Attempted to add an empty/null species name to entity spawn queue.\n" + Environment.StackTrace;
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue4:SpeciesNameNullOrEmpty", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new CharacterSpawnInfo(speciesName, worldPosition, onSpawn));
|
||||
}
|
||||
|
||||
public void AddToSpawnQueue(string speciesName, Vector2 position, Submarine sub, Action<Character> onSpawn = null)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
if (string.IsNullOrEmpty(speciesName))
|
||||
{
|
||||
string errorMsg = "Attempted to add an empty/null species name to entity spawn queue.\n" + Environment.StackTrace;
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue5:SpeciesNameNullOrEmpty", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new CharacterSpawnInfo(speciesName, position, sub, onSpawn));
|
||||
}
|
||||
|
||||
public void AddToRemoveQueue(Entity entity)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Barotrauma.Networking
|
||||
public const float ItemConditionUpdateInterval = 0.15f;
|
||||
public const float LevelObjectUpdateInterval = 0.5f;
|
||||
public const float HullUpdateInterval = 0.5f;
|
||||
public const float SparseHullUpdateInterval = 5.0f;
|
||||
public const float HullUpdateDistance = 20000.0f;
|
||||
|
||||
public const int MaxEventPacketsPerUpdate = 4;
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace Barotrauma.Networking
|
||||
STARTGAME, //start a new round
|
||||
ENDGAME,
|
||||
|
||||
TRAITOR_MESSAGE
|
||||
TRAITOR_MESSAGE,
|
||||
MISSION
|
||||
}
|
||||
enum ServerNetObject
|
||||
{
|
||||
@@ -152,12 +153,10 @@ namespace Barotrauma.Networking
|
||||
protected RespawnManager respawnManager;
|
||||
|
||||
public bool ShowNetStats;
|
||||
|
||||
#if DEBUG
|
||||
|
||||
public float SimulatedRandomLatency, SimulatedMinimumLatency;
|
||||
public float SimulatedLoss;
|
||||
public float SimulatedDuplicatesChance;
|
||||
#endif
|
||||
|
||||
public int TickRate
|
||||
{
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
get
|
||||
{
|
||||
return IPEndPoint.Address.IsIPv4MappedToIPv6 ? IPEndPoint.Address.MapToIPv4().ToString() : IPEndPoint.Address.ToString();
|
||||
return IPEndPoint.Address.IsIPv4MappedToIPv6 ? IPEndPoint.Address.MapToIPv4NoThrow().ToString() : IPEndPoint.Address.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (type.HasFlag(MessageType.Chat))
|
||||
{
|
||||
Text = $"[{DateTime.Now.ToString()}] {text}";
|
||||
Text = $"[{DateTime.Now.ToString()}]\n {text}";
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = $"[{DateTime.Now.ToString()}] {TextManager.GetServerMessage(text)}";
|
||||
Text = $"[{DateTime.Now.ToString()}]\n {TextManager.GetServerMessage(text)}";
|
||||
}
|
||||
|
||||
Type = type;
|
||||
@@ -101,7 +101,7 @@ namespace Barotrauma.Networking
|
||||
lines.Enqueue(newText);
|
||||
|
||||
#if CLIENT
|
||||
if (LogFrame != null)
|
||||
if (listBox != null)
|
||||
{
|
||||
AddLine(newText);
|
||||
|
||||
|
||||
@@ -28,6 +28,15 @@ namespace Barotrauma.Networking
|
||||
Normal, Fill
|
||||
}
|
||||
|
||||
public enum PlayStyle
|
||||
{
|
||||
Serious = 0,
|
||||
Casual = 1,
|
||||
Roleplay = 2,
|
||||
Rampage = 3,
|
||||
SomethingDifferent = 4
|
||||
}
|
||||
|
||||
partial class ServerSettings : ISerializableEntity
|
||||
{
|
||||
public const string SettingsFile = "serversettings.xml";
|
||||
@@ -82,10 +91,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
partial class NetPropertyData
|
||||
{
|
||||
private SerializableProperty property;
|
||||
private string typeString;
|
||||
|
||||
private object parentObject;
|
||||
private readonly SerializableProperty property;
|
||||
private readonly string typeString;
|
||||
private readonly object parentObject;
|
||||
|
||||
public string Name
|
||||
{
|
||||
@@ -257,7 +265,7 @@ namespace Barotrauma.Networking
|
||||
private set;
|
||||
}
|
||||
|
||||
Dictionary<UInt32, NetPropertyData> netProperties;
|
||||
private readonly Dictionary<UInt32, NetPropertyData> netProperties;
|
||||
|
||||
partial void InitProjSpecific();
|
||||
|
||||
@@ -348,7 +356,6 @@ namespace Barotrauma.Networking
|
||||
|
||||
public Dictionary<ItemPrefab, int> ExtraCargo { get; private set; }
|
||||
|
||||
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
|
||||
private float selectedLevelDifficulty;
|
||||
private byte[] password;
|
||||
|
||||
@@ -481,6 +488,18 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
private PlayStyle playstyleSelection;
|
||||
[Serialize(PlayStyle.Serious, true)]
|
||||
public PlayStyle PlayStyle
|
||||
{
|
||||
get { return playstyleSelection; }
|
||||
set
|
||||
{
|
||||
playstyleSelection = value;
|
||||
ServerDetailsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(800, true)]
|
||||
private int LinesPerLogFile
|
||||
{
|
||||
@@ -603,6 +622,20 @@ namespace Barotrauma.Networking
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
[Serialize("", true)]
|
||||
public string SelectedSubmarine
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
[Serialize("", true)]
|
||||
public string SelectedShuttle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private YesNoMaybe traitorsEnabled;
|
||||
[Serialize(YesNoMaybe.No, true)]
|
||||
public YesNoMaybe TraitorsEnabled
|
||||
@@ -744,7 +777,7 @@ namespace Barotrauma.Networking
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize("Random", true)]
|
||||
[Serialize("All", true)]
|
||||
public string MissionType
|
||||
{
|
||||
get;
|
||||
|
||||
Reference in New Issue
Block a user