v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -121,21 +121,21 @@ namespace Barotrauma
{
if (string.IsNullOrWhiteSpace(savePath)) { return; }
GameMain.GameSession = new GameSession(new SubmarineInfo(subPath), savePath, GameModePreset.MultiPlayerCampaign, startingSettings, seed);
GameMain.GameSession = new GameSession(new SubmarineInfo(subPath), Option.None, CampaignDataPath.CreateRegular(savePath), GameModePreset.MultiPlayerCampaign, startingSettings, seed);
GameMain.NetLobbyScreen.ToggleCampaignMode(true);
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
SaveUtil.SaveGame(GameMain.GameSession.DataPath);
DebugConsole.NewMessage("Campaign started!", Color.Cyan);
DebugConsole.NewMessage("Current location: " + GameMain.GameSession.Map.CurrentLocation.DisplayName, Color.Cyan);
((MultiPlayerCampaign)GameMain.GameSession.GameMode).LoadInitialLevel();
}
public static void LoadCampaign(string selectedSave, Client client)
public static void LoadCampaign(CampaignDataPath path, Client client)
{
GameMain.NetLobbyScreen.ToggleCampaignMode(true);
try
{
SaveUtil.LoadGame(selectedSave);
SaveUtil.LoadGame(path);
if (GameMain.GameSession.GameMode is MultiPlayerCampaign mpCampaign)
{
mpCampaign.LastSaveID++;
@@ -148,7 +148,7 @@ namespace Barotrauma
}
catch (Exception e)
{
string errorMsg = $"Error while loading the save {selectedSave}";
string errorMsg = $"Error while loading the save {path.LoadPath}";
if (client != null)
{
GameMain.Server?.SendDirectChatMessage($"{errorMsg}: {e.Message}\n{e.StackTrace}", client, ChatMessageType.Error);
@@ -209,7 +209,7 @@ namespace Barotrauma
{
try
{
LoadCampaign(saveFiles[saveIndex].FilePath, client: null);
LoadCampaign(CampaignDataPath.CreateRegular(saveFiles[saveIndex].FilePath), client: null);
}
catch (Exception ex)
{
@@ -289,7 +289,8 @@ namespace Barotrauma
data.Refresh(character, refreshHealthData: character.CauseOfDeath?.Type != CauseOfDeathType.Disconnected);
characterData.Add(data);
}
else
//check the cause of death in the CharacterInfo too (the character instance may have despawned, so we can't just rely on that)
else if (data.CharacterInfo.CauseOfDeath is not { Type: CauseOfDeathType.Disconnected })
{
//character dead or removed -> reduce skills, remove items, health data, etc
data.CharacterInfo.ApplyDeathEffects();
@@ -406,13 +407,13 @@ namespace Barotrauma
LeaveUnconnectedSubs(leavingSub);
NextLevel = newLevel;
GameMain.GameSession.SubmarineInfo = new SubmarineInfo(GameMain.GameSession.Submarine);
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
SaveUtil.SaveGame(GameMain.GameSession.DataPath);
}
else
{
PendingSubmarineSwitch = null;
GameMain.Server.EndGame(TransitionType.None, wasSaved: false);
LoadCampaign(GameMain.GameSession.SavePath, client: null);
LoadCampaign(GameMain.GameSession.DataPath, client: null);
LastSaveID++;
IncrementAllLastUpdateIds();
yield return CoroutineStatus.Success;
@@ -1229,7 +1230,7 @@ namespace Barotrauma
if (renameCharacter)
{
renamedIdentifier = msg.ReadUInt16();
newName = msg.ReadString();
newName = Client.SanitizeName(msg.ReadString());
existingCrewMember = msg.ReadBoolean();
if (!GameMain.Server.IsNameValid(sender, newName))
{
@@ -1466,7 +1467,16 @@ namespace Barotrauma
return wallet.Balance + Bank.Balance;
}
public override void Save(XElement element)
/// <summary>
/// Serializes the campaign and character data to XML.
/// </summary>
/// <param name="element">Game session element to save the campaign data to.</param>
/// <param name="isSavingOnLoading">
/// Whether the save is being done during loading to ensure the campaign ID matches the one in the save file.
/// Used to work around some quirks with the backup save system.
/// See: <see cref="SaveUtil.SaveGame(CampaignDataPath,bool)"/>
/// </param>
public override void Save(XElement element, bool isSavingOnLoading)
{
element.Add(new XAttribute("campaignid", CampaignID));
XElement modeElement = new XElement("MultiPlayerCampaign",
@@ -1516,8 +1526,16 @@ namespace Barotrauma
element.Add(modeElement);
//save character data to a separate file
string characterDataPath = GetCharacterDataSavePath();
// save character data to a separate file
// When loading a campaign in multiplayer, we save the campaign to ensure the campaign ID that gets assigned
// matches the one in the save file, this is a problem with the backup save system since this causes the
// character data to save too, and we don't want to overwrite the main save file's character data.
// So we instead save over the load path in this case, which in backup saves is the backup file
// which we don't mind getting overriden since the data should be the same
string characterDataPath = isSavingOnLoading
? GetCharacterDataPathForLoading()
: GetCharacterDataPathForSaving();
XDocument characterDataDoc = new XDocument(new XElement("CharacterData"));
foreach (CharacterCampaignData cd in characterData)
{
@@ -1525,6 +1543,7 @@ namespace Barotrauma
}
try
{
SaveUtil.DeleteIfExists(characterDataPath);
characterDataDoc.SaveSafe(characterDataPath);
}
catch (Exception e)
@@ -1544,7 +1563,7 @@ namespace Barotrauma
/// eg. when using this method to save a character itself restored from the backup.</param>
public void SaveSingleCharacter(CharacterCampaignData newData, bool skipBackup = false)
{
string characterDataPath = GetCharacterDataSavePath();
string characterDataPath = GetCharacterDataPathForSaving();
if (!File.Exists(characterDataPath))
{
DebugConsole.ThrowError($"Failed to load the character data for the campaign. Could not find the file \"{characterDataPath}\".");