(4b1fa5c86) Fixed client-side console errors during campaign setup because the client tried to load save files that only exist server-side. Now the server sends the information needed for the campaign setup window in the CAMPAIGN_SETUP_INFO message.
This commit is contained in:
@@ -269,7 +269,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (string saveFile in saveFiles)
|
foreach (string saveFile in saveFiles)
|
||||||
{
|
{
|
||||||
XDocument doc = SaveUtil.LoadGameSessionDoc(saveFile);
|
string fileName = saveFile;
|
||||||
|
string subName = "";
|
||||||
|
string saveTime = "";
|
||||||
var saveFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), saveList.Content.RectTransform), style: "ListBoxElement")
|
var saveFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), saveList.Content.RectTransform), style: "ListBoxElement")
|
||||||
{
|
{
|
||||||
UserData = saveFile
|
UserData = saveFile
|
||||||
@@ -277,25 +279,38 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var nameText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), saveFrame.RectTransform),
|
var nameText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), saveFrame.RectTransform),
|
||||||
text: Path.GetFileNameWithoutExtension(saveFile));
|
text: Path.GetFileNameWithoutExtension(saveFile));
|
||||||
if (doc?.Root == null)
|
|
||||||
|
if (!isMultiplayer)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error loading save file \"" + saveFile + "\". The file may be corrupted.");
|
XDocument doc = SaveUtil.LoadGameSessionDoc(saveFile);
|
||||||
nameText.Color = Color.Red;
|
if (doc?.Root == null)
|
||||||
continue;
|
{
|
||||||
|
DebugConsole.ThrowError("Error loading save file \"" + saveFile + "\". The file may be corrupted.");
|
||||||
|
nameText.Color = Color.Red;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
subName = doc.Root.GetAttributeString("submarine", "");
|
||||||
|
saveTime = doc.Root.GetAttributeString("savetime", "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string[] splitSaveFile = saveFile.Split(';');
|
||||||
|
saveFrame.UserData = splitSaveFile[0];
|
||||||
|
fileName = nameText.Text = Path.GetFileNameWithoutExtension(splitSaveFile[0]);
|
||||||
|
if (splitSaveFile.Length > 1) { subName = splitSaveFile[1]; }
|
||||||
|
if (splitSaveFile.Length > 2) { saveTime = splitSaveFile[2]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
string submarineName = doc.Root.GetAttributeString("submarine", "");
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), saveFrame.RectTransform, Anchor.BottomLeft),
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), saveFrame.RectTransform, Anchor.BottomLeft),
|
||||||
text: submarineName, font: GUI.SmallFont)
|
text: subName, font: GUI.SmallFont)
|
||||||
{
|
{
|
||||||
UserData = saveFile
|
UserData = fileName
|
||||||
};
|
};
|
||||||
|
|
||||||
string saveTime = doc.Root.GetAttributeString("savetime", "");
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), saveFrame.RectTransform),
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), saveFrame.RectTransform),
|
||||||
text: saveTime, textAlignment: Alignment.Right, font: GUI.SmallFont)
|
text: saveTime, textAlignment: Alignment.Right, font: GUI.SmallFont)
|
||||||
{
|
{
|
||||||
UserData = saveFile
|
UserData = fileName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,6 +364,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool SelectSaveFile(GUIComponent component, object obj)
|
private bool SelectSaveFile(GUIComponent component, object obj)
|
||||||
{
|
{
|
||||||
|
if (isMultiplayer)
|
||||||
|
{
|
||||||
|
loadGameButton.Enabled = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
string fileName = (string)obj;
|
string fileName = (string)obj;
|
||||||
|
|
||||||
XDocument doc = SaveUtil.LoadGameSessionDoc(fileName);
|
XDocument doc = SaveUtil.LoadGameSessionDoc(fileName);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using System.Text;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Barotrauma.Steam;
|
using Barotrauma.Steam;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma.Networking
|
namespace Barotrauma.Networking
|
||||||
{
|
{
|
||||||
@@ -1125,9 +1126,22 @@ namespace Barotrauma.Networking
|
|||||||
UInt16 modeIndex = inc.ReadUInt16();
|
UInt16 modeIndex = inc.ReadUInt16();
|
||||||
if (GameMain.NetLobbyScreen.GameModes[modeIndex].Identifier.ToLowerInvariant() == "multiplayercampaign")
|
if (GameMain.NetLobbyScreen.GameModes[modeIndex].Identifier.ToLowerInvariant() == "multiplayercampaign")
|
||||||
{
|
{
|
||||||
|
string[] saveFiles = SaveUtil.GetSaveFiles(SaveUtil.SaveType.Multiplayer);
|
||||||
|
for (int i = 0; i < saveFiles.Length; i++)
|
||||||
|
{
|
||||||
|
XDocument doc = SaveUtil.LoadGameSessionDoc(saveFiles[i]);
|
||||||
|
if (doc?.Root != null)
|
||||||
|
{
|
||||||
|
saveFiles[i] =
|
||||||
|
string.Join(";",
|
||||||
|
saveFiles[i].Replace(';', ' '),
|
||||||
|
doc.Root.GetAttributeString("submarine", ""),
|
||||||
|
doc.Root.GetAttributeString("savetime", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NetOutgoingMessage msg = server.CreateMessage();
|
NetOutgoingMessage msg = server.CreateMessage();
|
||||||
msg.Write((byte)ServerPacketHeader.CAMPAIGN_SETUP_INFO);
|
msg.Write((byte)ServerPacketHeader.CAMPAIGN_SETUP_INFO);
|
||||||
string[] saveFiles = SaveUtil.GetSaveFiles(SaveUtil.SaveType.Multiplayer);
|
|
||||||
msg.Write((UInt16)saveFiles.Count());
|
msg.Write((UInt16)saveFiles.Count());
|
||||||
foreach (string saveFile in saveFiles)
|
foreach (string saveFile in saveFiles)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user