(d9829ac) v0.9.4.0
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
public const int MaxNameLength = 20;
|
||||
|
||||
public string Name;
|
||||
public string Name; public UInt16 NameID;
|
||||
public byte ID;
|
||||
public UInt64 SteamID;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Barotrauma.Networking
|
||||
if (!File.Exists(file)) { return; }
|
||||
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
if (doc == null || doc.Root == null) { return; }
|
||||
if (doc == null) { return; }
|
||||
|
||||
List.Clear();
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
|
||||
@@ -94,7 +94,23 @@ namespace Barotrauma
|
||||
|
||||
public KarmaManager()
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(ConfigFile);
|
||||
XDocument doc = null;
|
||||
int maxLoadRetries = 4;
|
||||
for (int i = 0; i <= maxLoadRetries; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
doc = XMLExtensions.TryLoadXml(ConfigFile);
|
||||
break;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (i == maxLoadRetries) { break; }
|
||||
DebugConsole.NewMessage("Opening karma settings file \"" + ConfigFile + "\" failed, retrying in 250 ms...");
|
||||
System.Threading.Thread.Sleep(250);
|
||||
}
|
||||
}
|
||||
|
||||
SerializableProperties = SerializableProperty.DeserializeProperties(this, doc?.Root);
|
||||
if (doc?.Root != null)
|
||||
{
|
||||
@@ -104,7 +120,7 @@ namespace Barotrauma
|
||||
string presetName = subElement.GetAttributeString("name", "");
|
||||
Presets[presetName.ToLowerInvariant()] = subElement;
|
||||
}
|
||||
SelectPreset("default");
|
||||
SelectPreset(GameMain.NetworkMember?.ServerSettings?.KarmaPreset ?? "default");
|
||||
}
|
||||
herpesAffliction = AfflictionPrefab.List.Find(ap => ap.Identifier == "spaceherpes");
|
||||
}
|
||||
@@ -118,13 +134,18 @@ namespace Barotrauma
|
||||
{
|
||||
SerializableProperty.DeserializeProperties(this, Presets[presetName]);
|
||||
}
|
||||
else if (Presets.ContainsKey("custom"))
|
||||
{
|
||||
SerializableProperty.DeserializeProperties(this, Presets["custom"]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveCustomPreset()
|
||||
{
|
||||
if (Presets.ContainsKey("custom"))
|
||||
{
|
||||
SerializableProperty.SerializeProperties(this, Presets["custom"]);
|
||||
SerializableProperty.SerializeProperties(this, Presets["custom"], saveIfDefault: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,9 +164,25 @@ namespace Barotrauma
|
||||
NewLineOnAttributes = true
|
||||
};
|
||||
|
||||
using (var writer = XmlWriter.Create(ConfigFile, settings))
|
||||
int maxLoadRetries = 4;
|
||||
for (int i = 0; i <= maxLoadRetries; i++)
|
||||
{
|
||||
doc.Save(writer);
|
||||
try
|
||||
{
|
||||
using (var writer = XmlWriter.Create(ConfigFile, settings))
|
||||
{
|
||||
doc.Save(writer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (i == maxLoadRetries) { throw; }
|
||||
|
||||
DebugConsole.NewMessage("Saving karma settings file file \"" + ConfigFile + "\" failed, retrying in 250 ms...");
|
||||
System.Threading.Thread.Sleep(250);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ namespace Barotrauma.Networking
|
||||
public const float HighPrioCharacterPositionUpdateInterval = 0.0f;
|
||||
public const float LowPrioCharacterPositionUpdateInterval = 1.0f;
|
||||
|
||||
//this should be higher than LowPrioCharacterPositionUpdateInterval,
|
||||
//otherwise the clients may freeze characters even though the server hasn't actually stopped sending position updates
|
||||
public const float FreezeCharacterIfPositionDataMissingDelay = 2.0f;
|
||||
public const float DisableCharacterIfPositionDataMissingDelay = 3.5f;
|
||||
|
||||
public const float DeleteDisconnectedTime = 20.0f;
|
||||
|
||||
public const float ItemConditionUpdateInterval = 0.15f;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (IdMoreRecent(min, max))
|
||||
{
|
||||
throw new ArgumentException("Min cannot be larger than max");
|
||||
throw new ArgumentException($"Min cannot be larger than max ({min}, {max})");
|
||||
}
|
||||
|
||||
if (!IdMoreRecent(id, min))
|
||||
|
||||
@@ -140,8 +140,6 @@ namespace Barotrauma.Networking
|
||||
public Dictionary<string, long> messageCount = new Dictionary<string, long>();
|
||||
#endif
|
||||
|
||||
protected string name;
|
||||
|
||||
protected ServerSettings serverSettings;
|
||||
|
||||
protected TimeSpan updateInterval;
|
||||
@@ -155,6 +153,12 @@ namespace Barotrauma.Networking
|
||||
|
||||
public bool ShowNetStats;
|
||||
|
||||
#if DEBUG
|
||||
public float SimulatedRandomLatency, SimulatedMinimumLatency;
|
||||
public float SimulatedLoss;
|
||||
public float SimulatedDuplicatesChance;
|
||||
#endif
|
||||
|
||||
public int TickRate
|
||||
{
|
||||
get { return serverSettings.TickRate; }
|
||||
@@ -171,16 +175,6 @@ namespace Barotrauma.Networking
|
||||
private set;
|
||||
} = new KarmaManager();
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) { return; }
|
||||
name = value.Replace(":", "").Replace(";", "");
|
||||
}
|
||||
}
|
||||
|
||||
public bool GameStarted
|
||||
{
|
||||
get { return gameStarted; }
|
||||
|
||||
@@ -623,6 +623,34 @@ namespace Barotrauma.Networking
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 90.0f, isSaveable: true)]
|
||||
public float TraitorsMinStartDelay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 180.0f, isSaveable: true)]
|
||||
public float TraitorsMaxStartDelay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 30.0f, isSaveable: true)]
|
||||
public float TraitorsMinRestartDelay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 90.0f, isSaveable: true)]
|
||||
public float TraitorsMaxRestartDelay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private SelectionMode subSelectionMode;
|
||||
[Serialize(SelectionMode.Manual, true)]
|
||||
public SelectionMode SubSelectionMode
|
||||
@@ -693,12 +721,21 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
private string karmaPreset = "default";
|
||||
[Serialize("default", true)]
|
||||
public string KarmaPreset
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = "default";
|
||||
get { return karmaPreset; }
|
||||
set
|
||||
{
|
||||
if (karmaPreset == value) { return; }
|
||||
if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient)
|
||||
{
|
||||
GameMain.NetworkMember?.KarmaManager?.SelectPreset(value);
|
||||
}
|
||||
karmaPreset = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize("sandbox", true)]
|
||||
public string GameModeIdentifier
|
||||
|
||||
Reference in New Issue
Block a user