Skip to content

Commit

Permalink
(1968ab79f) v0.9.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Regalis11 committed Apr 30, 2020
1 parent ac37a3b commit ce4ccd9
Show file tree
Hide file tree
Showing 23 changed files with 131 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,17 @@ public virtual void ClientRead(ServerNetObject type, IReadMessage msg, float sen
UInt16 targetEntityID = msg.ReadUInt16();
int targetLimbIndex = msg.ReadByte();

//255 = entity already removed, no need to do anything
if (attackLimbIndex == 255) { break; }

if (attackLimbIndex >= AnimController.Limbs.Length)
{
DebugConsole.ThrowError($"Received invalid ExecuteAttack message. Limb index out of bounds ({attackLimbIndex})");
break;
}
Limb attackLimb = AnimController.Limbs[attackLimbIndex];
IDamageable targetEntity = FindEntityByID(targetEntityID) as IDamageable;
Limb targetLimb = null;
if (targetEntity == null)
if (!(FindEntityByID(targetEntityID) is IDamageable targetEntity))
{
DebugConsole.ThrowError($"Received invalid ExecuteAttack message. Target entity not found (ID {targetEntityID})");
break;
Expand All @@ -365,8 +367,10 @@ public virtual void ClientRead(ServerNetObject type, IReadMessage msg, float sen
}
targetLimb = targetCharacter.AnimController.Limbs[targetLimbIndex];
}

attackLimb.ExecuteAttack(targetEntity, targetLimb, out _);
if (attackLimb?.attack != null)
{
attackLimb.ExecuteAttack(targetEntity, targetLimb, out _);
}
break;
}
msg.ReadPadBits();
Expand Down
13 changes: 13 additions & 0 deletions Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2124,6 +2124,7 @@ private void OnFileReceived(FileReceiver.FileTransferIn transfer)
GameMain.GameSession.SubmarineInfo = new SubmarineInfo(subPath, "");
}
SaveUtil.LoadGame(GameMain.GameSession.SavePath, GameMain.GameSession);
GameMain.GameSession?.SubmarineInfo?.Reload();
GameMain.GameSession?.SubmarineInfo?.CheckSubsLeftBehind();
if (GameMain.GameSession?.SubmarineInfo?.Name != null)
{
Expand Down Expand Up @@ -3007,6 +3008,11 @@ private void WriteEventErrorData(ClientNetError error, UInt16 expectedID, UInt16
if (GameMain.GameSession?.GameMode != null)
{
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)
{
Expand All @@ -3015,6 +3021,13 @@ private void WriteEventErrorData(ClientNetError error, UInt16 expectedID, UInt16
if (Level.Loaded != null)
{
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:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public static void AssignLobbyDataToServerInfo(Steamworks.Data.Lobby lobby, Serv
if (Enum.TryParse(lobby.GetData("traitors"), out YesNoMaybe traitorsEnabled)) { serverInfo.TraitorsEnabled = traitorsEnabled; }

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 (serverInfo.ContentPackageNames.Count != serverInfo.ContentPackageHashes.Count ||
Expand Down Expand Up @@ -1052,7 +1052,7 @@ private async static Task<string> CopyWorkShopItemAsync(Steamworks.Ugc.Item? ite
Directory.CreateDirectory(targetPath);
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);
return "";
Expand Down Expand Up @@ -1145,7 +1145,7 @@ private async static Task<string> CopyWorkShopItemAsync(Steamworks.Ugc.Item? ite

//make sure the destination directory exists
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)
Expand All @@ -1154,7 +1154,7 @@ private async static Task<string> CopyWorkShopItemAsync(Steamworks.Ugc.Item? ite
if (!File.Exists(sourceFile)) { continue; }
string destinationPath = CorrectContentFilePath(nonContentFile, contentPackage, false);
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);
Expand Down Expand Up @@ -1507,6 +1507,8 @@ private static void CorrectXMLFilePaths(ContentPackage package, XElement element

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))
{
XDocument doc = XMLExtensions.TryLoadXml(src);
Expand All @@ -1529,12 +1531,12 @@ private static void CorrectContentFileCopy(ContentPackage package, string src, s
}
else
{
File.Copy(src, dest, overwrite: overwrite);
File.Copy(src, dest, overwrite: true);
}
}
else
{
File.Copy(src, dest, overwrite: overwrite);
File.Copy(src, dest, overwrite: true);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Barotrauma/BarotraumaClient/ClientSource/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ static void CrashDump(GameMain game, string filePath, Exception exception)
if (GameMain.Config != null)
{
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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void RecalculateHolder()
}

// 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>();
foreach (GameModePreset mode in GameModePreset.List)
Expand Down Expand Up @@ -1013,7 +1013,7 @@ private void FilterServers()
foreach (GUITickBox tickBox in gameModeTickBoxes)
{
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;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3103,8 +3103,7 @@ public override void Update(double deltaTime)
}
}

// TODO adjust when the new inventory stuff rolls in
if (PlayerInput.KeyHit(Keys.Q) && mode == Mode.Default)
if (GameMain.Config.KeyBind(InputType.ToggleInventory).IsHit() && mode == Mode.Default)
{
toggleEntityMenuButton.OnClicked?.Invoke(toggleEntityMenuButton, toggleEntityMenuButton.UserData);
}
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/LinuxClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.9.9.0</Version>
<Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/MacClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.9.9.0</Version>
<Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/WindowsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.9.9.0</Version>
<Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/LinuxServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>0.9.9.0</Version>
<Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/MacServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>0.9.9.0</Version>
<Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public virtual void ServerWrite(IWriteMessage msg, Client c, object[] extraData
UInt16 targetEntityID = (UInt16)extraData[2];
int targetLimbIndex = extraData.Length > 3 ? (int)extraData[3] : 0;
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((byte)targetLimbIndex);
break;
Expand Down
12 changes: 12 additions & 0 deletions Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ private void WriteEventErrorData(Client client, string errorStr)
if (GameMain.GameSession?.GameMode != null)
{
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)
{
Expand All @@ -850,6 +855,13 @@ private void WriteEventErrorData(Client client, string errorStr)
if (Level.Loaded != null)
{
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:");
Expand Down
4 changes: 4 additions & 0 deletions Barotrauma/BarotraumaServer/ServerSource/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ static void CrashDump(string filePath, Exception exception)
sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
sb.AppendLine("\n");
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)
{
sb.AppendLine("Selected content packages: " + (!GameMain.SelectedPackages.Any() ? "None" : string.Join(", ", GameMain.SelectedPackages.Select(c => c.Name))));
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/WindowsServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>0.9.9.0</Version>
<Version>0.9.9.1</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,10 @@ public void Kill(CauseOfDeathType causeOfDeath, Affliction causeOfDeathAfflictio
causeOfDeathAffliction?.Source ?? LastAttacker, LastDamageSource);
OnDeath?.Invoke(this, CauseOfDeath);

SteamAchievementManager.OnCharacterKilled(this, CauseOfDeath);
if (GameMain.GameSession != null && Screen.Selected == GameMain.GameScreen)
{
SteamAchievementManager.OnCharacterKilled(this, CauseOfDeath);
}

KillProjSpecific(causeOfDeath, causeOfDeathAffliction, log);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Extensions;
using FarseerPhysics.Dynamics;

namespace Barotrauma.Items.Components
{
Expand Down Expand Up @@ -655,7 +656,8 @@ public void ThalamusOperate(WreckAI ai, float deltaTime, bool targetHumans, bool
end -= target.Submarine.SimPosition;
}
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; }
Character targetCharacter = null;
if (pickedBody.UserData is Character c)
Expand Down Expand Up @@ -817,7 +819,8 @@ public override bool AIOperate(float deltaTime, Character character, AIObjective
end -= closestEnemy.Submarine.SimPosition;
}
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; }
Character targetCharacter = null;
if (pickedBody.UserData is Character c)
Expand Down
12 changes: 11 additions & 1 deletion Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ public int EqualityCheckVal
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
{
get;
Expand Down Expand Up @@ -281,8 +286,11 @@ public static Level CreateRandom(string seed = "", float? difficulty = null, Lev

public void Generate(bool mirror)
{
if (loaded != null) loaded.Remove();
if (loaded != null) { loaded.Remove(); }
loaded = this;

EntitiesBeforeGenerate = GetEntityList();
EntityCountBeforeGenerate = EntitiesBeforeGenerate.Count();

levelObjectManager = new LevelObjectManager();

Expand Down Expand Up @@ -759,6 +767,8 @@ public void Generate(bool mirror)
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
ID = FindFreeID();
}
Expand Down
11 changes: 7 additions & 4 deletions Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public bool AtDamageDepth

public override string ToString()
{
return "Barotrauma.Submarine (" + Info?.Name ?? "[NULL INFO]" + ")";
return "Barotrauma.Submarine (" + (Info?.Name ?? "[NULL INFO]") + ", " + IdOffset + ")";
}

public override bool Removed
Expand Down Expand Up @@ -1231,9 +1231,12 @@ public void SaveToXElement(XElement element)

public bool SaveAs(string filePath, MemoryStream previewImage = null)
{
var newInfo = new SubmarineInfo(this);
newInfo.FilePath = filePath;
newInfo.Name = Path.GetFileNameWithoutExtension(filePath);
var newInfo = new SubmarineInfo(this)
{
GameVersion = GameMain.Version,
FilePath = filePath,
Name = Path.GetFileNameWithoutExtension(filePath)
};
Info.Dispose(); Info = newInfo;

return newInfo.SaveAs(filePath, previewImage);
Expand Down
Loading

0 comments on commit ce4ccd9

Please sign in to comment.