4e002dc...f9e8100

commit f9e8100140d99d30db551c16523f04cf042fb107
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 20:37:23 2019 +0200

    Automatically grab adjacent ladders when the top/bottom of the current ladder is reached. Makes moving through docking ports a little less confusing. Closes #1337

commit 7ad697036299c3dae0145f89dc7e1f4fec22953d
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Sun Mar 24 20:11:57 2019 +0200

    Fixed windows clients being unable to start a campaign in servers running on Linux. Caused by submarine paths not matching because the clients would use backslash in the filepath while Linux uses a slash. The submarine selection logic also had an additional issue: the clients would assume the submarine is in the default Submarines folder, even though the server may actually store them somewhere else. Now the client communicates the selected sub to the server by sending the name and MD5 hash instead of the path, so mismatching paths shouldn't cause problems anymore. Closes #1332
This commit is contained in:
Joonas Rikkonen
2019-03-24 20:38:12 +02:00
parent c4cd346ae2
commit c3b5c414cb
5 changed files with 31 additions and 17 deletions

View File

@@ -1973,7 +1973,8 @@ namespace Barotrauma.Networking
msg.Write(true); msg.WritePadBits();
msg.Write(savePath);
msg.Write(mapSeed);
msg.Write(sub.FilePath);
msg.Write(sub.Name);
msg.Write(sub.MD5Hash.Hash);
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);

View File

@@ -11,11 +11,11 @@ namespace Barotrauma
{
private List<CharacterCampaignData> characterData = new List<CharacterCampaignData>();
public static void StartNewCampaign(string savePath, string subName, string seed)
public static void StartNewCampaign(string savePath, string subPath, string seed)
{
if (string.IsNullOrWhiteSpace(savePath)) return;
GameMain.GameSession = new GameSession(new Submarine(subName, ""), savePath,
GameMain.GameSession = new GameSession(new Submarine(subPath, ""), savePath,
GameModePreset.List.Find(g => g.Identifier == "multiplayercampaign"));
var campaign = ((MultiPlayerCampaign)GameMain.GameSession.GameMode);
campaign.GenerateMap(seed);

View File

@@ -715,23 +715,25 @@ namespace Barotrauma.Networking
{
string savePath = inc.ReadString();
string seed = inc.ReadString();
string subPath = inc.ReadString();
string subName = inc.ReadString();
string subHash = inc.ReadString();
if (!File.Exists(subPath))
var matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == subName && s.MD5Hash.Hash == subHash);
if (matchingSub == null)
{
SendDirectChatMessage(
TextManager.Get("CampaignStartFailedSubNotFound").Replace("[subpath]", subPath),
TextManager.Get("CampaignStartFailedSubNotFound").Replace("[subname]", subName),
connectedClient, ChatMessageType.MessageBox);
}
else
{
if (connectedClient.HasPermission(ClientPermissions.SelectMode)) MultiPlayerCampaign.StartNewCampaign(savePath, subPath, seed);
if (connectedClient.HasPermission(ClientPermissions.SelectMode)) MultiPlayerCampaign.StartNewCampaign(savePath, matchingSub.FilePath, seed);
}
}
else
{
string saveName = inc.ReadString();
if (connectedClient.HasPermission(ClientPermissions.SelectMode)) MultiPlayerCampaign.LoadCampaign(saveName);
}
break;

View File

@@ -1666,10 +1666,12 @@ namespace Barotrauma
focusedItem = null;
}
findFocusedTimer -= deltaTime;
}
}
#endif
//climb ladders automatically when pressing up/down inside their trigger area
if (SelectedConstruction == null && !AnimController.InWater && Screen.Selected != GameMain.SubEditorScreen)
Ladder currentLadder = SelectedConstruction?.GetComponent<Ladder>();
if ((SelectedConstruction == null || currentLadder != null) &&
!AnimController.InWater && Screen.Selected != GameMain.SubEditorScreen)
{
bool climbInput = IsKeyDown(InputType.Up) || IsKeyDown(InputType.Down);
bool isControlled = Controlled == this;
@@ -1680,6 +1682,19 @@ namespace Barotrauma
float minDist = float.PositiveInfinity;
foreach (Ladder ladder in Ladder.List)
{
if (ladder == currentLadder)
{
continue;
}
else if (currentLadder != null)
{
//only switch from ladder to another if the ladders are above the current ladders and pressing up, or vice versa
if (ladder.Item.WorldPosition.Y > currentLadder.Item.WorldPosition.Y != IsKeyDown(InputType.Up))
{
continue;
}
}
if (CanInteractWith(ladder.Item, out float dist, checkLinked: false) && dist < minDist)
{
minDist = dist;

View File

@@ -5,16 +5,12 @@ namespace Barotrauma.Items.Components
{
class Ladder : ItemComponent
{
private static List<Ladder> list = new List<Ladder>();
public static List<Ladder> List
{
get { return list; }
}
public static List<Ladder> List { get; } = new List<Ladder>();
public Ladder(Item item, XElement element)
: base(item, element)
{
list.Add(this);
List.Add(this);
}
public override bool Select(Character character)
@@ -27,7 +23,7 @@ namespace Barotrauma.Items.Components
protected override void RemoveComponentSpecific()
{
list.Remove(this);
List.Remove(this);
}
}
}