(3a5d98b) v0.9.6.0
This commit is contained in:
@@ -483,6 +483,8 @@ namespace Barotrauma.Networking
|
||||
if (DateTime.Now > timeOut)
|
||||
{
|
||||
clientPeer?.Close(Lidgren.Network.NetConnection.NoResponseMessage);
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("ConnectionFailed"), TextManager.Get("CouldNotConnectToServer"));
|
||||
msgBox.Buttons[0].OnClicked += ReturnToPreviousMenu;
|
||||
reconnectBox?.Close(); reconnectBox = null;
|
||||
break;
|
||||
}
|
||||
@@ -1232,7 +1234,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (Level.Loaded.EqualityCheckVal != levelEqualityCheckVal)
|
||||
{
|
||||
string errorMsg = "Level equality check failed. The level generated at your end doesn't match the level generated by the server (seed " + Level.Loaded.Seed + ").";
|
||||
string errorMsg = "Level equality check failed. The level generated at your end doesn't match the level generated by the server (seed: " + Level.Loaded.Seed +
|
||||
", sub: " + Submarine.MainSub.Name + " (" + Submarine.MainSub.MD5Hash.ShortHash + ")" +
|
||||
", mirrored: " + Level.Loaded.Mirrored + ").";
|
||||
DebugConsole.ThrowError(errorMsg, createMessageBox: true);
|
||||
GameAnalyticsManager.AddErrorEventOnce("GameClient.StartGame:LevelsDontMatch" + levelSeed, GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
CoroutineManager.StartCoroutine(EndGame(""));
|
||||
@@ -1274,6 +1278,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
gameStarted = false;
|
||||
Character.Controlled = null;
|
||||
SpawnAsTraitor = false;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
respawnManager = null;
|
||||
@@ -1432,6 +1437,8 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
private bool initialUpdateReceived;
|
||||
|
||||
private void ReadLobbyUpdate(IReadMessage inc)
|
||||
{
|
||||
ServerNetObject objHeader;
|
||||
@@ -1452,13 +1459,15 @@ namespace Barotrauma.Networking
|
||||
UInt16 settingsLen = inc.ReadUInt16();
|
||||
byte[] settingsData = inc.ReadBytes(settingsLen);
|
||||
|
||||
if (inc.ReadBoolean())
|
||||
bool isInitialUpdate = inc.ReadBoolean();
|
||||
if (isInitialUpdate)
|
||||
{
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("Received initial lobby update, ID: " + updateID + ", last ID: " + GameMain.NetLobbyScreen.LastUpdateID, Color.Gray);
|
||||
}
|
||||
ReadInitialUpdate(inc);
|
||||
initialUpdateReceived = true;
|
||||
}
|
||||
|
||||
string selectSubName = inc.ReadString();
|
||||
@@ -1489,7 +1498,9 @@ namespace Barotrauma.Networking
|
||||
float autoRestartTimer = autoRestartEnabled ? inc.ReadSingle() : 0.0f;
|
||||
|
||||
//ignore the message if we already a more up-to-date one
|
||||
if (NetIdUtils.IdMoreRecent(updateID, GameMain.NetLobbyScreen.LastUpdateID))
|
||||
//or if we're still waiting for the initial update
|
||||
if (NetIdUtils.IdMoreRecent(updateID, GameMain.NetLobbyScreen.LastUpdateID) &&
|
||||
(isInitialUpdate || initialUpdateReceived))
|
||||
{
|
||||
ReadWriteMessage settingsBuf = new ReadWriteMessage();
|
||||
settingsBuf.Write(settingsData, 0, settingsLen); settingsBuf.BitPosition = 0;
|
||||
@@ -2248,12 +2259,10 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (gameStarted)
|
||||
{
|
||||
tickBox.Visible = false;
|
||||
tickBox.Parent.Visible = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Vote(VoteType.StartRound, tickBox.Selected);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+16
-1
@@ -200,6 +200,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
msg.BitPosition += msgLength * 8;
|
||||
msg.ReadPadBits();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -213,6 +214,20 @@ namespace Barotrauma.Networking
|
||||
try
|
||||
{
|
||||
ReadEvent(msg, entity, sendingTime);
|
||||
msg.ReadPadBits();
|
||||
|
||||
if (msg.BitPosition != msgPosition + msgLength * 8)
|
||||
{
|
||||
string errorMsg = "Message byte position incorrect after reading an event for the entity \"" + entity.ToString()
|
||||
+ "\". Read " + (msg.BitPosition - msgPosition) + " bits, expected message length was " + (msgLength * 8) + " bits.";
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
#endif
|
||||
GameAnalyticsManager.AddErrorEventOnce("ClientEntityEventManager.Read:BitPosMismatch", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
|
||||
//TODO: force the BitPosition to correct place? Having some entity in a potentially incorrect state is not as bad as a desync kick
|
||||
//msg.BitPosition = (int)(msgPosition + msgLength * 8);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
@@ -231,9 +246,9 @@ namespace Barotrauma.Networking
|
||||
GameAnalyticsManager.AddErrorEventOnce("ClientEntityEventManager.Read:ReadFailed" + entity.ToString(),
|
||||
GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
msg.BitPosition = (int)(msgPosition + msgLength * 8);
|
||||
msg.ReadPadBits();
|
||||
}
|
||||
}
|
||||
msg.ReadPadBits();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -275,6 +275,7 @@ namespace Barotrauma.Networking
|
||||
#if DEBUG
|
||||
CoroutineManager.InvokeAfter(() =>
|
||||
{
|
||||
if (GameMain.Client == null) { return; }
|
||||
if (Rand.Range(0.0f, 1.0f) < GameMain.Client.SimulatedLoss && sendType != Facepunch.Steamworks.Networking.SendType.Reliable) { return; }
|
||||
int count = Rand.Range(0.0f, 1.0f) < GameMain.Client.SimulatedDuplicatesChance ? 2 : 1;
|
||||
for (int i = 0; i < count; i++)
|
||||
|
||||
@@ -18,7 +18,17 @@ namespace Barotrauma.Networking
|
||||
public UInt64 OwnerID;
|
||||
public bool OwnerVerified;
|
||||
|
||||
public string ServerName;
|
||||
private string serverName;
|
||||
public string ServerName
|
||||
{
|
||||
get { return serverName; }
|
||||
set
|
||||
{
|
||||
serverName = value;
|
||||
if (serverName.Length > NetConfig.ServerNameMaxLength) { ServerName = ServerName.Substring(0, NetConfig.ServerNameMaxLength); }
|
||||
}
|
||||
}
|
||||
|
||||
public string ServerMessage;
|
||||
public bool GameStarted;
|
||||
public int PlayerCount;
|
||||
@@ -455,38 +465,7 @@ namespace Barotrauma.Networking
|
||||
if (SteamFriend.IsPlayingThisGame && SteamFriend.ServerLobbyId != 0)
|
||||
{
|
||||
LobbyID = SteamFriend.ServerLobbyId;
|
||||
SteamManager.Instance.LobbyList.SetManualLobbyDataCallback(LobbyID, (lobby) =>
|
||||
{
|
||||
SteamManager.Instance.LobbyList.SetManualLobbyDataCallback(LobbyID, null);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(lobby.GetData("haspassword"))) { return; }
|
||||
bool.TryParse(lobby.GetData("haspassword"), out bool hasPassword);
|
||||
int.TryParse(lobby.GetData("playercount"), out int currPlayers);
|
||||
int.TryParse(lobby.GetData("maxplayernum"), out int maxPlayers);
|
||||
//UInt64.TryParse(lobby.GetData("connectsteamid"), out ulong connectSteamId);
|
||||
string ip = lobby.GetData("hostipaddress");
|
||||
UInt64 ownerId = SteamManager.SteamIDStringToUInt64(lobby.GetData("lobbyowner"));
|
||||
|
||||
if (OwnerID != ownerId) { return; }
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ip)) { ip = ""; }
|
||||
|
||||
ServerName = lobby.Name;
|
||||
Port = "";
|
||||
QueryPort = "";
|
||||
IP = ip;
|
||||
PlayerCount = currPlayers;
|
||||
MaxPlayers = maxPlayers;
|
||||
HasPassword = hasPassword;
|
||||
RespondedToSteamQuery = true;
|
||||
LobbyID = lobby.LobbyID;
|
||||
OwnerID = ownerId;
|
||||
PingChecked = false;
|
||||
OwnerVerified = true;
|
||||
SteamManager.AssignLobbyDataToServerInfo(lobby, this);
|
||||
|
||||
onServerRulesReceived?.Invoke(this);
|
||||
});
|
||||
|
||||
SteamManager.Instance.LobbyList.RequestLobbyData(LobbyID);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -326,8 +326,8 @@ namespace Barotrauma.Steam
|
||||
localQuery.OnFinished = onFinished;
|
||||
#endif
|
||||
|
||||
instance.client.LobbyList.OnLobbiesUpdated = () => { UpdateLobbyQuery(onServerFound, onServerRulesReceived, onFinished); };
|
||||
instance.client.LobbyList.Refresh();
|
||||
|
||||
instance.client.LobbyList.Request();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -382,42 +382,6 @@ namespace Barotrauma.Steam
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void UpdateLobbyQuery(Action<Networking.ServerInfo> onServerFound, Action<Networking.ServerInfo> onServerRulesReceived, Action onFinished)
|
||||
{
|
||||
foreach (LobbyList.Lobby lobby in instance.client.LobbyList.Lobbies)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(lobby.GetData("haspassword"))) { continue; }
|
||||
bool.TryParse(lobby.GetData("haspassword"), out bool hasPassword);
|
||||
int.TryParse(lobby.GetData("playercount"), out int currPlayers);
|
||||
int.TryParse(lobby.GetData("maxplayernum"), out int maxPlayers);
|
||||
UInt64 ownerId = SteamIDStringToUInt64(lobby.GetData("lobbyowner"));
|
||||
//UInt64.TryParse(lobby.GetData("connectsteamid"), out ulong connectSteamId);
|
||||
string ip = lobby.GetData("hostipaddress");
|
||||
if (string.IsNullOrWhiteSpace(ip)) { ip = ""; }
|
||||
|
||||
var serverInfo = new ServerInfo()
|
||||
{
|
||||
ServerName = lobby.Name,
|
||||
Port = "",
|
||||
QueryPort = "",
|
||||
IP = ip,
|
||||
PlayerCount = currPlayers,
|
||||
MaxPlayers = maxPlayers,
|
||||
HasPassword = hasPassword,
|
||||
RespondedToSteamQuery = true,
|
||||
LobbyID = lobby.LobbyID,
|
||||
OwnerID = ownerId
|
||||
};
|
||||
serverInfo.PingChecked = false;
|
||||
AssignLobbyDataToServerInfo(lobby, serverInfo);
|
||||
|
||||
onServerFound(serverInfo);
|
||||
//onServerRulesReceived(serverInfo);
|
||||
}
|
||||
|
||||
onFinished();
|
||||
}
|
||||
|
||||
public static void AssignLobbyDataToServerInfo(LobbyList.Lobby lobby, ServerInfo serverInfo)
|
||||
{
|
||||
serverInfo.ServerMessage = lobby.GetData("message");
|
||||
@@ -495,6 +459,7 @@ namespace Barotrauma.Steam
|
||||
serverInfo.PingChecked = true;
|
||||
serverInfo.Ping = s.Ping;
|
||||
serverInfo.LobbyID = 0;
|
||||
serverInfo.OwnerVerified = true;
|
||||
if (responded)
|
||||
{
|
||||
s.FetchRules();
|
||||
|
||||
Reference in New Issue
Block a user