v1.4.4.1 (Blood in the Water Update)

This commit is contained in:
Regalis11
2024-04-24 18:09:05 +03:00
parent 89b91d1c3e
commit ff1b8951a7
397 changed files with 15250 additions and 6479 deletions
@@ -32,6 +32,12 @@ namespace Barotrauma.Networking
public const float SpeakRange = 2000.0f;
/// <summary>
/// This is shorter than the text chat speak range, because the voice chat is still intelligible (just quiet) close to the maximum range,
/// while the text chat (which drops letters from the message) becomes unintelligible sooner
/// </summary>
public const float SpeakRangeVOIP = 1000.0f;
private static readonly string dateTimeFormatLongTimePattern = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
public static Color[] MessageColor =
@@ -162,7 +162,8 @@ namespace Barotrauma
{ typeof(AccountId), new ReadWriteBehavior<AccountId>(ReadAccountId, WriteAccountId) },
{ typeof(Color), new ReadWriteBehavior<Color>(ReadColor, WriteColor) },
{ typeof(Vector2), new ReadWriteBehavior<Vector2>(ReadVector2, WriteVector2) },
{ typeof(SerializableDateTime), new ReadWriteBehavior<SerializableDateTime>(ReadSerializableDateTime, WriteSerializableDateTime) }
{ typeof(SerializableDateTime), new ReadWriteBehavior<SerializableDateTime>(ReadSerializableDateTime, WriteSerializableDateTime) },
{ typeof(NetLimitedString), new ReadWriteBehavior<NetLimitedString>(ReadNetLString, WriteNetLString) }
};
private static readonly ImmutableDictionary<Predicate<Type>, Func<Type, IReadWriteBehavior>> BehaviorFactories = new Dictionary<Predicate<Type>, Func<Type, IReadWriteBehavior>>
@@ -458,6 +459,12 @@ namespace Barotrauma
private static double ReadDouble(IReadMessage inc, NetworkSerialize attribute, ReadOnlyBitField bitField) => inc.ReadDouble();
private static void WriteDouble(double b, NetworkSerialize attribute, IWriteMessage msg, WriteOnlyBitField bitField) { msg.WriteDouble(b); }
// We do not validate that the string read is within the max length, but do we need to?
// Modified client could send a network message with a really long string when we use NetLimitedString
// but they could also just do that for any other network message.
private static NetLimitedString ReadNetLString(IReadMessage inc, NetworkSerialize attribute, ReadOnlyBitField bitField) => new NetLimitedString(inc.ReadString());
private static void WriteNetLString(NetLimitedString b, NetworkSerialize attribute, IWriteMessage msg, WriteOnlyBitField bitField) { msg.WriteString(b.Value); }
private static string ReadString(IReadMessage inc, NetworkSerialize attribute, ReadOnlyBitField bitField) => inc.ReadString();
private static void WriteString(string b, NetworkSerialize attribute, IWriteMessage msg, WriteOnlyBitField bitField) { msg.WriteString(b); }
@@ -685,6 +692,7 @@ namespace Barotrauma
/// <see cref="Single">float</see><br/>
/// <see cref="Double">double</see><br/>
/// <see cref="String">string</see><br/>
/// <see cref="Barotrauma.NetLimitedString"></see><br/>
/// <see cref="Barotrauma.Networking.AccountId"/><br/>
/// <see cref="System.Collections.Immutable.ImmutableArray{T}"></see><br/>
/// <see cref="Microsoft.Xna.Framework.Color"/><br/>
@@ -210,15 +210,7 @@ namespace Barotrauma.Networking
AddChatMessage(ChatMessage.Create(senderName, message, type, senderCharacter, senderClient, changeType: changeType, textColor: textColor));
}
public virtual void AddChatMessage(ChatMessage message)
{
if (string.IsNullOrEmpty(message.Text)) { return; }
if (message.Sender != null && !message.Sender.IsDead)
{
message.Sender.ShowSpeechBubble(2.0f, message.Color);
}
}
public abstract void AddChatMessage(ChatMessage message);
public static string ClientLogName(Client client, string name = null)
{
@@ -31,7 +31,9 @@ namespace Barotrauma.Networking
/// </summary>
public OrderChatMessage(Order order, Character targetCharacter, Character sender, bool isNewOrder = true)
: this(order,
order?.GetChatMessage(targetCharacter?.Name, (order.TargetEntity as Hull ?? sender?.CurrentHull)?.DisplayName?.Value, givingOrderToSelf: targetCharacter == sender, orderOption: order.Option, isNewOrder: isNewOrder),
order?.GetChatMessage(targetCharacter?.Name,
(order.TargetEntity as Hull ?? sender?.CurrentHull)?.DisplayName?.Value,
givingOrderToSelf: targetCharacter == sender, orderOption: order.Option, isNewOrder: isNewOrder),
targetCharacter, sender, isNewOrder)
{
@@ -68,6 +68,7 @@ namespace Barotrauma.Networking
{
public string ServerName;
public ImmutableArray<ServerContentPackage> ContentPackages;
public bool AllowModDownloads;
}
[NetworkSerialize(ArrayMaxSize = ushort.MaxValue)]
@@ -14,7 +14,14 @@ namespace Barotrauma.Networking
/// <summary>
/// How much skills drop towards the job's default skill levels when dying
/// </summary>
public static float SkillLossPercentageOnDeath => GameMain.NetworkMember?.ServerSettings?.SkillLossPercentageOnDeath ?? 50.0f;
public static float SkillLossPercentageOnDeath => GameMain.NetworkMember?.ServerSettings?.SkillLossPercentageOnDeath ?? 20.0f;
/// <summary>
/// How much more the skills drop towards the job's default skill levels
/// when dying, in addition to SkillLossPercentageOnDeath, if the player
/// chooses to respawn in the middle of the round
/// </summary>
public static float SkillLossPercentageOnImmediateRespawn => GameMain.NetworkMember?.ServerSettings?.SkillLossPercentageOnImmediateRespawn ?? 10.0f;
public enum State
{
@@ -76,6 +83,10 @@ namespace Barotrauma.Networking
private float updateReturnTimer;
public bool CanRespawnAgain =>
/*can never respawn again if we're currently transporting and transport time is set to be infinite*/
!(CurrentState == State.Transporting && maxTransportTime <= 0.0f);
public Submarine RespawnShuttle { get; private set; }
public RespawnManager(NetworkMember networkMember, SubmarineInfo shuttleInfo)
@@ -88,7 +99,7 @@ namespace Barotrauma.Networking
RespawnShuttle = new Submarine(shuttleInfo, true);
RespawnShuttle.PhysicsBody.FarseerBody.OnCollision += OnShuttleCollision;
//set crush depth slightly deeper than the main sub's
RespawnShuttle.RealWorldCrushDepth = Math.Max(RespawnShuttle.RealWorldCrushDepth, Submarine.MainSub.RealWorldCrushDepth * 1.2f);
RespawnShuttle.SetCrushDepth(Math.Max(RespawnShuttle.RealWorldCrushDepth, Submarine.MainSub.RealWorldCrushDepth * 1.2f));
//prevent wifi components from communicating between the respawn shuttle and other subs
List<WifiComponent> wifiComponents = new List<WifiComponent>();
@@ -340,25 +351,6 @@ namespace Barotrauma.Networking
RespawnCharactersProjSpecific(shuttlePos);
}
public static AfflictionPrefab GetRespawnPenaltyAfflictionPrefab()
{
return AfflictionPrefab.Prefabs.First(a => a.AfflictionType == "respawnpenalty");
}
public static Affliction GetRespawnPenaltyAffliction()
{
return GetRespawnPenaltyAfflictionPrefab()?.Instantiate(10.0f);
}
public static void GiveRespawnPenaltyAffliction(Character character)
{
var respawnPenaltyAffliction = GetRespawnPenaltyAffliction();
if (respawnPenaltyAffliction != null)
{
character.CharacterHealth.ApplyAffliction(targetLimb: null, respawnPenaltyAffliction);
}
}
public Vector2 FindSpawnPos()
{
if (Level.Loaded == null || Submarine.MainSub == null) { return Vector2.Zero; }
@@ -49,8 +49,6 @@ namespace Barotrauma.Networking
public enum NetFlags : byte
{
None = 0x0,
Name = 0x1,
Message = 0x2,
Properties = 0x4,
Misc = 0x8,
LevelSeed = 0x10,
@@ -320,24 +318,26 @@ namespace Barotrauma.Networking
}
}
private string serverName;
private string serverName = string.Empty;
[Serialize("", IsPropertySaveable.Yes)]
public string ServerName
{
get { return serverName; }
set
{
string val = value;
if (val.Length > NetConfig.ServerNameMaxLength) { val = val.Substring(0, NetConfig.ServerNameMaxLength); }
if (serverName == val) { return; }
serverName = val;
string newName = value;
if (newName.Length > NetConfig.ServerNameMaxLength) { newName = newName.Substring(0, NetConfig.ServerNameMaxLength); }
if (serverName == newName) { return; }
if (newName.IsNullOrWhiteSpace()) { return; }
serverName = newName;
ServerDetailsChanged = true;
#if SERVER
UpdateFlag(NetFlags.Name);
#endif
}
}
private string serverMessageText;
[Serialize("", IsPropertySaveable.Yes)]
public string ServerMessageText
{
get { return serverMessageText; }
@@ -346,11 +346,11 @@ namespace Barotrauma.Networking
string val = value;
if (val.Length > NetConfig.ServerMessageMaxLength) { val = val.Substring(0, NetConfig.ServerMessageMaxLength); }
if (serverMessageText == val) { return; }
#if SERVER
GameMain.Server?.SendChatMessage(TextManager.AddPunctuation(':', TextManager.Get("servermotd"), val).Value, ChatMessageType.Server);
#endif
serverMessageText = val;
ServerDetailsChanged = true;
#if SERVER
UpdateFlag(NetFlags.Message);
#endif
}
}
@@ -433,7 +433,7 @@ namespace Barotrauma.Networking
private set;
}
[Serialize(50f, IsPropertySaveable.Yes)]
[Serialize(20f, IsPropertySaveable.Yes)]
/// <summary>
/// How much skills drop towards the job's default skill levels when dying
/// </summary>
@@ -443,6 +443,18 @@ namespace Barotrauma.Networking
private set;
}
[Serialize(10f, IsPropertySaveable.Yes)]
/// <summary>
/// How much more the skills drop towards the job's default skill levels
/// when dying, in addition to SkillLossPercentageOnDeath, if the player
/// chooses to respawn in the middle of the round
/// </summary>
public float SkillLossPercentageOnImmediateRespawn
{
get;
private set;
}
[Serialize(60.0f, IsPropertySaveable.Yes)]
public float AutoRestartInterval
{
@@ -550,6 +562,7 @@ namespace Barotrauma.Networking
}
}
[Serialize(false, IsPropertySaveable.Yes)]
public bool AutoRestart
{
get { return autoRestart; }
@@ -625,6 +638,7 @@ namespace Barotrauma.Networking
set;
}
[Serialize(0.0f, IsPropertySaveable.Yes)]
public float SelectedLevelDifficulty
{
get { return selectedLevelDifficulty; }
@@ -753,13 +767,18 @@ namespace Barotrauma.Networking
if (traitorDangerLevel == clampedValue) { return; }
traitorDangerLevel = clampedValue;
ServerDetailsChanged = true;
#if CLIENT
GameMain.NetLobbyScreen?.SetTraitorDangerLevel(traitorDangerLevel);
#endif
}
}
private int traitorsMinPlayerCount;
[Serialize(defaultValue: 1, isSaveable: IsPropertySaveable.Yes)]
public int TraitorsMinPlayerCount
{
get;
set;
get { return traitorsMinPlayerCount; }
set { traitorsMinPlayerCount = MathHelper.Clamp(value, 1, NetConfig.MaxPlayers); }
}
[Serialize(defaultValue: 50.0f, isSaveable: IsPropertySaveable.Yes)]
@@ -865,7 +884,11 @@ namespace Barotrauma.Networking
{
karmaEnabled = value;
#if CLIENT
if (karmaSettingsBlocker != null) { karmaSettingsBlocker.Visible = !karmaEnabled || karmaPresetDD.SelectedData as string != "custom"; }
if (karmaSettingsList != null)
{
SetElementInteractability(karmaSettingsList.Content, !karmaEnabled || KarmaPreset != "custom");
}
karmaElements.ForEach(e => e.Visible = karmaEnabled);
#endif
}
}
@@ -1035,8 +1058,9 @@ namespace Barotrauma.Networking
.OrderBy(k => CharacterPrefab.Prefabs[k].UintIdentifier)
.ToImmutableArray();
public void ReadMonsterEnabled(IReadMessage inc)
public bool ReadMonsterEnabled(IReadMessage inc)
{
bool changed = false;
InitMonstersEnabled();
var monsterNames = ExtractAndSortKeys(MonsterEnabled);
uint receivedMonsterCount = inc.ReadVariableUInt32();
@@ -1049,10 +1073,13 @@ namespace Barotrauma.Networking
{
foreach (Identifier s in monsterNames)
{
MonsterEnabled.TryGetValue(s, out bool prevEnabled);
MonsterEnabled[s] = inc.ReadBoolean();
changed |= prevEnabled != MonsterEnabled[s];
}
}
inc.ReadPadBits();
return changed;
}
public void WriteMonsterEnabled(IWriteMessage msg, Dictionary<Identifier, bool> monsterEnabled = null)