Unstable 0.17.0.0
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
@@ -50,8 +51,9 @@ namespace Barotrauma.Networking
|
||||
private GUIMessageBox reconnectBox, waitInServerQueueBox;
|
||||
|
||||
//TODO: move these to NetLobbyScreen
|
||||
public LocalizedString endRoundVoteText;
|
||||
public GUITickBox EndVoteTickBox;
|
||||
private GUIComponent buttonContainer;
|
||||
private readonly GUIComponent buttonContainer;
|
||||
|
||||
public readonly NetStats NetStats;
|
||||
|
||||
@@ -121,7 +123,7 @@ namespace Barotrauma.Networking
|
||||
public bool HasSpawned;
|
||||
|
||||
public bool SpawnAsTraitor;
|
||||
public string TraitorFirstObjective;
|
||||
public LocalizedString TraitorFirstObjective;
|
||||
public TraitorMissionPrefab TraitorMission = null;
|
||||
|
||||
public byte ID
|
||||
@@ -221,13 +223,14 @@ namespace Barotrauma.Networking
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
endRoundVoteText = TextManager.Get("EndRound");
|
||||
EndVoteTickBox = new GUITickBox(new RectTransform(new Vector2(0.1f, 0.4f), buttonContainer.RectTransform) { MinSize = new Point(150, 0) },
|
||||
TextManager.Get("EndRound"))
|
||||
endRoundVoteText)
|
||||
{
|
||||
UserData = TextManager.Get("EndRound"),
|
||||
OnSelected = ToggleEndRoundVote,
|
||||
Visible = false
|
||||
};
|
||||
EndVoteTickBox.TextBlock.Wrap = true;
|
||||
|
||||
ShowLogButton = new GUIButton(new RectTransform(new Vector2(0.1f, 0.6f), buttonContainer.RectTransform) { MinSize = new Point(150, 0) },
|
||||
TextManager.Get("ServerLog"))
|
||||
@@ -282,8 +285,7 @@ namespace Barotrauma.Networking
|
||||
//ServerLog = new ServerLog("");
|
||||
|
||||
ChatMessage.LastID = 0;
|
||||
GameMain.NetLobbyScreen?.Release();
|
||||
GameMain.NetLobbyScreen = new NetLobbyScreen();
|
||||
GameMain.ResetNetLobbyScreen();
|
||||
}
|
||||
|
||||
private void ConnectToServer(object endpoint, string hostName)
|
||||
@@ -340,7 +342,7 @@ namespace Barotrauma.Networking
|
||||
catch
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("CouldNotConnectToServer"),
|
||||
TextManager.GetWithVariables("InvalidIPAddress", new string[2] { "[serverip]", "[port]" }, new string[2] { serverIP, port.ToString() }));
|
||||
TextManager.GetWithVariables("InvalidIPAddress", ("[serverip]", serverIP), ("[port]", port.ToString())));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,39 +363,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
clientPeer.OnDisconnect = OnDisconnect;
|
||||
clientPeer.OnDisconnectMessageReceived = HandleDisconnectMessage;
|
||||
clientPeer.OnInitializationComplete = () =>
|
||||
{
|
||||
if (SteamManager.IsInitialized)
|
||||
{
|
||||
Steamworks.SteamFriends.ClearRichPresence();
|
||||
Steamworks.SteamFriends.SetRichPresence("status", "Playing on " + serverName);
|
||||
Steamworks.SteamFriends.SetRichPresence("connect", "-connect \"" + serverName.Replace("\"", "\\\"") + "\" " + serverEndpoint);
|
||||
}
|
||||
|
||||
canStart = true;
|
||||
connected = true;
|
||||
|
||||
VoipClient = new VoipClient(this, clientPeer);
|
||||
|
||||
if (Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
entityEventManager.ClearSelf();
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
c.ResetNetState();
|
||||
}
|
||||
}
|
||||
|
||||
chatBox.InputBox.Enabled = true;
|
||||
if (GameMain.NetLobbyScreen?.ChatInput != null)
|
||||
{
|
||||
GameMain.NetLobbyScreen.ChatInput.Enabled = true;
|
||||
}
|
||||
};
|
||||
clientPeer.OnInitializationComplete = OnConnectionInitializationComplete;
|
||||
clientPeer.OnRequestPassword = (int salt, int retries) =>
|
||||
{
|
||||
if (pwRetries != retries)
|
||||
@@ -471,10 +441,10 @@ namespace Barotrauma.Networking
|
||||
canStart = false;
|
||||
|
||||
DateTime timeOut = DateTime.Now + new TimeSpan(0, 0, 40);
|
||||
DateTime reqAuthTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, 200);
|
||||
DateTime reqAuthTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, 200);
|
||||
|
||||
// Loop until we are approved
|
||||
string connectingText = TextManager.Get("Connecting");
|
||||
LocalizedString connectingText = TextManager.Get("Connecting");
|
||||
while (!canStart && !connectCancelled)
|
||||
{
|
||||
if (reconnectBox == null && waitInServerQueueBox == null)
|
||||
@@ -493,12 +463,12 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(serverDisplayName)) { serverDisplayName = TextManager.Get("Unknown"); }
|
||||
if (string.IsNullOrEmpty(serverDisplayName)) { serverDisplayName = TextManager.Get("Unknown").Value; }
|
||||
|
||||
reconnectBox = new GUIMessageBox(
|
||||
connectingText,
|
||||
TextManager.GetWithVariable("ConnectingTo", "[serverip]", serverDisplayName),
|
||||
new string[] { TextManager.Get("Cancel") });
|
||||
new LocalizedString[] { TextManager.Get("Cancel") });
|
||||
reconnectBox.Buttons[0].OnClicked += (btn, userdata) => { CancelConnect(); return true; };
|
||||
reconnectBox.Buttons[0].OnClicked += reconnectBox.Close;
|
||||
}
|
||||
@@ -524,9 +494,9 @@ namespace Barotrauma.Networking
|
||||
GUI.ClearCursorWait();
|
||||
reconnectBox?.Close(); reconnectBox = null;
|
||||
|
||||
string pwMsg = TextManager.Get("PasswordRequired");
|
||||
LocalizedString pwMsg = TextManager.Get("PasswordRequired");
|
||||
|
||||
var msgBox = new GUIMessageBox(pwMsg, "", new string[] { TextManager.Get("OK"), TextManager.Get("Cancel") },
|
||||
var msgBox = new GUIMessageBox(pwMsg, "", new LocalizedString[] { TextManager.Get("OK"), TextManager.Get("Cancel") },
|
||||
relativeSize: new Vector2(0.25f, 0.1f), minSize: new Point(400, GUI.IntScale(170)));
|
||||
var passwordHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), msgBox.Content.RectTransform), childAnchor: Anchor.TopCenter);
|
||||
var passwordBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1f), passwordHolder.RectTransform) { MinSize = new Point(0, 20) })
|
||||
@@ -537,7 +507,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (wrongPassword)
|
||||
{
|
||||
var incorrectPasswordText = new GUITextBlock(new RectTransform(new Vector2(1f, 0.0f), passwordHolder.RectTransform), TextManager.Get("incorrectpassword"), GUI.Style.Red, GUI.Font, textAlignment: Alignment.Center);
|
||||
var incorrectPasswordText = new GUITextBlock(new RectTransform(new Vector2(1f, 0.0f), passwordHolder.RectTransform), TextManager.Get("incorrectpassword"), GUIStyle.Red, GUIStyle.Font, textAlignment: Alignment.Center);
|
||||
incorrectPasswordText.RectTransform.MinSize = new Point(0, (int)incorrectPasswordText.TextSize.Y);
|
||||
passwordHolder.Recalculate();
|
||||
}
|
||||
@@ -651,7 +621,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
GameAnalyticsManager.AddErrorEventOnce("GameClient.Update:CheckServerMessagesException" + e.TargetSite.ToString(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
DebugConsole.ThrowError("Error while reading a message from server.", e);
|
||||
new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariables("MessageReadError", new string[2] { "[message]", "[targetsite]" }, new string[2] { e.Message, e.TargetSite.ToString() }));
|
||||
new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariables("MessageReadError", ("[message]", e.Message), ("[targetsite]", e.TargetSite.ToString())));
|
||||
Disconnect();
|
||||
GameMain.ServerListScreen.Select();
|
||||
return;
|
||||
@@ -734,6 +704,22 @@ namespace Barotrauma.Networking
|
||||
MultiPlayerCampaign campaign = GameMain.NetLobbyScreen.SelectedMode == GameMain.GameSession?.GameMode.Preset ?
|
||||
GameMain.GameSession?.GameMode as MultiPlayerCampaign : null;
|
||||
|
||||
if (Screen.Selected is ModDownloadScreen)
|
||||
{
|
||||
switch (header)
|
||||
{
|
||||
case ServerPacketHeader.UPDATE_LOBBY:
|
||||
case ServerPacketHeader.PING_REQUEST:
|
||||
case ServerPacketHeader.FILE_TRANSFER:
|
||||
case ServerPacketHeader.PERMISSIONS:
|
||||
case ServerPacketHeader.CHEATS_ENABLED:
|
||||
//allow interpreting this packet
|
||||
break;
|
||||
default:
|
||||
return; //ignore any other packets
|
||||
}
|
||||
}
|
||||
|
||||
switch (header)
|
||||
{
|
||||
case ServerPacketHeader.PING_REQUEST:
|
||||
@@ -980,9 +966,12 @@ namespace Barotrauma.Networking
|
||||
List<ContentFile> contentToPreload = new List<ContentFile>();
|
||||
for (int i = 0; i < contentToPreloadCount; i++)
|
||||
{
|
||||
ContentType contentType = (ContentType)inc.ReadByte();
|
||||
string filePath = inc.ReadString();
|
||||
contentToPreload.Add(new ContentFile(filePath, contentType));
|
||||
ContentFile file = ContentPackageManager.EnabledPackages.All
|
||||
.Select(p =>
|
||||
p.Files.FirstOrDefault(f => f.Path == filePath))
|
||||
.FirstOrDefault(f => !(f is null));
|
||||
contentToPreload.AddIfNotNull(file);
|
||||
}
|
||||
|
||||
GameMain.GameSession.EventManager.PreloadContent(contentToPreload);
|
||||
@@ -1002,10 +991,10 @@ namespace Barotrauma.Networking
|
||||
string errorMsg = $"Mission equality check failed. Mission count doesn't match the server (server: {missionCount}, client: {GameMain.GameSession.Missions.Count()})";
|
||||
throw new Exception(errorMsg);
|
||||
}
|
||||
List<string> serverMissionIdentifiers = new List<string>();
|
||||
List<Identifier> serverMissionIdentifiers = new List<Identifier>();
|
||||
for (int i = 0; i < missionCount; i++)
|
||||
{
|
||||
serverMissionIdentifiers.Add(inc.ReadString() ?? "");
|
||||
serverMissionIdentifiers.Add(inc.ReadIdentifier());
|
||||
}
|
||||
|
||||
if (missionCount > 0)
|
||||
@@ -1032,7 +1021,7 @@ namespace Barotrauma.Networking
|
||||
" (client value count: " + Level.Loaded.EqualityCheckValues.Count +
|
||||
", level value count: " + levelEqualityCheckValues.Count +
|
||||
", seed: " + Level.Loaded.Seed +
|
||||
", sub: " + Submarine.MainSub.Info.Name + " (" + Submarine.MainSub.Info.MD5Hash.ShortHash + ")" +
|
||||
", sub: " + Submarine.MainSub.Info.Name + " (" + Submarine.MainSub.Info.MD5Hash.ShortRepresentation + ")" +
|
||||
", mirrored: " + Level.Loaded.Mirrored + ").";
|
||||
GameAnalyticsManager.AddErrorEventOnce("GameClient.StartGame:LevelsDontMatch" + Level.Loaded.Seed, GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
throw new Exception(errorMsg);
|
||||
@@ -1048,7 +1037,7 @@ namespace Barotrauma.Networking
|
||||
", server value #" + i + ": " + levelEqualityCheckValues[i].ToString("X") +
|
||||
", level value count: " + levelEqualityCheckValues.Count +
|
||||
", seed: " + Level.Loaded.Seed +
|
||||
", sub: " + Submarine.MainSub.Info.Name + " (" + Submarine.MainSub.Info.MD5Hash.ShortHash + ")" +
|
||||
", sub: " + Submarine.MainSub.Info.Name + " (" + Submarine.MainSub.Info.MD5Hash.ShortRepresentation + ")" +
|
||||
", mirrored: " + Level.Loaded.Mirrored + ").";
|
||||
GameAnalyticsManager.AddErrorEventOnce("GameClient.StartGame:LevelsDontMatch" + Level.Loaded.Seed, GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
throw new Exception(errorMsg);
|
||||
@@ -1076,7 +1065,7 @@ namespace Barotrauma.Networking
|
||||
reconnectBox?.Close();
|
||||
reconnectBox = null;
|
||||
|
||||
GameMain.Config.RestoreBackupPackages();
|
||||
ContentPackageManager.EnabledPackages.Restore();
|
||||
|
||||
GUI.ClearCursorWait();
|
||||
|
||||
@@ -1138,7 +1127,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
var queueBox = new GUIMessageBox(
|
||||
TextManager.Get("DisconnectReason.ServerFull"),
|
||||
TextManager.Get("ServerFullQuestionPrompt"), new string[] { TextManager.Get("Cancel"), TextManager.Get("ServerQueue") });
|
||||
TextManager.Get("ServerFullQuestionPrompt"), new LocalizedString[] { TextManager.Get("Cancel"), TextManager.Get("ServerQueue") });
|
||||
|
||||
queueBox.Buttons[0].OnClicked += queueBox.Close;
|
||||
queueBox.Buttons[1].OnClicked += queueBox.Close;
|
||||
@@ -1178,15 +1167,15 @@ namespace Barotrauma.Networking
|
||||
DebugConsole.NewMessage("Attempting to reconnect...");
|
||||
|
||||
//if the first part of the message is the disconnect reason Enum, don't include it in the popup message
|
||||
string msg = TextManager.GetServerMessage(disconnectReasonIncluded ? string.Join('/', splitMsg.Skip(1)) : disconnectMsg);
|
||||
msg = string.IsNullOrWhiteSpace(msg) ?
|
||||
LocalizedString msg = TextManager.GetServerMessage(disconnectReasonIncluded ? string.Join('/', splitMsg.Skip(1)) : disconnectMsg);
|
||||
msg = msg.IsNullOrWhiteSpace() ?
|
||||
TextManager.Get("ConnectionLostReconnecting") :
|
||||
msg + '\n' + TextManager.Get("ConnectionLostReconnecting");
|
||||
|
||||
reconnectBox?.Close();
|
||||
reconnectBox = new GUIMessageBox(
|
||||
TextManager.Get("ConnectionLost"), msg,
|
||||
new string[] { TextManager.Get("Cancel") });
|
||||
new LocalizedString[] { TextManager.Get("Cancel") });
|
||||
reconnectBox.Buttons[0].OnClicked += (btn, userdata) => { CancelConnect(); return true; };
|
||||
connected = false;
|
||||
ConnectToServer(serverEndpoint, serverName);
|
||||
@@ -1196,7 +1185,7 @@ namespace Barotrauma.Networking
|
||||
connected = false;
|
||||
connectCancelled = true;
|
||||
|
||||
string msg = "";
|
||||
LocalizedString msg = "";
|
||||
if (disconnectReason == DisconnectReason.Unknown)
|
||||
{
|
||||
DebugConsole.NewMessage("Not attempting to reconnect (unknown disconnect reason).");
|
||||
@@ -1241,11 +1230,45 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
private void OnConnectionInitializationComplete()
|
||||
{
|
||||
if (SteamManager.IsInitialized)
|
||||
{
|
||||
Steamworks.SteamFriends.ClearRichPresence();
|
||||
Steamworks.SteamFriends.SetRichPresence("status", "Playing on " + serverName);
|
||||
Steamworks.SteamFriends.SetRichPresence("connect", "-connect \"" + serverName.Replace("\"", "\\\"") + "\" " + serverEndpoint);
|
||||
}
|
||||
|
||||
canStart = true;
|
||||
connected = true;
|
||||
|
||||
VoipClient = new VoipClient(this, clientPeer);
|
||||
|
||||
if (Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
GameMain.ModDownloadScreen.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
entityEventManager.ClearSelf();
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
c.ResetNetState();
|
||||
}
|
||||
}
|
||||
|
||||
chatBox.InputBox.Enabled = true;
|
||||
if (GameMain.NetLobbyScreen?.ChatInput != null)
|
||||
{
|
||||
GameMain.NetLobbyScreen.ChatInput.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<CoroutineStatus> WaitInServerQueue()
|
||||
{
|
||||
waitInServerQueueBox = new GUIMessageBox(
|
||||
TextManager.Get("ServerQueuePleaseWait"),
|
||||
TextManager.Get("WaitingInServerQueue"), new string[] { TextManager.Get("Cancel") });
|
||||
TextManager.Get("WaitingInServerQueue"), new LocalizedString[] { TextManager.Get("Cancel") });
|
||||
waitInServerQueueBox.Buttons[0].OnClicked += (btn, userdata) =>
|
||||
{
|
||||
CoroutineManager.StopCoroutines("WaitInServerQueue");
|
||||
@@ -1273,7 +1296,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
private void ReadAchievement(IReadMessage inc)
|
||||
{
|
||||
string achievementIdentifier = inc.ReadString();
|
||||
Identifier achievementIdentifier = inc.ReadIdentifier();
|
||||
int amount = inc.ReadInt32();
|
||||
if (amount == 0)
|
||||
{
|
||||
@@ -1289,16 +1312,16 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
TraitorMessageType messageType = (TraitorMessageType)inc.ReadByte();
|
||||
string missionIdentifier = inc.ReadString();
|
||||
string message = inc.ReadString();
|
||||
message = TextManager.GetServerMessage(message);
|
||||
string messageFmt = inc.ReadString();
|
||||
LocalizedString message = TextManager.GetServerMessage(messageFmt);
|
||||
|
||||
var missionPrefab = TraitorMissionPrefab.List.Find(t => t.Identifier == missionIdentifier);
|
||||
var missionPrefab = TraitorMissionPrefab.Prefabs.Find(t => t.Identifier == missionIdentifier);
|
||||
Sprite icon = missionPrefab?.Icon;
|
||||
|
||||
switch (messageType)
|
||||
{
|
||||
case TraitorMessageType.Objective:
|
||||
var isTraitor = !string.IsNullOrEmpty(message);
|
||||
var isTraitor = !message.IsNullOrEmpty();
|
||||
SpawnAsTraitor = isTraitor;
|
||||
TraitorFirstObjective = message;
|
||||
TraitorMission = missionPrefab;
|
||||
@@ -1309,11 +1332,11 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
break;
|
||||
case TraitorMessageType.Console:
|
||||
GameMain.Client.AddChatMessage(ChatMessage.Create("", message, ChatMessageType.Console, null));
|
||||
GameMain.Client.AddChatMessage(ChatMessage.Create("", message.Value, ChatMessageType.Console, null));
|
||||
DebugConsole.NewMessage(message);
|
||||
break;
|
||||
case TraitorMessageType.ServerMessageBox:
|
||||
var msgBox = new GUIMessageBox("", message, new string[0], type: GUIMessageBox.Type.InGame, icon: icon);
|
||||
var msgBox = new GUIMessageBox("", message, Array.Empty<LocalizedString>(), type: GUIMessageBox.Type.InGame, icon: icon);
|
||||
if (msgBox.Icon != null)
|
||||
{
|
||||
msgBox.IconColor = missionPrefab.IconColor;
|
||||
@@ -1321,7 +1344,7 @@ namespace Barotrauma.Networking
|
||||
break;
|
||||
case TraitorMessageType.Server:
|
||||
default:
|
||||
GameMain.Client.AddChatMessage(message, ChatMessageType.Server);
|
||||
GameMain.Client.AddChatMessage(message.Value, ChatMessageType.Server);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1369,7 +1392,7 @@ namespace Barotrauma.Networking
|
||||
msgBox.Content.ClearChildren();
|
||||
msgBox.Content.RectTransform.RelativeSize = new Vector2(0.95f, 0.9f);
|
||||
|
||||
var header = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), msgBox.Content.RectTransform), TextManager.Get("PermissionsChanged"), textAlignment: Alignment.Center, font: GUI.LargeFont);
|
||||
var header = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), msgBox.Content.RectTransform), TextManager.Get("PermissionsChanged"), textAlignment: Alignment.Center, font: GUIStyle.LargeFont);
|
||||
header.RectTransform.IsFixedSize = true;
|
||||
|
||||
var permissionArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), msgBox.Content.RectTransform), isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f };
|
||||
@@ -1378,12 +1401,12 @@ namespace Barotrauma.Networking
|
||||
|
||||
var permissionsLabel = new GUITextBlock(new RectTransform(new Vector2(newPermissions == ClientPermissions.None ? 2.0f : 1.0f, 0.0f), leftColumn.RectTransform),
|
||||
TextManager.Get(newPermissions == ClientPermissions.None ? "PermissionsRemoved" : "CurrentPermissions"),
|
||||
wrap: true, font: (newPermissions == ClientPermissions.None ? GUI.Font : GUI.SubHeadingFont));
|
||||
wrap: true, font: (newPermissions == ClientPermissions.None ? GUIStyle.Font : GUIStyle.SubHeadingFont));
|
||||
permissionsLabel.RectTransform.NonScaledSize = new Point(permissionsLabel.Rect.Width, permissionsLabel.Rect.Height);
|
||||
permissionsLabel.RectTransform.IsFixedSize = true;
|
||||
if (newPermissions != ClientPermissions.None)
|
||||
{
|
||||
string permissionList = "";
|
||||
LocalizedString permissionList = "";
|
||||
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
|
||||
{
|
||||
if (!newPermissions.HasFlag(permission) || permission == ClientPermissions.None) { continue; }
|
||||
@@ -1396,12 +1419,12 @@ namespace Barotrauma.Networking
|
||||
if (newPermissions.HasFlag(ClientPermissions.ConsoleCommands))
|
||||
{
|
||||
var commandsLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), rightColumn.RectTransform),
|
||||
TextManager.Get("PermittedConsoleCommands"), wrap: true, font: GUI.SubHeadingFont);
|
||||
TextManager.Get("PermittedConsoleCommands"), wrap: true, font: GUIStyle.SubHeadingFont);
|
||||
var commandList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), rightColumn.RectTransform));
|
||||
foreach (string permittedCommand in permittedConsoleCommands)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), commandList.Content.RectTransform, minSize: new Point(0, 15)),
|
||||
permittedCommand, font: GUI.SmallFont)
|
||||
permittedCommand, font: GUIStyle.SmallFont)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -1504,11 +1527,11 @@ namespace Barotrauma.Networking
|
||||
string subHash = inc.ReadString();
|
||||
string shuttleName = inc.ReadString();
|
||||
string shuttleHash = inc.ReadString();
|
||||
List<int> missionIndices = new List<int>();
|
||||
List<UInt32> missionHashes = new List<UInt32>();
|
||||
int missionCount = inc.ReadByte();
|
||||
for (int i = 0; i < missionCount; i++)
|
||||
{
|
||||
missionIndices.Add(inc.ReadInt16());
|
||||
missionHashes.Add(inc.ReadUInt32());
|
||||
}
|
||||
if (!GameMain.NetLobbyScreen.TrySelectSub(subName, subHash, GameMain.NetLobbyScreen.SubList))
|
||||
{
|
||||
@@ -1525,7 +1548,7 @@ namespace Barotrauma.Networking
|
||||
//this shouldn't happen, TrySelectSub should stop the coroutine if the correct sub/shuttle cannot be found
|
||||
if (GameMain.NetLobbyScreen.SelectedSub == null ||
|
||||
GameMain.NetLobbyScreen.SelectedSub.Name != subName ||
|
||||
GameMain.NetLobbyScreen.SelectedSub.MD5Hash?.Hash != subHash)
|
||||
GameMain.NetLobbyScreen.SelectedSub.MD5Hash?.StringRepresentation != subHash)
|
||||
{
|
||||
string errorMsg = "Failed to select submarine \"" + subName + "\" (hash: " + subHash + ").";
|
||||
if (GameMain.NetLobbyScreen.SelectedSub == null)
|
||||
@@ -1538,9 +1561,9 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
errorMsg += "\n" + "Name mismatch: " + GameMain.NetLobbyScreen.SelectedSub.Name + " != " + subName;
|
||||
}
|
||||
if (GameMain.NetLobbyScreen.SelectedSub.MD5Hash?.Hash != subHash)
|
||||
if (GameMain.NetLobbyScreen.SelectedSub.MD5Hash?.StringRepresentation != subHash)
|
||||
{
|
||||
errorMsg += "\n" + "Hash mismatch: " + GameMain.NetLobbyScreen.SelectedSub.MD5Hash?.Hash + " != " + subHash;
|
||||
errorMsg += "\n" + "Hash mismatch: " + GameMain.NetLobbyScreen.SelectedSub.MD5Hash?.StringRepresentation + " != " + subHash;
|
||||
}
|
||||
}
|
||||
gameStarted = true;
|
||||
@@ -1552,7 +1575,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
if (GameMain.NetLobbyScreen.SelectedShuttle == null ||
|
||||
GameMain.NetLobbyScreen.SelectedShuttle.Name != shuttleName ||
|
||||
GameMain.NetLobbyScreen.SelectedShuttle.MD5Hash?.Hash != shuttleHash)
|
||||
GameMain.NetLobbyScreen.SelectedShuttle.MD5Hash?.StringRepresentation != shuttleHash)
|
||||
{
|
||||
gameStarted = true;
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
@@ -1563,7 +1586,7 @@ namespace Barotrauma.Networking
|
||||
yield return CoroutineStatus.Failure;
|
||||
}
|
||||
|
||||
var selectedMissions = missionIndices.Select(i => MissionPrefab.List[i]);
|
||||
var selectedMissions = missionHashes.Select(i => MissionPrefab.Prefabs.Find(p => p.UintIdentifier == i));
|
||||
|
||||
GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedSub, gameMode, missionPrefabs: selectedMissions);
|
||||
GameMain.GameSession.StartRound(levelSeed, levelDifficulty);
|
||||
@@ -1767,7 +1790,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
GameMain.GameScreen.Select();
|
||||
|
||||
AddChatMessage($"ServerMessage.HowToCommunicate~[chatbutton]={GameMain.Config.KeyBindText(InputType.Chat)}~[radiobutton]={GameMain.Config.KeyBindText(InputType.RadioChat)}", ChatMessageType.Server);
|
||||
AddChatMessage($"ServerMessage.HowToCommunicate~[chatbutton]={GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.Chat)}~[radiobutton]={GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.RadioChat)}", ChatMessageType.Server);
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
@@ -1850,7 +1873,7 @@ namespace Barotrauma.Networking
|
||||
byte subClass = inc.ReadByte();
|
||||
bool requiredContentPackagesInstalled = inc.ReadBoolean();
|
||||
|
||||
var matchingSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == subName && s.MD5Hash.Hash == subHash);
|
||||
var matchingSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == subName && s.MD5Hash.StringRepresentation == subHash);
|
||||
if (matchingSub == null)
|
||||
{
|
||||
matchingSub = new SubmarineInfo(Path.Combine(SubmarineInfo.SavePath, subName) + ".sub", subHash, tryLoad: false)
|
||||
@@ -1913,7 +1936,7 @@ namespace Barotrauma.Networking
|
||||
if (Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("PleaseWait"), TextManager.Get(allowSpectating ? "RoundRunningSpectateEnabled" : "RoundRunningSpectateDisabled"));
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
if (!(Screen.Selected is ModDownloadScreen)) { GameMain.NetLobbyScreen.Select(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1930,7 +1953,7 @@ namespace Barotrauma.Networking
|
||||
UInt64 steamId = inc.ReadUInt64();
|
||||
UInt16 nameId = inc.ReadUInt16();
|
||||
string name = inc.ReadString();
|
||||
string preferredJob = inc.ReadString();
|
||||
Identifier preferredJob = inc.ReadIdentifier();
|
||||
byte preferredTeam = inc.ReadByte();
|
||||
UInt16 characterID = inc.ReadUInt16();
|
||||
float karma = inc.ReadSingle();
|
||||
@@ -2088,7 +2111,7 @@ namespace Barotrauma.Networking
|
||||
bool isInitialUpdate = inc.ReadBoolean();
|
||||
if (isInitialUpdate)
|
||||
{
|
||||
if (GameSettings.VerboseLogging)
|
||||
if (GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("Received initial lobby update, ID: " + updateID + ", last ID: " + GameMain.NetLobbyScreen.LastUpdateID, Color.Gray);
|
||||
}
|
||||
@@ -2253,7 +2276,10 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
break;
|
||||
case ServerNetObject.ENTITY_POSITION:
|
||||
bool isItem = inc.ReadBoolean();
|
||||
inc.ReadPadBits(); //padding is required here to make sure any padding bits within tempBuffer are read correctly
|
||||
|
||||
bool isItem = inc.ReadBoolean(); inc.ReadPadBits();
|
||||
UInt32 incomingUintIdentifier = inc.ReadUInt32();
|
||||
UInt16 id = inc.ReadUInt16();
|
||||
uint msgLength = inc.ReadVariableUInt32();
|
||||
int msgEndPos = (int)(inc.BitPosition + msgLength * 8);
|
||||
@@ -2272,11 +2298,18 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
DebugConsole.AddWarning($"Received a potentially invalid ENTITY_POSITION message. Entity type does not match (server entity is {(isItem ? "an item" : "not an item")}, client entity is {(entity?.GetType().ToString() ?? "null")}). Ignoring the message...");
|
||||
}
|
||||
else if (entity is MapEntity { Prefab: { UintIdentifier: { } uintIdentifier } } me &&
|
||||
uintIdentifier != incomingUintIdentifier)
|
||||
{
|
||||
DebugConsole.AddWarning($"Received a potentially invalid ENTITY_POSITION message."
|
||||
+$"Entity identifier does not match (server entity is {MapEntityPrefab.List.FirstOrDefault(p => p.UintIdentifier == incomingUintIdentifier)?.Identifier.Value ?? "[not found]"}, "
|
||||
+$"client entity is {me.Prefab.Identifier}). Ignoring the message...");
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.ClientRead(objHeader.Value, inc, sendingTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//force to the correct position in case the entity doesn't exist
|
||||
//or the message wasn't read correctly for whatever reason
|
||||
@@ -2382,13 +2415,13 @@ namespace Barotrauma.Networking
|
||||
var jobPreferences = GameMain.NetLobbyScreen.JobPreferences;
|
||||
if (jobPreferences.Count > 0)
|
||||
{
|
||||
outmsg.Write(jobPreferences[0].First.Identifier);
|
||||
outmsg.Write(jobPreferences[0].Prefab.Identifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
outmsg.Write("");
|
||||
}
|
||||
outmsg.Write((byte)GameMain.Config.TeamPreference);
|
||||
outmsg.Write((byte)MultiplayerPreferences.Instance.TeamPreference);
|
||||
|
||||
if (!(GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign) || campaign.LastSaveID == 0)
|
||||
{
|
||||
@@ -2512,8 +2545,8 @@ namespace Barotrauma.Networking
|
||||
msg.Write((byte)ClientPacketHeader.FILE_REQUEST);
|
||||
msg.Write((byte)FileTransferMessageType.Initiate);
|
||||
msg.Write((byte)fileType);
|
||||
if (file != null) msg.Write(file);
|
||||
if (fileHash != null) msg.Write(fileHash);
|
||||
msg.Write(file ?? throw new ArgumentNullException(nameof(file)));
|
||||
msg.Write(fileHash ?? throw new ArgumentNullException(nameof(fileHash)));
|
||||
clientPeer.Send(msg, DeliveryMethod.Reliable);
|
||||
}
|
||||
|
||||
@@ -2522,13 +2555,14 @@ namespace Barotrauma.Networking
|
||||
CancelFileTransfer(transfer.ID);
|
||||
}
|
||||
|
||||
public void UpdateFileTransfer(int id, int offset, bool reliable = false)
|
||||
public void UpdateFileTransfer(int id, int expecting, int lastSeen, bool reliable = false)
|
||||
{
|
||||
IWriteMessage msg = new WriteOnlyMessage();
|
||||
msg.Write((byte)ClientPacketHeader.FILE_REQUEST);
|
||||
msg.Write((byte)FileTransferMessageType.Data);
|
||||
msg.Write((byte)id);
|
||||
msg.Write(offset);
|
||||
msg.Write(expecting);
|
||||
msg.Write(lastSeen);
|
||||
clientPeer.Send(msg, reliable ? DeliveryMethod.Reliable : DeliveryMethod.Unreliable);
|
||||
}
|
||||
|
||||
@@ -2550,7 +2584,7 @@ namespace Barotrauma.Networking
|
||||
var newSub = new SubmarineInfo(transfer.FilePath);
|
||||
if (newSub.IsFileCorrupted) { return; }
|
||||
|
||||
var existingSubs = SubmarineInfo.SavedSubmarines.Where(s => s.Name == newSub.Name && s.MD5Hash.Hash == newSub.MD5Hash.Hash).ToList();
|
||||
var existingSubs = SubmarineInfo.SavedSubmarines.Where(s => s.Name == newSub.Name && s.MD5Hash.StringRepresentation == newSub.MD5Hash.StringRepresentation).ToList();
|
||||
foreach (SubmarineInfo existingSub in existingSubs)
|
||||
{
|
||||
existingSub.Dispose();
|
||||
@@ -2565,7 +2599,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
var subElement = subListChildren.FirstOrDefault(c =>
|
||||
((SubmarineInfo)c.UserData).Name == newSub.Name &&
|
||||
((SubmarineInfo)c.UserData).MD5Hash.Hash == newSub.MD5Hash.Hash);
|
||||
((SubmarineInfo)c.UserData).MD5Hash.StringRepresentation == newSub.MD5Hash.StringRepresentation);
|
||||
if (subElement == null) continue;
|
||||
|
||||
Color newSubTextColor = new Color(subElement.GetChild<GUITextBlock>().TextColor, 1.0f);
|
||||
@@ -2585,25 +2619,25 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (GameMain.NetLobbyScreen.FailedSelectedSub.HasValue &&
|
||||
GameMain.NetLobbyScreen.FailedSelectedSub.Value.Name == newSub.Name &&
|
||||
GameMain.NetLobbyScreen.FailedSelectedSub.Value.Hash == newSub.MD5Hash.Hash)
|
||||
GameMain.NetLobbyScreen.FailedSelectedSub.Value.Hash == newSub.MD5Hash.StringRepresentation)
|
||||
{
|
||||
GameMain.NetLobbyScreen.TrySelectSub(newSub.Name, newSub.MD5Hash.Hash, GameMain.NetLobbyScreen.SubList);
|
||||
GameMain.NetLobbyScreen.TrySelectSub(newSub.Name, newSub.MD5Hash.StringRepresentation, GameMain.NetLobbyScreen.SubList);
|
||||
}
|
||||
|
||||
if (GameMain.NetLobbyScreen.FailedSelectedShuttle.HasValue &&
|
||||
GameMain.NetLobbyScreen.FailedSelectedShuttle.Value.Name == newSub.Name &&
|
||||
GameMain.NetLobbyScreen.FailedSelectedShuttle.Value.Hash == newSub.MD5Hash.Hash)
|
||||
GameMain.NetLobbyScreen.FailedSelectedShuttle.Value.Name == newSub.MD5Hash.StringRepresentation)
|
||||
{
|
||||
GameMain.NetLobbyScreen.TrySelectSub(newSub.Name, newSub.MD5Hash.Hash, GameMain.NetLobbyScreen.ShuttleList.ListBox);
|
||||
GameMain.NetLobbyScreen.TrySelectSub(newSub.Name, newSub.MD5Hash.StringRepresentation, GameMain.NetLobbyScreen.ShuttleList.ListBox);
|
||||
}
|
||||
|
||||
NetLobbyScreen.FailedSubInfo failedCampaignSub = GameMain.NetLobbyScreen.FailedCampaignSubs.Find(s => s.Name == newSub.Name && s.Hash == newSub.MD5Hash.Hash);
|
||||
NetLobbyScreen.FailedSubInfo failedCampaignSub = GameMain.NetLobbyScreen.FailedCampaignSubs.Find(s => s.Name == newSub.Name && s.Hash == newSub.MD5Hash.StringRepresentation);
|
||||
if (failedCampaignSub != default)
|
||||
{
|
||||
GameMain.NetLobbyScreen.FailedCampaignSubs.Remove(failedCampaignSub);
|
||||
}
|
||||
|
||||
NetLobbyScreen.FailedSubInfo failedOwnedSub = GameMain.NetLobbyScreen.FailedOwnedSubs.Find(s => s.Name == newSub.Name && s.Hash == newSub.MD5Hash.Hash);
|
||||
NetLobbyScreen.FailedSubInfo failedOwnedSub = GameMain.NetLobbyScreen.FailedOwnedSubs.Find(s => s.Name == newSub.Name && s.Hash == newSub.MD5Hash.StringRepresentation);
|
||||
if (failedOwnedSub != default)
|
||||
{
|
||||
GameMain.NetLobbyScreen.ServerOwnedSubmarines.Add(newSub);
|
||||
@@ -2611,7 +2645,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
// Replace a submarine dud with the downloaded version
|
||||
SubmarineInfo existingServerSub = ServerSubmarines.Find(s => s.Name == newSub.Name && s.MD5Hash?.Hash == newSub.MD5Hash?.Hash);
|
||||
SubmarineInfo existingServerSub = ServerSubmarines.Find(s => s.Name == newSub.Name && s.MD5Hash?.StringRepresentation == newSub.MD5Hash?.StringRepresentation);
|
||||
if (existingServerSub != null)
|
||||
{
|
||||
int existingIndex = ServerSubmarines.IndexOf(existingServerSub);
|
||||
@@ -2661,6 +2695,11 @@ namespace Barotrauma.Networking
|
||||
//(as there may have been campaign updates after the save file was created)
|
||||
campaign.LastUpdateID--;
|
||||
break;
|
||||
case FileTransferType.Mod:
|
||||
if (!(Screen.Selected is ModDownloadScreen)) { return; }
|
||||
|
||||
GameMain.ModDownloadScreen.CurrentDownloadFinished(transfer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2756,24 +2795,26 @@ namespace Barotrauma.Networking
|
||||
msg.Write(characterInfo == null);
|
||||
if (characterInfo == null) return;
|
||||
|
||||
msg.Write((byte)characterInfo.Gender);
|
||||
msg.Write((byte)characterInfo.Race);
|
||||
msg.Write((byte)characterInfo.HeadSpriteId);
|
||||
msg.Write((byte)characterInfo.HairIndex);
|
||||
msg.Write((byte)characterInfo.BeardIndex);
|
||||
msg.Write((byte)characterInfo.MoustacheIndex);
|
||||
msg.Write((byte)characterInfo.FaceAttachmentIndex);
|
||||
msg.WriteColorR8G8B8(characterInfo.SkinColor);
|
||||
msg.WriteColorR8G8B8(characterInfo.HairColor);
|
||||
msg.WriteColorR8G8B8(characterInfo.FacialHairColor);
|
||||
msg.Write((byte)characterInfo.Head.Preset.TagSet.Count);
|
||||
foreach (Identifier tag in characterInfo.Head.Preset.TagSet)
|
||||
{
|
||||
msg.Write(tag);
|
||||
}
|
||||
msg.Write((byte)characterInfo.Head.HairIndex);
|
||||
msg.Write((byte)characterInfo.Head.BeardIndex);
|
||||
msg.Write((byte)characterInfo.Head.MoustacheIndex);
|
||||
msg.Write((byte)characterInfo.Head.FaceAttachmentIndex);
|
||||
msg.WriteColorR8G8B8(characterInfo.Head.SkinColor);
|
||||
msg.WriteColorR8G8B8(characterInfo.Head.HairColor);
|
||||
msg.WriteColorR8G8B8(characterInfo.Head.FacialHairColor);
|
||||
|
||||
var jobPreferences = GameMain.NetLobbyScreen.JobPreferences;
|
||||
int count = Math.Min(jobPreferences.Count, 3);
|
||||
msg.Write((byte)count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
msg.Write(jobPreferences[i].First.Identifier);
|
||||
msg.Write((byte)jobPreferences[i].Second);
|
||||
msg.Write(jobPreferences[i].Prefab.Identifier);
|
||||
msg.Write((byte)jobPreferences[i].Variant);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2976,7 +3017,7 @@ namespace Barotrauma.Networking
|
||||
msg.Write(saveName);
|
||||
msg.Write(mapSeed);
|
||||
msg.Write(sub.Name);
|
||||
msg.Write(sub.MD5Hash.Hash);
|
||||
msg.Write(sub.MD5Hash.StringRepresentation);
|
||||
settings.Serialize(msg);
|
||||
|
||||
clientPeer.Send(msg, DeliveryMethod.Reliable);
|
||||
@@ -3259,7 +3300,7 @@ namespace Barotrauma.Networking
|
||||
GameMain.NetLobbyScreen.FileTransferFrame.UserData = transfer;
|
||||
GameMain.NetLobbyScreen.FileTransferTitle.Text =
|
||||
ToolBox.LimitString(
|
||||
TextManager.GetWithVariable("DownloadingFile", "[filename]", transfer.FileName),
|
||||
TextManager.GetWithVariable("DownloadingFile", "[filename]", transfer.FileName).Value,
|
||||
GameMain.NetLobbyScreen.FileTransferTitle.Font,
|
||||
GameMain.NetLobbyScreen.FileTransferTitle.Rect.Width);
|
||||
GameMain.NetLobbyScreen.FileTransferProgressBar.BarSize = transfer.Progress;
|
||||
@@ -3279,26 +3320,25 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (EndVoteTickBox.Visible)
|
||||
{
|
||||
EndVoteTickBox.Text =
|
||||
(EndVoteTickBox.UserData as string) + " " + EndVoteCount + "/" + EndVoteMax;
|
||||
EndVoteTickBox.Text = $"{endRoundVoteText} {EndVoteCount}/{EndVoteMax}";
|
||||
}
|
||||
else
|
||||
{
|
||||
string endVoteText = TextManager.GetWithVariables("EndRoundVotes", new string[2] { "[votes]", "[max]" }, new string[2] { EndVoteCount.ToString(), EndVoteMax.ToString() });
|
||||
GUI.DrawString(spriteBatch, EndVoteTickBox.Rect.Center.ToVector2() - GUI.SmallFont.MeasureString(endVoteText) / 2,
|
||||
endVoteText,
|
||||
LocalizedString endVoteText = TextManager.GetWithVariables("EndRoundVotes", ("[votes]", EndVoteCount.ToString()), ("[max]", EndVoteMax.ToString()));
|
||||
GUI.DrawString(spriteBatch, EndVoteTickBox.Rect.Center.ToVector2() - GUIStyle.SmallFont.MeasureString(endVoteText) / 2,
|
||||
endVoteText.Value,
|
||||
Color.White,
|
||||
font: GUI.SmallFont);
|
||||
font: GUIStyle.SmallFont);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EndVoteTickBox.Text = EndVoteTickBox.UserData as string;
|
||||
EndVoteTickBox.Text = endRoundVoteText;
|
||||
}
|
||||
|
||||
if (respawnManager != null)
|
||||
{
|
||||
string respawnText = string.Empty;
|
||||
LocalizedString respawnText = string.Empty;
|
||||
Color textColor = Color.White;
|
||||
bool canChooseRespawn =
|
||||
GameMain.GameSession.GameMode is CampaignMode &&
|
||||
@@ -3316,9 +3356,9 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
else if (respawnManager.PendingRespawnCount > 0)
|
||||
{
|
||||
respawnText = TextManager.GetWithVariables("RespawnWaitingForMoreDeadPlayers",
|
||||
new string[] { "[deadplayers]", "[requireddeadplayers]" },
|
||||
new string[] { respawnManager.PendingRespawnCount.ToString(), respawnManager.RequiredRespawnCount.ToString() });
|
||||
respawnText = TextManager.GetWithVariables("RespawnWaitingForMoreDeadPlayers",
|
||||
("[deadplayers]", respawnManager.PendingRespawnCount.ToString()),
|
||||
("[requireddeadplayers]", respawnManager.RequiredRespawnCount.ToString()));
|
||||
}
|
||||
}
|
||||
else if (respawnManager.CurrentState == RespawnManager.State.Transporting &&
|
||||
@@ -3333,13 +3373,13 @@ namespace Barotrauma.Networking
|
||||
//oscillate between 0-1
|
||||
float phase = (float)(Math.Sin(timeLeft * MathHelper.Pi) + 1.0f) * 0.5f;
|
||||
//textScale = 1.0f + phase * 0.5f;
|
||||
textColor = Color.Lerp(GUI.Style.Red, Color.White, 1.0f - phase);
|
||||
textColor = Color.Lerp(GUIStyle.Red, Color.White, 1.0f - phase);
|
||||
}
|
||||
canChooseRespawn = false;
|
||||
}
|
||||
|
||||
GameMain.GameSession?.SetRespawnInfo(
|
||||
visible: !string.IsNullOrEmpty(respawnText) || canChooseRespawn, text: respawnText, textColor: textColor,
|
||||
visible: !respawnText.IsNullOrEmpty() || canChooseRespawn, text: respawnText.Value, textColor: textColor,
|
||||
buttonsVisible: canChooseRespawn, waitForNextRoundRespawn: (WaitForNextRoundRespawn ?? true));
|
||||
}
|
||||
|
||||
@@ -3352,23 +3392,23 @@ namespace Barotrauma.Networking
|
||||
int x = GameMain.GraphicsWidth - width, y = (int)(GameMain.GraphicsHeight * 0.3f);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black * 0.7f, true);
|
||||
GUI.Font.DrawString(spriteBatch, "Network statistics:", new Vector2(x + 10, y + 10), Color.White);
|
||||
GUIStyle.Font.DrawString(spriteBatch, "Network statistics:", new Vector2(x + 10, y + 10), Color.White);
|
||||
|
||||
if (client.ServerConnection != null)
|
||||
{
|
||||
GUI.Font.DrawString(spriteBatch, "Ping: " + (int)(client.ServerConnection.AverageRoundtripTime * 1000.0f) + " ms", new Vector2(x + 10, y + 25), Color.White);
|
||||
GUIStyle.Font.DrawString(spriteBatch, "Ping: " + (int)(client.ServerConnection.AverageRoundtripTime * 1000.0f) + " ms", new Vector2(x + 10, y + 25), Color.White);
|
||||
|
||||
y += 15;
|
||||
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Received bytes: " + client.Statistics.ReceivedBytes, new Vector2(x + 10, y + 45), Color.White);
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Received packets: " + client.Statistics.ReceivedPackets, new Vector2(x + 10, y + 60), Color.White);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, "Received bytes: " + client.Statistics.ReceivedBytes, new Vector2(x + 10, y + 45), Color.White);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, "Received packets: " + client.Statistics.ReceivedPackets, new Vector2(x + 10, y + 60), Color.White);
|
||||
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Sent bytes: " + client.Statistics.SentBytes, new Vector2(x + 10, y + 75), Color.White);
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Sent packets: " + client.Statistics.SentPackets, new Vector2(x + 10, y + 90), Color.White);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, "Sent bytes: " + client.Statistics.SentBytes, new Vector2(x + 10, y + 75), Color.White);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, "Sent packets: " + client.Statistics.SentPackets, new Vector2(x + 10, y + 90), Color.White);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.Font.DrawString(spriteBatch, "Disconnected", new Vector2(x + 10, y + 25), Color.White);
|
||||
GUIStyle.Font.DrawString(spriteBatch, "Disconnected", new Vector2(x + 10, y + 25), Color.White);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -3471,7 +3511,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
var banReasonPrompt = new GUIMessageBox(
|
||||
TextManager.Get(ban ? "BanReasonPrompt" : "KickReasonPrompt"),
|
||||
"", new string[] { TextManager.Get("OK"), TextManager.Get("Cancel") }, new Vector2(0.25f, 0.25f), new Point(400, 260));
|
||||
"", new LocalizedString[] { TextManager.Get("OK"), TextManager.Get("Cancel") }, new Vector2(0.25f, 0.25f), new Point(400, 260));
|
||||
|
||||
var content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.6f), banReasonPrompt.InnerFrame.RectTransform, Anchor.Center))
|
||||
{
|
||||
@@ -3489,7 +3529,7 @@ namespace Barotrauma.Networking
|
||||
if (ban)
|
||||
{
|
||||
var labelContainer = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), content.RectTransform), isHorizontal: false);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1f, 0.0f), labelContainer.RectTransform), TextManager.Get("BanDuration"), font: GUI.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
new GUITextBlock(new RectTransform(new Vector2(1f, 0.0f), labelContainer.RectTransform), TextManager.Get("BanDuration"), font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
var buttonContent = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5f), labelContainer.RectTransform), isHorizontal: true);
|
||||
permaBanTickBox = new GUITickBox(new RectTransform(new Vector2(0.4f, 0.15f), buttonContent.RectTransform), TextManager.Get("BanPermanent"))
|
||||
{
|
||||
@@ -3599,7 +3639,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (GameMain.GameSession?.GameMode != null)
|
||||
{
|
||||
errorLines.Add("Game mode: " + GameMain.GameSession.GameMode.Name);
|
||||
errorLines.Add("Game mode: " + GameMain.GameSession.GameMode.Name.Value);
|
||||
if (GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign)
|
||||
{
|
||||
errorLines.Add("Campaign ID: " + campaign.CampaignID);
|
||||
@@ -3623,19 +3663,18 @@ namespace Barotrauma.Networking
|
||||
errorLines.Add("Level: " + Level.Loaded.Seed + ", " + string.Join(", ", Level.Loaded.EqualityCheckValues.Select(cv => cv.ToString("X"))));
|
||||
errorLines.Add("Entity count before generating level: " + Level.Loaded.EntityCountBeforeGenerate);
|
||||
errorLines.Add("Entities:");
|
||||
foreach (Entity e in Level.Loaded.EntitiesBeforeGenerate)
|
||||
foreach (Entity e in Level.Loaded.EntitiesBeforeGenerate.OrderBy(e => e.CreationIndex))
|
||||
{
|
||||
errorLines.Add(" " + e.ID + ": " + e.ToString());
|
||||
errorLines.Add(e.ErrorLine);
|
||||
}
|
||||
errorLines.Add("Entity count after generating level: " + Level.Loaded.EntityCountAfterGenerate);
|
||||
}
|
||||
|
||||
errorLines.Add("Entity IDs:");
|
||||
List<Entity> sortedEntities = Entity.GetEntities().ToList();
|
||||
sortedEntities.Sort((e1, e2) => e1.ID.CompareTo(e2.ID));
|
||||
Entity[] sortedEntities = Entity.GetEntities().OrderBy(e => e.CreationIndex).ToArray();
|
||||
foreach (Entity e in sortedEntities)
|
||||
{
|
||||
errorLines.Add(e.ID + ": " + e.ToString());
|
||||
errorLines.Add(e.ErrorLine);
|
||||
}
|
||||
|
||||
errorLines.Add("");
|
||||
@@ -3645,7 +3684,7 @@ namespace Barotrauma.Networking
|
||||
errorLines.Add(" " + DebugConsole.Messages[i].Time + " - " + DebugConsole.Messages[i].Text);
|
||||
}
|
||||
|
||||
string filePath = "event_error_log_client_" + Name + "_" + DateTime.UtcNow.ToShortTimeString() + ".log";
|
||||
string filePath = $"event_error_log_client_{Name}_{DateTime.UtcNow.ToShortTimeString()}.log";
|
||||
filePath = Path.Combine(ServerLog.SavePath, ToolBox.RemoveInvalidFileNameChars(filePath));
|
||||
|
||||
if (!Directory.Exists(ServerLog.SavePath))
|
||||
|
||||
Reference in New Issue
Block a user