Release 1.11.4.1 (Winter Update)

This commit is contained in:
Markus Isberg
2025-12-08 14:56:47 +00:00
parent 21e34e5cd8
commit 598966f200
121 changed files with 1614 additions and 819 deletions
@@ -53,7 +53,7 @@ namespace Barotrauma
{
if (!Enabled) { return 1000.0f; }
Vector2 comparePosition = recipient.SpectatePos == null ? recipient.Character.WorldPosition : recipient.SpectatePos.Value;
Vector2 comparePosition = recipient.SpectatePos ?? recipient.Character.WorldPosition;
float distance = Vector2.Distance(comparePosition, WorldPosition);
if (recipient.Character?.ViewTarget != null)
@@ -199,7 +199,9 @@ namespace Barotrauma
UInt16 networkUpdateID = msg.ReadUInt16();
byte inputCount = msg.ReadByte();
if (AllowInput) { Enabled = true; }
// Doesn't seem to work consistently (at least with simulated long loading time 120), because sometimes there's some stun on the character. Anyway, can't see why we'd have to check AllowInput here.
//if (AllowInput) { Enabled = true; }
Enabled = true;
for (int i = 0; i < inputCount; i++)
{
@@ -798,9 +800,7 @@ namespace Barotrauma
if (msg.LengthBytes - initialMsgLength >= 255 && restrictMessageSize)
{
string errorMsg = $"Error when writing character spawn data for \"{Name}\": data exceeded 255 bytes (info: {infoLength}, orders: {ordersLength}, total: {msg.LengthBytes - initialMsgLength})";
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Character.WriteSpawnData:TooMuchData", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
DebugConsole.AddWarning($"Character spawn data for \"{Name}\" exceeded 255 bytes (info: {infoLength}, orders: {ordersLength}, total: {msg.LengthBytes - initialMsgLength})");
}
TryWriteStatus(msg);
@@ -816,9 +816,7 @@ namespace Barotrauma
msg.WriteBoolean(false);
if (msgLengthBeforeStatus < 255)
{
string errorMsg = $"Error when writing character spawn data for \"{Name}\": status data caused the length of the message to exceed 255 bytes ({msgLengthBeforeStatus} + {tempBuffer.LengthBytes})";
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Character.WriteSpawnData:TooMuchDataForStatus", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
DebugConsole.ThrowError($"Character spawn data for \"{Name}\" caused the length of the message to exceed 255 bytes ({msgLengthBeforeStatus} + {tempBuffer.LengthBytes})");
}
}
else
@@ -278,7 +278,14 @@ namespace Barotrauma
characterInfo.ApplyDeathEffects();
}
c.CharacterInfo = characterInfo;
SetClientCharacterData(c);
// Only create new character data if the connected client has an active character (which they might not,
// eg. if they are in the lobby). Otherwise the CharacterCampaignData constructor would fall back to a new
// Character object, overwriting the inventory and wallet with empty values.
if (c.Character != null)
{
SetClientCharacterData(c);
}
}
//refresh the character data of clients who aren't in the server anymore
@@ -1105,10 +1112,6 @@ namespace Barotrauma
bool predicate(SoldItem i) => allowedToSellInventoryItems != (i.Origin == SoldItem.SellOrigin.Character);
}
}
else
{
GameServer.Log($"{sender.Name} attempted to buy or sell items without having access to a store NPC.", ServerLog.MessageType.Error);
}
if ((purchasedUpgrades.Any() || purchasedItemSwaps.Any()) &&
HasCampaignInteractionAvailable(sender, InteractionType.Upgrade))
@@ -1142,10 +1145,6 @@ namespace Barotrauma
}
}
}
else
{
GameServer.Log($"{sender.Name} attempted to buy upgrades without having access to an NPC offering upgrades.", ServerLog.MessageType.Error);
}
}
private bool HasCampaignInteractionAvailable(Client sender, InteractionType interactionType)
@@ -0,0 +1,48 @@
using Barotrauma.Networking;
using System.Collections.Generic;
namespace Barotrauma.Items.Components
{
partial class ConnectionSelectorComponent : ItemComponent
{
private CoroutineHandle sendStateCoroutine;
private int lastSentConnectionIndex;
private float sendStateTimer;
partial void OnStateChanged()
{
sendStateTimer = 0.5f;
if (sendStateCoroutine == null)
{
sendStateCoroutine = CoroutineManager.StartCoroutine(SendStateAfterDelay());
}
}
private IEnumerable<CoroutineStatus> SendStateAfterDelay()
{
while (sendStateTimer > 0.0f)
{
sendStateTimer -= CoroutineManager.DeltaTime;
yield return CoroutineStatus.Running;
}
if (item.Removed || GameMain.NetworkMember == null)
{
yield return CoroutineStatus.Success;
}
sendStateCoroutine = null;
if (lastSentConnectionIndex != selectedConnectionIndex)
{
item.CreateServerEvent(this);
}
yield return CoroutineStatus.Success;
}
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
{
msg.WriteRangedInteger(selectedConnectionIndex, 0, 255);
lastSentConnectionIndex = selectedConnectionIndex;
}
}
}
@@ -1845,6 +1845,9 @@ namespace Barotrauma.Networking
}
else
{
//client presumably isn't afk if they clicked to start a round
sender.AFK = false;
bool continueCampaign = inc.ReadBoolean();
if (mpCampaign != null && mpCampaign.GameOver || continueCampaign)
{
@@ -2030,7 +2033,8 @@ namespace Barotrauma.Networking
}
}
if (!FileSender.ActiveTransfers.Any(t => t.Connection == c.Connection && t.FileType == FileTransferType.CampaignSave))
//don't send the campaign save if there's any other transfers running (client waiting for subs, mods, or already transferring the campaign save)
if (FileSender.ActiveTransfers.None(t => t.Connection == c.Connection))
{
FileSender.StartTransfer(c.Connection, FileTransferType.CampaignSave, GameMain.GameSession.DataPath.SavePath);
c.LastCampaignSaveSendTime = (campaign.LastSaveID, (float)NetTime.Now);
@@ -3057,7 +3061,7 @@ namespace Barotrauma.Networking
WayPoint jobItemSpawnPoint = mainSubWaypoints != null ? mainSubWaypoints[i] : spawnWaypoints[i];
Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, spawnWaypoints[i].WorldPosition, teamClients[i].CharacterInfo.Name, isRemotePlayer: true, hasAi: false);
spawnedCharacter.AnimController.Frozen = true;
//spawnedCharacter.AnimController.Frozen = true;
spawnedCharacter.TeamID = teamID;
teamClients[i].Character = spawnedCharacter;
var characterData = campaign?.GetClientCharacterData(teamClients[i]);
@@ -4302,7 +4306,7 @@ namespace Barotrauma.Networking
public void SetClientCharacter(Client client, Character newCharacter)
{
if (client == null) return;
if (client == null) { return; }
//the client's previous character is no longer a remote player
if (client.Character != null)
@@ -4328,13 +4332,14 @@ namespace Barotrauma.Networking
newCharacter.LastNetworkUpdateID = client.Character.LastNetworkUpdateID;
}
if (newCharacter.Info != null && newCharacter.Info.Character == null)
if (newCharacter.Info is { Character: null })
{
newCharacter.Info.Character = newCharacter;
}
newCharacter.SetOwnerClient(client);
newCharacter.Enabled = true;
newCharacter.AnimController.Frozen = false;
client.Character = newCharacter;
client.CharacterInfo = newCharacter.Info;
CreateEntityEvent(newCharacter, new Character.ControlEventData(client));
@@ -128,11 +128,11 @@ namespace Barotrauma.Networking
//remove old events that have been sent to all clients, they are redundant now
// keep at least one event in the list (lastSentToAll == e.ID) so we can use it to keep track of the latest ID
// and events less than 15 seconds old to give disconnected clients a bit of time to reconnect without getting desynced
if (GameMain.GameSession.RoundDuration > NetConfig.RoundStartSyncDuration)
if (GameMain.GameSession.RoundDuration > server.ServerSettings.RoundStartSyncDuration)
{
events.RemoveAll(e =>
(NetIdUtils.IdMoreRecent(lastSentToAll, e.ID) || !inGameClientsPresent) &&
e.CreateTime < Timing.TotalTime - NetConfig.EventRemovalTime);
e.CreateTime < Timing.TotalTime - server.ServerSettings.EventRemovalTime);
}
for (int i = events.Count - 1; i >= 0; i--)
@@ -226,7 +226,7 @@ namespace Barotrauma.Networking
if (Timing.TotalTime - lastWarningTime > 5.0 &&
Timing.TotalTime - lastSentToAnyoneTime > 10.0 &&
GameMain.GameSession.RoundDuration > NetConfig.RoundStartSyncDuration)
GameMain.GameSession.RoundDuration > server.ServerSettings.RoundStartSyncDuration)
{
lastWarningTime = Timing.TotalTime;
string warningMsg = $"WARNING: ServerEntityEventManager is lagging behind! Last sent id: {lastSentToAnyone}, latest create id: {ID}";
@@ -240,8 +240,8 @@ namespace Barotrauma.Networking
ServerEntityEvent firstEventToResend = events.Find(e => e.ID == (ushort)(lastSentToAll + 1));
if (firstEventToResend != null &&
GameMain.GameSession.RoundDuration > NetConfig.RoundStartSyncDuration &&
((lastSentToAnyoneTime - firstEventToResend.CreateTime) > NetConfig.OldReceivedEventKickTime || (Timing.TotalTime - firstEventToResend.CreateTime) > NetConfig.OldEventKickTime))
GameMain.GameSession.RoundDuration > server.ServerSettings.RoundStartSyncDuration &&
((lastSentToAnyoneTime - firstEventToResend.CreateTime) > server.ServerSettings.OldReceivedEventKickTime || (Timing.TotalTime - firstEventToResend.CreateTime) > server.ServerSettings.OldEventKickTime))
{
// This event is 10 seconds older than the last one we've successfully sent,
// kick everyone that hasn't received it yet, this is way too old
@@ -55,13 +55,13 @@ namespace Barotrauma.Networking
PasswordRetries = 0;
PasswordSalt = null;
UpdateTime = Timing.TotalTime + Timing.Step * 3.0;
TimeOut = NetworkConnection.TimeoutThreshold;
TimeOut = NetworkConnection.TimeoutThresholdNotInGame;
AuthSessionStarted = false;
}
public void Heartbeat()
{
TimeOut = NetworkConnection.TimeoutThreshold;
TimeOut = NetworkConnection.TimeoutThresholdNotInGame;
}
}
@@ -124,7 +124,7 @@ namespace Barotrauma.Networking
protected void ReadConnectionInitializationStep(PendingClient pendingClient, IReadMessage inc, ConnectionInitialization initializationStep)
{
pendingClient.TimeOut = NetworkConnection.TimeoutThreshold;
pendingClient.TimeOut = NetworkConnection.TimeoutThresholdNotInGame;
if (pendingClient.InitializationStep != initializationStep) { return; }