Merge remote-tracking branch 'upstream/master' into develop
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Barotrauma.Networking
|
||||
public UInt16 LastRecvLobbyUpdate
|
||||
= NetIdUtils.GetIdOlderThan(GameMain.NetLobbyScreen.LastUpdateID);
|
||||
|
||||
public bool InitialLobbyUpdateSent;
|
||||
|
||||
public UInt16 LastSentChatMsgID = 0; //last msg this client said
|
||||
public UInt16 LastRecvChatMsgID = 0; //last msg this client knows about
|
||||
|
||||
@@ -166,8 +168,8 @@ namespace Barotrauma.Networking
|
||||
LastSentChatMsgID = 0;
|
||||
LastRecvChatMsgID = ChatMessage.LastID;
|
||||
|
||||
LastRecvLobbyUpdate = 0;
|
||||
|
||||
LastRecvLobbyUpdate = NetIdUtils.GetIdOlderThan(GameMain.NetLobbyScreen.LastUpdateID);
|
||||
InitialLobbyUpdateSent = false;
|
||||
LastRecvEntityEventID = 0;
|
||||
|
||||
UnreceivedEntityEventCount = 0;
|
||||
|
||||
@@ -1298,11 +1298,8 @@ namespace Barotrauma.Networking
|
||||
//check if midround syncing is needed due to missed unique events
|
||||
if (!midroundSyncingDone) { entityEventManager.InitClientMidRoundSync(c); }
|
||||
MissionAction.NotifyMissionsUnlockedThisRound(c);
|
||||
if (GameMain.GameSession.Campaign is MultiPlayerCampaign mpCampaign)
|
||||
{
|
||||
mpCampaign.SendCrewState();
|
||||
}
|
||||
else if (GameMain.GameSession.GameMode is PvPMode)
|
||||
|
||||
if (GameMain.GameSession.GameMode is PvPMode)
|
||||
{
|
||||
if (c.TeamID == CharacterTeamType.None)
|
||||
{
|
||||
@@ -1311,6 +1308,10 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GameMain.GameSession.Campaign is MultiPlayerCampaign mpCampaign)
|
||||
{
|
||||
mpCampaign.SendCrewState();
|
||||
}
|
||||
//everyone's in team 1 in non-pvp game modes
|
||||
c.TeamID = CharacterTeamType.Team1;
|
||||
}
|
||||
@@ -2251,12 +2252,13 @@ namespace Barotrauma.Networking
|
||||
outmsg.WriteUInt16((UInt16)settingsBuf.LengthBytes);
|
||||
outmsg.WriteBytes(settingsBuf.Buffer, 0, settingsBuf.LengthBytes);
|
||||
|
||||
outmsg.WriteBoolean(c.LastRecvLobbyUpdate < 1);
|
||||
if (c.LastRecvLobbyUpdate < 1)
|
||||
outmsg.WriteBoolean(!c.InitialLobbyUpdateSent);
|
||||
if (!c.InitialLobbyUpdateSent)
|
||||
{
|
||||
isInitialUpdate = true;
|
||||
initialUpdateBytes = outmsg.LengthBytes;
|
||||
ClientWriteInitial(c, outmsg);
|
||||
c.InitialLobbyUpdateSent = true;
|
||||
initialUpdateBytes = outmsg.LengthBytes - initialUpdateBytes;
|
||||
}
|
||||
outmsg.WriteString(GameMain.NetLobbyScreen.SelectedSub.Name);
|
||||
@@ -3135,6 +3137,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
msg.WriteString(levelSeed);
|
||||
msg.WriteSingle(ServerSettings.SelectedLevelDifficulty);
|
||||
msg.WriteIdentifier(ServerSettings.Biome == "Random".ToIdentifier() ? Identifier.Empty : ServerSettings.Biome);
|
||||
msg.WriteString(gameSession.SubmarineInfo.Name);
|
||||
msg.WriteString(gameSession.SubmarineInfo.MD5Hash.StringRepresentation);
|
||||
var selectedShuttle = GameStarted && RespawnManager != null && RespawnManager.UsingShuttle ?
|
||||
@@ -3788,13 +3791,13 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
else //msg sent by an AI character
|
||||
{
|
||||
senderName = senderCharacter.Name;
|
||||
senderName = senderCharacter.DisplayName;
|
||||
}
|
||||
}
|
||||
else //msg sent by a client
|
||||
{
|
||||
senderCharacter = senderClient.Character;
|
||||
senderName = senderCharacter == null ? senderClient.Name : senderCharacter.Name;
|
||||
senderName = senderCharacter == null ? senderClient.Name : senderCharacter.DisplayName;
|
||||
if (type == ChatMessageType.Private)
|
||||
{
|
||||
if (senderCharacter != null && !senderCharacter.IsDead || targetClient.Character != null && !targetClient.Character.IsDead)
|
||||
|
||||
@@ -151,11 +151,11 @@ namespace Barotrauma
|
||||
//increase the strength of the herpes affliction in steps instead of linearly
|
||||
//otherwise clients could determine their exact karma value from the strength
|
||||
float herpesStrength = 0.0f;
|
||||
if (client.Karma < 20)
|
||||
if (client.Karma < HerpesThreshold * 0.5f)
|
||||
herpesStrength = 100.0f;
|
||||
else if (client.Karma < 30)
|
||||
else if (client.Karma < HerpesThreshold * 0.75f)
|
||||
herpesStrength = 60.0f;
|
||||
else if (client.Karma < 40.0f)
|
||||
else if (client.Karma < HerpesThreshold)
|
||||
herpesStrength = 30.0f;
|
||||
|
||||
var existingAffliction = client.Character.CharacterHealth.GetAffliction<AfflictionSpaceHerpes>(AfflictionPrefab.SpaceHerpesType);
|
||||
|
||||
+32
-15
@@ -229,7 +229,9 @@ namespace Barotrauma.Networking
|
||||
GameMain.GameSession.RoundDuration > NetConfig.RoundStartSyncDuration)
|
||||
{
|
||||
lastWarningTime = Timing.TotalTime;
|
||||
GameServer.Log("WARNING: ServerEntityEventManager is lagging behind! Last sent id: " + lastSentToAnyone.ToString() + ", latest create id: " + ID.ToString(), ServerLog.MessageType.ServerMessage);
|
||||
string warningMsg = $"WARNING: ServerEntityEventManager is lagging behind! Last sent id: {lastSentToAnyone}, latest create id: {ID}";
|
||||
warningMsg += "\n" + GetHighEventCountsWarning(events, maxEventsToList: 3);
|
||||
GameServer.Log(warningMsg, ServerLog.MessageType.ServerMessage);
|
||||
events.ForEach(e => e.ResetCreateTime());
|
||||
//TODO: reset clients if this happens, maybe do it if a majority are behind rather than all of them?
|
||||
}
|
||||
@@ -323,30 +325,20 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
//too many events for one packet
|
||||
//(normal right after a round has just started, don't show a warning if it's been less than 10 seconds)
|
||||
if (eventsToSync.Count > 200 && GameMain.GameSession != null && GameMain.GameSession.RoundDuration > 10.0)
|
||||
//(normal right after a round has just started, don't show a warning if it's been less than 30 seconds)
|
||||
if (eventsToSync.Count > 200 && GameMain.GameSession != null && GameMain.GameSession.RoundDuration > 30.0)
|
||||
{
|
||||
if (eventsToSync.Count > 200 && !client.NeedsMidRoundSync && Timing.TotalTime > lastEventCountHighWarning + 2.0)
|
||||
{
|
||||
Color color = eventsToSync.Count > 500 ? Color.Red : Color.Orange;
|
||||
if (eventsToSync.Count < 300) { color = Color.Yellow; }
|
||||
string warningMsg = "WARNING: event count very high: " + eventsToSync.Count;
|
||||
|
||||
var sortedEvents = eventsToSync.GroupBy(e => e.Entity.ToString())
|
||||
.Select(e => new { Value = e.Key, Count = e.Count() })
|
||||
.OrderByDescending(e => e.Count);
|
||||
|
||||
int count = 1;
|
||||
foreach (var sortedEvent in sortedEvents)
|
||||
{
|
||||
warningMsg += "\n" + count + ". " + (sortedEvent.Value?.ToString() ?? "null") + " x" + sortedEvent.Count;
|
||||
count++;
|
||||
if (count > 3) { break; }
|
||||
}
|
||||
warningMsg += "\n" + GetHighEventCountsWarning(eventsToSync, maxEventsToList: 3);
|
||||
if (GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
GameServer.Log(warningMsg, ServerLog.MessageType.Error);
|
||||
}
|
||||
server.SendConsoleMessage(warningMsg, client, color);
|
||||
DebugConsole.NewMessage(warningMsg, color);
|
||||
lastEventCountHighWarning = Timing.TotalTime;
|
||||
}
|
||||
@@ -373,6 +365,31 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
private string GetHighEventCountsWarning(IEnumerable<NetEntityEvent> events, int maxEventsToList)
|
||||
{
|
||||
string warningMsg = string.Empty;
|
||||
|
||||
var sortedEvents = events.GroupBy(e => e.Entity.ToString())
|
||||
.Select(e => new { Value = e.First(), Count = e.Count() })
|
||||
.OrderByDescending(e => e.Count);
|
||||
|
||||
int count = 1;
|
||||
foreach (var sortedEvent in sortedEvents)
|
||||
{
|
||||
Entity targetEntity = sortedEvent.Value.Entity;
|
||||
if (!warningMsg.IsNullOrEmpty()) { warningMsg += "\n"; }
|
||||
warningMsg += count + ". " + (targetEntity?.ToString() ?? "null") + " x" + sortedEvent.Count;
|
||||
if (targetEntity != null && targetEntity.ContentPackage != ContentPackageManager.VanillaCorePackage)
|
||||
{
|
||||
warningMsg += $" (content package: {targetEntity.ContentPackage.Name})";
|
||||
}
|
||||
count++;
|
||||
if (count > maxEventsToList) { break; }
|
||||
}
|
||||
|
||||
return warningMsg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of events that should be sent to the client from the eventList
|
||||
/// </summary>
|
||||
|
||||
+10
-4
@@ -457,7 +457,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (pendingClient.AccountInfo.AccountId != packet.AccountId)
|
||||
{
|
||||
RemovePendingClient(pendingClient, PeerDisconnectPacket.WithReason(DisconnectReason.AuthenticationFailed));
|
||||
rejectClient();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -513,10 +513,16 @@ namespace Barotrauma.Networking
|
||||
pendingClient.AuthSessionStarted = true;
|
||||
TaskPool.Add($"{nameof(LidgrenServerPeer)}.ProcessAuth", authenticator.VerifyTicket(authTicket), t =>
|
||||
{
|
||||
if (!t.TryGetResult(out AccountInfo accountInfo)
|
||||
|| accountInfo.IsNone)
|
||||
if (!t.TryGetResult(out AccountInfo accountInfo) || accountInfo.IsNone)
|
||||
{
|
||||
rejectClient();
|
||||
if (GameMain.Server.ServerSettings.RequireAuthentication)
|
||||
{
|
||||
rejectClient();
|
||||
}
|
||||
else
|
||||
{
|
||||
acceptClient(new AccountInfo(new UnauthenticatedAccountId(packet.Name)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
var property = netProperties[key];
|
||||
property.SyncValue();
|
||||
if (NetIdUtils.IdMoreRecent(property.LastUpdateID, c.LastRecvLobbyUpdate))
|
||||
if (NetIdUtils.IdMoreRecent(property.LastUpdateID, c.LastRecvLobbyUpdate) || !c.InitialLobbyUpdateSent)
|
||||
{
|
||||
outMsg.WriteUInt32(key);
|
||||
netProperties[key].Write(outMsg);
|
||||
|
||||
Reference in New Issue
Block a user