Unstable 0.16.5.0

This commit is contained in:
Markus Isberg
2022-02-17 00:03:08 +09:00
parent 2190fe08ef
commit a0696ecb74
51 changed files with 197 additions and 96 deletions
@@ -430,11 +430,14 @@ namespace Barotrauma
if (avgUpdateRate < Timing.FixedUpdateRate * 0.98 && GameSession != null && Timing.TotalTime > GameSession.RoundStartTime + 1.0)
{
DebugConsole.AddWarning($"Running slowly ({avgUpdateRate} updates/s)!");
foreach (Client c in Server.ConnectedClients)
if (Server != null)
{
if (c.Connection == Server.OwnerConnection || c.Permissions != ClientPermissions.None)
foreach (Client c in Server.ConnectedClients)
{
Server.SendConsoleMessage($"Server running slowly ({avgUpdateRate} updates/s)!", c, Color.Orange);
if (c.Connection == Server.OwnerConnection || c.Permissions != ClientPermissions.None)
{
Server.SendConsoleMessage($"Server running slowly ({avgUpdateRate} updates/s)!", c, Color.Orange);
}
}
}
}
@@ -212,7 +212,14 @@ namespace Barotrauma
}
//use the info of the character the client is currently controlling
// or the previously saved info if not (e.g. if the client has been spectating or died)
var characterInfo = c.Character?.Info ?? characterData.Find(d => d.MatchesClient(c))?.CharacterInfo;
var characterInfo = c.Character?.Info;
var matchingCharacterData = characterData.Find(d => d.MatchesClient(c));
if (matchingCharacterData != null)
{
//hasn't spawned this round -> don't touch the data
if (!matchingCharacterData.HasSpawned) { continue; }
characterInfo ??= matchingCharacterData.CharacterInfo;
}
if (characterInfo == null) { continue; }
//reduce skills if the character has died
if (characterInfo.CauseOfDeath != null && characterInfo.CauseOfDeath.Type != CauseOfDeathType.Disconnected)
@@ -117,8 +117,14 @@ namespace Barotrauma.Networking
{
GameMain.Server.VoipServer.UnregisterQueue(VoipQueue);
VoipQueue.Dispose();
characterInfo?.Remove();
characterInfo = null;
if (characterInfo != null)
{
if (characterInfo.Character == null || characterInfo.Character.Removed)
{
characterInfo?.Remove();
characterInfo = null;
}
}
}
public void InitClientSync()
@@ -857,6 +857,12 @@ namespace Barotrauma.Networking
case ClientNetError.MISSING_ENTITY:
UInt16 eventID = inc.ReadUInt16();
UInt16 entityID = inc.ReadUInt16();
byte subCount = inc.ReadByte();
List<string> subNames = new List<string>();
for (int i = 0; i < subCount; i++)
{
subNames.Add(inc.ReadString());
}
Entity entity = Entity.FindEntityByID(entityID);
if (entity == null)
{
@@ -875,6 +881,13 @@ namespace Barotrauma.Networking
{
errorStr = errorStrNoName = $"Missing entity {entity}, sub: {entity.Submarine?.Info?.Name ?? "none"} (event id {eventID}, entity id {entityID}).";
}
var serverSubNames = Submarine.Loaded.Select(s => s.Info.Name);
if (subCount != Submarine.Loaded.Count || !subNames.SequenceEqual(serverSubNames))
{
string subErrorStr = $" Loaded submarines don't match (client: {string.Join(", ", subNames)}, server: {string.Join(", ", serverSubNames)}).";
errorStr += subErrorStr;
errorStrNoName += subErrorStr;
}
break;
}
@@ -1850,9 +1863,10 @@ namespace Barotrauma.Networking
}
outmsg.Write(GameMain.NetLobbyScreen.SelectedSub.Name);
outmsg.Write(GameMain.NetLobbyScreen.SelectedSub.MD5Hash.ToString());
outmsg.Write(serverSettings.UseRespawnShuttle);
outmsg.Write(GameMain.NetLobbyScreen.SelectedShuttle.Name);
outmsg.Write(GameMain.NetLobbyScreen.SelectedShuttle.MD5Hash.ToString());
outmsg.Write(serverSettings.UseRespawnShuttle || (gameStarted && respawnManager.UsingShuttle));
var selectedShuttle = gameStarted && respawnManager.UsingShuttle ? respawnManager.RespawnShuttle.Info : GameMain.NetLobbyScreen.SelectedShuttle;
outmsg.Write(selectedShuttle.Name);
outmsg.Write(selectedShuttle.MD5Hash.ToString());
outmsg.Write(serverSettings.Voting.AllowSubVoting);
outmsg.Write(serverSettings.Voting.AllowModeVoting);
@@ -2031,7 +2045,7 @@ namespace Barotrauma.Networking
msg.Write(selectedSub.Name);
msg.Write(selectedSub.MD5Hash.Hash);
msg.Write(serverSettings.UseRespawnShuttle);
msg.Write(serverSettings.UseRespawnShuttle || (gameStarted && respawnManager.UsingShuttle));
msg.Write(selectedShuttle.Name);
msg.Write(selectedShuttle.MD5Hash.Hash);
@@ -2468,8 +2482,9 @@ namespace Barotrauma.Networking
msg.Write(serverSettings.SelectedLevelDifficulty);
msg.Write(gameSession.SubmarineInfo.Name);
msg.Write(gameSession.SubmarineInfo.MD5Hash.Hash);
msg.Write(GameMain.NetLobbyScreen.SelectedShuttle.Name);
msg.Write(GameMain.NetLobbyScreen.SelectedShuttle.MD5Hash.Hash);
var selectedShuttle = gameStarted && respawnManager.UsingShuttle ? respawnManager.RespawnShuttle.Info : GameMain.NetLobbyScreen.SelectedShuttle;
msg.Write(selectedShuttle.Name);
msg.Write(selectedShuttle.MD5Hash.Hash);
msg.Write((byte)GameMain.GameSession.GameMode.Missions.Count());
foreach (Mission mission in GameMain.GameSession.GameMode.Missions)
{