(1968ab79f) v0.9.9.1

This commit is contained in:
Joonas Rikkonen
2020-04-30 14:09:23 +03:00
parent ac37a3b0e4
commit ce4ccd99ac
23 changed files with 131 additions and 55 deletions
@@ -343,15 +343,17 @@ namespace Barotrauma
UInt16 targetEntityID = msg.ReadUInt16(); UInt16 targetEntityID = msg.ReadUInt16();
int targetLimbIndex = msg.ReadByte(); int targetLimbIndex = msg.ReadByte();
//255 = entity already removed, no need to do anything
if (attackLimbIndex == 255) { break; }
if (attackLimbIndex >= AnimController.Limbs.Length) if (attackLimbIndex >= AnimController.Limbs.Length)
{ {
DebugConsole.ThrowError($"Received invalid ExecuteAttack message. Limb index out of bounds ({attackLimbIndex})"); DebugConsole.ThrowError($"Received invalid ExecuteAttack message. Limb index out of bounds ({attackLimbIndex})");
break; break;
} }
Limb attackLimb = AnimController.Limbs[attackLimbIndex]; Limb attackLimb = AnimController.Limbs[attackLimbIndex];
IDamageable targetEntity = FindEntityByID(targetEntityID) as IDamageable;
Limb targetLimb = null; Limb targetLimb = null;
if (targetEntity == null) if (!(FindEntityByID(targetEntityID) is IDamageable targetEntity))
{ {
DebugConsole.ThrowError($"Received invalid ExecuteAttack message. Target entity not found (ID {targetEntityID})"); DebugConsole.ThrowError($"Received invalid ExecuteAttack message. Target entity not found (ID {targetEntityID})");
break; break;
@@ -365,8 +367,10 @@ namespace Barotrauma
} }
targetLimb = targetCharacter.AnimController.Limbs[targetLimbIndex]; targetLimb = targetCharacter.AnimController.Limbs[targetLimbIndex];
} }
if (attackLimb?.attack != null)
attackLimb.ExecuteAttack(targetEntity, targetLimb, out _); {
attackLimb.ExecuteAttack(targetEntity, targetLimb, out _);
}
break; break;
} }
msg.ReadPadBits(); msg.ReadPadBits();
@@ -2124,6 +2124,7 @@ namespace Barotrauma.Networking
GameMain.GameSession.SubmarineInfo = new SubmarineInfo(subPath, ""); GameMain.GameSession.SubmarineInfo = new SubmarineInfo(subPath, "");
} }
SaveUtil.LoadGame(GameMain.GameSession.SavePath, GameMain.GameSession); SaveUtil.LoadGame(GameMain.GameSession.SavePath, GameMain.GameSession);
GameMain.GameSession?.SubmarineInfo?.Reload();
GameMain.GameSession?.SubmarineInfo?.CheckSubsLeftBehind(); GameMain.GameSession?.SubmarineInfo?.CheckSubsLeftBehind();
if (GameMain.GameSession?.SubmarineInfo?.Name != null) if (GameMain.GameSession?.SubmarineInfo?.Name != null)
{ {
@@ -3007,6 +3008,11 @@ namespace Barotrauma.Networking
if (GameMain.GameSession?.GameMode != null) if (GameMain.GameSession?.GameMode != null)
{ {
errorLines.Add("Game mode: " + GameMain.GameSession.GameMode.Name); errorLines.Add("Game mode: " + GameMain.GameSession.GameMode.Name);
if (GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign)
{
errorLines.Add("Campaign ID: " + campaign.CampaignID);
errorLines.Add("Campaign save ID: " + campaign.LastSaveID + "(pending: " + campaign.PendingSaveID + ")");
}
} }
if (GameMain.GameSession?.Submarine != null) if (GameMain.GameSession?.Submarine != null)
{ {
@@ -3015,6 +3021,13 @@ namespace Barotrauma.Networking
if (Level.Loaded != null) if (Level.Loaded != null)
{ {
errorLines.Add("Level: " + Level.Loaded.Seed + ", " + Level.Loaded.EqualityCheckVal); errorLines.Add("Level: " + Level.Loaded.Seed + ", " + Level.Loaded.EqualityCheckVal);
errorLines.Add("Entity count before generating level: " + Level.Loaded.EntityCountBeforeGenerate);
errorLines.Add("Entities:");
foreach (Entity e in Level.Loaded.EntitiesBeforeGenerate)
{
errorLines.Add(" " + e.ID + ": " + e.ToString());
}
errorLines.Add("Entity count after generating level: " + Level.Loaded.EntityCountAfterGenerate);
} }
errorLines.Add("Entity IDs:"); errorLines.Add("Entity IDs:");
@@ -370,7 +370,7 @@ namespace Barotrauma.Steam
if (Enum.TryParse(lobby.GetData("traitors"), out YesNoMaybe traitorsEnabled)) { serverInfo.TraitorsEnabled = traitorsEnabled; } if (Enum.TryParse(lobby.GetData("traitors"), out YesNoMaybe traitorsEnabled)) { serverInfo.TraitorsEnabled = traitorsEnabled; }
serverInfo.GameStarted = lobby.GetData("gamestarted") == "True"; serverInfo.GameStarted = lobby.GetData("gamestarted") == "True";
serverInfo.GameMode = lobby.GetData("gamemode"); serverInfo.GameMode = lobby.GetData("gamemode") ?? "";
if (Enum.TryParse(lobby.GetData("playstyle"), out PlayStyle playStyle)) serverInfo.PlayStyle = playStyle; if (Enum.TryParse(lobby.GetData("playstyle"), out PlayStyle playStyle)) serverInfo.PlayStyle = playStyle;
if (serverInfo.ContentPackageNames.Count != serverInfo.ContentPackageHashes.Count || if (serverInfo.ContentPackageNames.Count != serverInfo.ContentPackageHashes.Count ||
@@ -1052,7 +1052,7 @@ namespace Barotrauma.Steam
Directory.CreateDirectory(targetPath); Directory.CreateDirectory(targetPath);
File.WriteAllText(copyingPath, "TEMPORARY FILE"); File.WriteAllText(copyingPath, "TEMPORARY FILE");
SaveUtil.CopyFolder(item?.Directory, targetPath, copySubDirs: true, overwriteExisting: true); SaveUtil.CopyFolder(item?.Directory, targetPath, copySubDirs: true, overwriteExisting: item?.Owner.Id != Steamworks.SteamClient.SteamId);
File.Delete(copyingPath); File.Delete(copyingPath);
return ""; return "";
@@ -1145,7 +1145,7 @@ namespace Barotrauma.Steam
//make sure the destination directory exists //make sure the destination directory exists
Directory.CreateDirectory(Path.GetDirectoryName(contentFile.Path)); Directory.CreateDirectory(Path.GetDirectoryName(contentFile.Path));
CorrectContentFileCopy(contentPackage, sourceFile, contentFile.Path, overwrite: true); CorrectContentFileCopy(contentPackage, sourceFile, contentFile.Path, overwrite: item?.Owner.Id != Steamworks.SteamClient.SteamId);
} }
foreach (string nonContentFile in nonContentFiles) foreach (string nonContentFile in nonContentFiles)
@@ -1154,7 +1154,7 @@ namespace Barotrauma.Steam
if (!File.Exists(sourceFile)) { continue; } if (!File.Exists(sourceFile)) { continue; }
string destinationPath = CorrectContentFilePath(nonContentFile, contentPackage, false); string destinationPath = CorrectContentFilePath(nonContentFile, contentPackage, false);
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)); Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
CorrectContentFileCopy(contentPackage, sourceFile, destinationPath, overwrite: true); CorrectContentFileCopy(contentPackage, sourceFile, destinationPath, overwrite: item?.Owner.Id != Steamworks.SteamClient.SteamId);
} }
File.Delete(copyingPath); File.Delete(copyingPath);
@@ -1507,6 +1507,8 @@ namespace Barotrauma.Steam
private static void CorrectContentFileCopy(ContentPackage package, string src, string dest, bool overwrite) private static void CorrectContentFileCopy(ContentPackage package, string src, string dest, bool overwrite)
{ {
if (!overwrite && File.Exists(dest)) { return; }
if (Path.GetExtension(src).Equals(".xml", StringComparison.OrdinalIgnoreCase)) if (Path.GetExtension(src).Equals(".xml", StringComparison.OrdinalIgnoreCase))
{ {
XDocument doc = XMLExtensions.TryLoadXml(src); XDocument doc = XMLExtensions.TryLoadXml(src);
@@ -1529,12 +1531,12 @@ namespace Barotrauma.Steam
} }
else else
{ {
File.Copy(src, dest, overwrite: overwrite); File.Copy(src, dest, overwrite: true);
} }
} }
else else
{ {
File.Copy(src, dest, overwrite: overwrite); File.Copy(src, dest, overwrite: true);
} }
} }
@@ -148,7 +148,8 @@ namespace Barotrauma
if (GameMain.Config != null) if (GameMain.Config != null)
{ {
sb.AppendLine("Graphics mode: " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight + " (" + GameMain.Config.WindowMode.ToString() + ")"); sb.AppendLine("Graphics mode: " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight + " (" + GameMain.Config.WindowMode.ToString() + ")");
sb.AppendLine("VSync "+ (GameMain.Config.VSyncEnabled ? "ON" : "OFF")); sb.AppendLine("VSync " + (GameMain.Config.VSyncEnabled ? "ON" : "OFF"));
sb.AppendLine("Language: " + (GameMain.Config.Language ?? "none"));
} }
if (GameMain.SelectedPackages != null) if (GameMain.SelectedPackages != null)
{ {
@@ -422,7 +422,7 @@ namespace Barotrauma
} }
// Game mode Selection // Game mode Selection
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), filters.Content.RectTransform), TextManager.Get("gamemode")) { CanBeFocused = false }; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), filters.Content.RectTransform), TextManager.Get("gamemode"), font: GUI.SubHeadingFont) { CanBeFocused = false };
gameModeTickBoxes = new List<GUITickBox>(); gameModeTickBoxes = new List<GUITickBox>();
foreach (GameModePreset mode in GameModePreset.List) foreach (GameModePreset mode in GameModePreset.List)
@@ -1013,7 +1013,7 @@ namespace Barotrauma
foreach (GUITickBox tickBox in gameModeTickBoxes) foreach (GUITickBox tickBox in gameModeTickBoxes)
{ {
var gameMode = (string)tickBox.UserData; var gameMode = (string)tickBox.UserData;
if (!tickBox.Selected && serverInfo.GameMode.Equals(gameMode, StringComparison.OrdinalIgnoreCase)) if (!tickBox.Selected && serverInfo.GameMode != null && serverInfo.GameMode.Equals(gameMode, StringComparison.OrdinalIgnoreCase))
{ {
child.Visible = false; child.Visible = false;
break; break;
@@ -3103,8 +3103,7 @@ namespace Barotrauma
} }
} }
// TODO adjust when the new inventory stuff rolls in if (GameMain.Config.KeyBind(InputType.ToggleInventory).IsHit() && mode == Mode.Default)
if (PlayerInput.KeyHit(Keys.Q) && mode == Mode.Default)
{ {
toggleEntityMenuButton.OnClicked?.Invoke(toggleEntityMenuButton, toggleEntityMenuButton.UserData); toggleEntityMenuButton.OnClicked?.Invoke(toggleEntityMenuButton, toggleEntityMenuButton.UserData);
} }
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>0.9.9.0</Version> <Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
+1 -1
View File
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>0.9.9.0</Version> <Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>0.9.9.0</Version> <Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>0.9.9.0</Version> <Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
+1 -1
View File
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>0.9.9.0</Version> <Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
@@ -298,7 +298,7 @@ namespace Barotrauma
UInt16 targetEntityID = (UInt16)extraData[2]; UInt16 targetEntityID = (UInt16)extraData[2];
int targetLimbIndex = extraData.Length > 3 ? (int)extraData[3] : 0; int targetLimbIndex = extraData.Length > 3 ? (int)extraData[3] : 0;
msg.WriteRangedInteger(4, 0, 4); msg.WriteRangedInteger(4, 0, 4);
msg.Write((byte)(Removed ? 0 : Array.IndexOf(AnimController.Limbs, attackLimb))); msg.Write((byte)(Removed ? 255 : Array.IndexOf(AnimController.Limbs, attackLimb)));
msg.Write(targetEntityID); msg.Write(targetEntityID);
msg.Write((byte)targetLimbIndex); msg.Write((byte)targetLimbIndex);
break; break;
@@ -842,6 +842,11 @@ namespace Barotrauma.Networking
if (GameMain.GameSession?.GameMode != null) if (GameMain.GameSession?.GameMode != null)
{ {
errorLines.Add("Game mode: " + GameMain.GameSession.GameMode.Name); errorLines.Add("Game mode: " + GameMain.GameSession.GameMode.Name);
if (GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign)
{
errorLines.Add("Campaign ID: " + campaign.CampaignID);
errorLines.Add("Campaign save ID: " + campaign.LastSaveID);
}
} }
if (GameMain.GameSession?.Submarine != null) if (GameMain.GameSession?.Submarine != null)
{ {
@@ -850,6 +855,13 @@ namespace Barotrauma.Networking
if (Level.Loaded != null) if (Level.Loaded != null)
{ {
errorLines.Add("Level: " + Level.Loaded.Seed + ", " + Level.Loaded.EqualityCheckVal); errorLines.Add("Level: " + Level.Loaded.Seed + ", " + Level.Loaded.EqualityCheckVal);
errorLines.Add("Entity count before generating level: " + Level.Loaded.EntityCountBeforeGenerate);
errorLines.Add("Entities:");
foreach (Entity e in Level.Loaded.EntitiesBeforeGenerate)
{
errorLines.Add(" " + e.ID + ": " + e.ToString());
}
errorLines.Add("Entity count after generating level: " + Level.Loaded.EntityCountAfterGenerate);
} }
errorLines.Add("Entity IDs:"); errorLines.Add("Entity IDs:");
@@ -93,6 +93,10 @@ namespace Barotrauma
sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! "); sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
sb.AppendLine("\n"); sb.AppendLine("\n");
sb.AppendLine("Game version " + GameMain.Version + " (" + AssemblyInfo.GetBuildString() + ", branch " + AssemblyInfo.GetGitBranch() + ", revision " + AssemblyInfo.GetGitRevision() + ")"); sb.AppendLine("Game version " + GameMain.Version + " (" + AssemblyInfo.GetBuildString() + ", branch " + AssemblyInfo.GetGitBranch() + ", revision " + AssemblyInfo.GetGitRevision() + ")");
if (GameMain.Config != null)
{
sb.AppendLine("Language: " + (GameMain.Config.Language ?? "none"));
}
if (GameMain.SelectedPackages != null) if (GameMain.SelectedPackages != null)
{ {
sb.AppendLine("Selected content packages: " + (!GameMain.SelectedPackages.Any() ? "None" : string.Join(", ", GameMain.SelectedPackages.Select(c => c.Name)))); sb.AppendLine("Selected content packages: " + (!GameMain.SelectedPackages.Any() ? "None" : string.Join(", ", GameMain.SelectedPackages.Select(c => c.Name))));
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>0.9.9.0</Version> <Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
@@ -2908,7 +2908,10 @@ namespace Barotrauma
causeOfDeathAffliction?.Source ?? LastAttacker, LastDamageSource); causeOfDeathAffliction?.Source ?? LastAttacker, LastDamageSource);
OnDeath?.Invoke(this, CauseOfDeath); OnDeath?.Invoke(this, CauseOfDeath);
SteamAchievementManager.OnCharacterKilled(this, CauseOfDeath); if (GameMain.GameSession != null && Screen.Selected == GameMain.GameScreen)
{
SteamAchievementManager.OnCharacterKilled(this, CauseOfDeath);
}
KillProjSpecific(causeOfDeath, causeOfDeathAffliction, log); KillProjSpecific(causeOfDeath, causeOfDeathAffliction, log);
@@ -8,6 +8,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using Barotrauma.Extensions; using Barotrauma.Extensions;
using FarseerPhysics.Dynamics;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
{ {
@@ -655,7 +656,8 @@ namespace Barotrauma.Items.Components
end -= target.Submarine.SimPosition; end -= target.Submarine.SimPosition;
} }
var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel; var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel;
var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true); var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true,
customPredicate: (Fixture f) => { return !item.StaticFixtures.Contains(f); });
if (pickedBody == null) { return; } if (pickedBody == null) { return; }
Character targetCharacter = null; Character targetCharacter = null;
if (pickedBody.UserData is Character c) if (pickedBody.UserData is Character c)
@@ -817,7 +819,8 @@ namespace Barotrauma.Items.Components
end -= closestEnemy.Submarine.SimPosition; end -= closestEnemy.Submarine.SimPosition;
} }
var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel; var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel;
var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true); var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true,
customPredicate: (Fixture f) => { return !item.StaticFixtures.Contains(f); });
if (pickedBody == null) { return false; } if (pickedBody == null) { return false; }
Character targetCharacter = null; Character targetCharacter = null;
if (pickedBody.UserData is Character c) if (pickedBody.UserData is Character c)
@@ -166,6 +166,11 @@ namespace Barotrauma
private set; private set;
} }
public List<Entity> EntitiesBeforeGenerate { get; private set; } = new List<Entity>();
public int EntityCountBeforeGenerate { get; private set; }
public int EntityCountAfterGenerate { get; private set; }
public float Difficulty public float Difficulty
{ {
get; get;
@@ -281,8 +286,11 @@ namespace Barotrauma
public void Generate(bool mirror) public void Generate(bool mirror)
{ {
if (loaded != null) loaded.Remove(); if (loaded != null) { loaded.Remove(); }
loaded = this; loaded = this;
EntitiesBeforeGenerate = GetEntityList();
EntityCountBeforeGenerate = EntitiesBeforeGenerate.Count();
levelObjectManager = new LevelObjectManager(); levelObjectManager = new LevelObjectManager();
@@ -759,6 +767,8 @@ namespace Barotrauma
DebugConsole.NewMessage("Generated level with the seed " + seed + " (type: " + generationParams.Name + ")", Color.White); DebugConsole.NewMessage("Generated level with the seed " + seed + " (type: " + generationParams.Name + ")", Color.White);
} }
EntityCountAfterGenerate = Entity.GetEntityList().Count();
//assign an ID to make entity events work //assign an ID to make entity events work
ID = FindFreeID(); ID = FindFreeID();
} }
@@ -215,7 +215,7 @@ namespace Barotrauma
public override string ToString() public override string ToString()
{ {
return "Barotrauma.Submarine (" + Info?.Name ?? "[NULL INFO]" + ")"; return "Barotrauma.Submarine (" + (Info?.Name ?? "[NULL INFO]") + ", " + IdOffset + ")";
} }
public override bool Removed public override bool Removed
@@ -1231,9 +1231,12 @@ namespace Barotrauma
public bool SaveAs(string filePath, MemoryStream previewImage = null) public bool SaveAs(string filePath, MemoryStream previewImage = null)
{ {
var newInfo = new SubmarineInfo(this); var newInfo = new SubmarineInfo(this)
newInfo.FilePath = filePath; {
newInfo.Name = Path.GetFileNameWithoutExtension(filePath); GameVersion = GameMain.Version,
FilePath = filePath,
Name = Path.GetFileNameWithoutExtension(filePath)
};
Info.Dispose(); Info = newInfo; Info.Dispose(); Info = newInfo;
return newInfo.SaveAs(filePath, previewImage); return newInfo.SaveAs(filePath, previewImage);
@@ -101,7 +101,11 @@ namespace Barotrauma
set; set;
} }
public readonly XElement SubmarineElement; public XElement SubmarineElement
{
get;
private set;
}
public override string ToString() public override string ToString()
{ {
@@ -180,28 +184,7 @@ namespace Barotrauma
if (element == null && tryLoad) if (element == null && tryLoad)
{ {
XDocument doc = null; Reload();
int maxLoadRetries = 4;
for (int i = 0; i <= maxLoadRetries; i++)
{
doc = OpenFile(filePath, out Exception e);
if (e != null && !(e is IOException)) { break; }
if (doc != null || i == maxLoadRetries || !File.Exists(filePath)) { break; }
DebugConsole.NewMessage("Opening submarine file \"" + filePath + "\" failed, retrying in 250 ms...");
Thread.Sleep(250);
}
if (doc == null || doc.Root == null)
{
IsFileCorrupted = true;
return;
}
if (string.IsNullOrWhiteSpace(hash))
{
StartHashDocTask(doc);
}
SubmarineElement = doc.Root;
} }
else else
{ {
@@ -215,6 +198,7 @@ namespace Barotrauma
public SubmarineInfo(Submarine sub) : this(sub.Info) public SubmarineInfo(Submarine sub) : this(sub.Info)
{ {
GameVersion = GameMain.Version;
SubmarineElement = new XElement("Submarine"); SubmarineElement = new XElement("Submarine");
sub.SaveToXElement(SubmarineElement); sub.SaveToXElement(SubmarineElement);
Init(); Init();
@@ -242,6 +226,30 @@ namespace Barotrauma
#endif #endif
} }
public void Reload()
{
XDocument doc = null;
int maxLoadRetries = 4;
for (int i = 0; i <= maxLoadRetries; i++)
{
doc = OpenFile(FilePath, out Exception e);
if (e != null && !(e is IOException)) { break; }
if (doc != null || i == maxLoadRetries || !File.Exists(FilePath)) { break; }
DebugConsole.NewMessage("Opening submarine file \"" + FilePath + "\" failed, retrying in 250 ms...");
Thread.Sleep(250);
}
if (doc == null || doc.Root == null)
{
IsFileCorrupted = true;
return;
}
if (hash == null)
{
StartHashDocTask(doc);
}
SubmarineElement = doc.Root;
}
private void Init() private void Init()
{ {
DisplayName = TextManager.Get("Submarine.Name." + Name, true); DisplayName = TextManager.Get("Submarine.Name." + Name, true);
@@ -371,7 +371,7 @@ namespace Barotrauma
if (charactersInSub.Count == 1) if (charactersInSub.Count == 1)
{ {
//there must be some non-enemy casualties to get the last mant standing achievement //there must be some non-enemy casualties to get the last mant standing achievement
if (roundData.Casualties.Any(c => !(c.AIController is EnemyAIController))) if (roundData.Casualties.Any(c => !(c.AIController is EnemyAIController) && c.TeamID == charactersInSub[0].TeamID))
{ {
UnlockAchievement(charactersInSub[0], "lastmanstanding"); UnlockAchievement(charactersInSub[0], "lastmanstanding");
} }
@@ -410,7 +410,8 @@ namespace Barotrauma
foreach (FileInfo file in files) foreach (FileInfo file in files)
{ {
string tempPath = Path.Combine(destDirName, file.Name); string tempPath = Path.Combine(destDirName, file.Name);
file.CopyTo(tempPath, overwriteExisting); if (!overwriteExisting && File.Exists(tempPath)) { continue; }
file.CopyTo(tempPath, true);
} }
// If copying subdirectories, copy them and their contents to new location. // If copying subdirectories, copy them and their contents to new location.
+13
View File
@@ -1,3 +1,16 @@
---------------------------------------------------------------------------------------------------------
v0.9.9.1
---------------------------------------------------------------------------------------------------------
- Fixed bots being unable to fire turrets due to the visibility raycast hitting the turret's collider.
- Fixed submarine's version number resetting to 0.0.0.0 when saving in the sub editor (didn't affect the actual saved sub file, only the in-game metadata that got fixed by restarting the game - so there's no need to do anything to fix the sub files you saved with the previous version).
- Fixed server list occasionally crashing when trying to filter based on game mode.
- Fixed an issue in multiplayer campaign that occasionally caused clients to get kicked with a "missing entity" error message.
- Fixed clients occasionally crashing when joining a server mid-round. Happened when the client tried to execute the attack of a monster that has already despawned server-side.
- Fixed local changes an user has made to a mod getting overwritten when the item gets autoupdated.
- Changed the hotkey to toggle the entity list in the sub editor from Q to the "toggle inventory" keybind to make it a little more user-friendly on AZERTY keyboards.
- Fixed corpses in wrecks being considered dead members of the crew in SteamAchievementManager, preventing "lone sailor" from unlocking and making it possible to unlock "last man standing" with just one character.
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
v0.9.9.0 v0.9.9.0
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------