Unstable 0.16.0.0
This commit is contained in:
@@ -78,7 +78,7 @@ namespace Barotrauma.Networking
|
||||
txt = orderPrefab.GetChatMessage(orderMessageInfo.TargetCharacter?.Name, targetRoom,
|
||||
givingOrderToSelf: orderMessageInfo.TargetCharacter == senderCharacter,
|
||||
orderOption: orderOption,
|
||||
priority: orderMessageInfo.Priority);
|
||||
isNewOrder: orderMessageInfo.IsNewOrder);
|
||||
|
||||
if (GameMain.Client.GameStarted && Screen.Selected == GameMain.GameScreen)
|
||||
{
|
||||
|
||||
@@ -948,6 +948,9 @@ namespace Barotrauma.Networking
|
||||
case ServerPacketHeader.CREW:
|
||||
campaign?.ClientReadCrew(inc);
|
||||
break;
|
||||
case ServerPacketHeader.MEDICAL:
|
||||
campaign?.MedicalClinic?.ClientRead(inc);
|
||||
break;
|
||||
case ServerPacketHeader.READY_CHECK:
|
||||
ReadyCheck.ClientRead(inc);
|
||||
break;
|
||||
@@ -1116,9 +1119,9 @@ namespace Barotrauma.Networking
|
||||
disconnectReason != DisconnectReason.InvalidVersion)
|
||||
{
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
"GameClient.HandleDisconnectMessage",
|
||||
GameAnalyticsManager.ErrorSeverity.Debug,
|
||||
"Client received a disconnect message. Reason: " + disconnectReason.ToString());
|
||||
"GameClient.HandleDisconnectMessage",
|
||||
GameAnalyticsManager.ErrorSeverity.Debug,
|
||||
"Client received a disconnect message. Reason: " + disconnectReason.ToString());
|
||||
}
|
||||
|
||||
if (disconnectReason == DisconnectReason.ServerFull)
|
||||
@@ -1271,7 +1274,15 @@ namespace Barotrauma.Networking
|
||||
private void ReadAchievement(IReadMessage inc)
|
||||
{
|
||||
string achievementIdentifier = inc.ReadString();
|
||||
SteamAchievementManager.UnlockAchievement(achievementIdentifier);
|
||||
int amount = inc.ReadInt32();
|
||||
if (amount == 0)
|
||||
{
|
||||
SteamAchievementManager.UnlockAchievement(achievementIdentifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
SteamAchievementManager.IncrementStat(achievementIdentifier, amount);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadTraitorMessage(IReadMessage inc)
|
||||
@@ -1471,7 +1482,7 @@ namespace Barotrauma.Networking
|
||||
serverSettings.LockAllDefaultWires = inc.ReadBoolean();
|
||||
serverSettings.AllowRagdollButton = inc.ReadBoolean();
|
||||
serverSettings.AllowLinkingWifiToChat = inc.ReadBoolean();
|
||||
GameMain.NetLobbyScreen.UsingShuttle = inc.ReadBoolean();
|
||||
bool usingShuttle = GameMain.NetLobbyScreen.UsingShuttle = inc.ReadBoolean();
|
||||
GameMain.LightManager.LosMode = (LosMode)inc.ReadByte();
|
||||
bool includesFinalize = inc.ReadBoolean(); inc.ReadPadBits();
|
||||
GameMain.LightManager.LightingEnabled = true;
|
||||
@@ -1483,6 +1494,8 @@ namespace Barotrauma.Networking
|
||||
Task loadTask = null;
|
||||
var roundSummary = (GUIMessageBox.MessageBoxes.Find(c => c?.UserData is RoundSummary)?.UserData) as RoundSummary;
|
||||
|
||||
bool isOutpost = false;
|
||||
|
||||
if (gameMode != GameModePreset.MultiPlayerCampaign)
|
||||
{
|
||||
string levelSeed = inc.ReadString();
|
||||
@@ -1621,6 +1634,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
GameMain.GameSession.StartRound(levelData, mirrorLevel);
|
||||
}
|
||||
isOutpost = levelData.Type == LevelData.LevelType.Outpost;
|
||||
}
|
||||
|
||||
if (GameMain.Client?.ServerSettings?.Voting != null)
|
||||
@@ -1740,8 +1754,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (respawnAllowed)
|
||||
{
|
||||
bool isOutpost = GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign && Level.Loaded?.Type == LevelData.LevelType.Outpost;
|
||||
respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.UsingShuttle && !isOutpost ? GameMain.NetLobbyScreen.SelectedShuttle : null);
|
||||
respawnManager = new RespawnManager(this, usingShuttle && !isOutpost ? GameMain.NetLobbyScreen.SelectedShuttle : null);
|
||||
}
|
||||
|
||||
gameStarted = true;
|
||||
@@ -1872,7 +1885,7 @@ namespace Barotrauma.Networking
|
||||
if (int.TryParse(ownedIndexes[i], out int index))
|
||||
{
|
||||
SubmarineInfo sub = GameMain.Client.ServerSubmarines[index];
|
||||
if (GameMain.NetLobbyScreen.CheckIfCampaignSubMatches(sub, "owned"))
|
||||
if (GameMain.NetLobbyScreen.CheckIfCampaignSubMatches(sub, NetLobbyScreen.SubmarineDeliveryData.Owned))
|
||||
{
|
||||
GameMain.GameSession.OwnedSubmarines.Add(sub);
|
||||
}
|
||||
@@ -1888,7 +1901,7 @@ namespace Barotrauma.Networking
|
||||
if (int.TryParse(ownedIndexes[i], out index))
|
||||
{
|
||||
SubmarineInfo sub = GameMain.Client.ServerSubmarines[index];
|
||||
if (GameMain.NetLobbyScreen.CheckIfCampaignSubMatches(sub, "owned"))
|
||||
if (GameMain.NetLobbyScreen.CheckIfCampaignSubMatches(sub, NetLobbyScreen.SubmarineDeliveryData.Owned))
|
||||
{
|
||||
GameMain.NetLobbyScreen.ServerOwnedSubmarines.Add(sub);
|
||||
}
|
||||
@@ -2090,13 +2103,6 @@ namespace Barotrauma.Networking
|
||||
string selectShuttleName = inc.ReadString();
|
||||
string selectShuttleHash = inc.ReadString();
|
||||
|
||||
UInt16 campaignSubmarineIndexCount = inc.ReadUInt16();
|
||||
List<int> campaignSubIndices = new List<int>();
|
||||
for (int i = 0; i< campaignSubmarineIndexCount; i++)
|
||||
{
|
||||
campaignSubIndices.Add(inc.ReadUInt16());
|
||||
}
|
||||
|
||||
bool allowSubVoting = inc.ReadBoolean();
|
||||
bool allowModeVoting = inc.ReadBoolean();
|
||||
|
||||
@@ -2157,16 +2163,11 @@ namespace Barotrauma.Networking
|
||||
if (GameMain.Client.IsServerOwner) RequestSelectMode(modeIndex);
|
||||
}
|
||||
|
||||
if (campaignSubIndices != null)
|
||||
if (GameMain.NetLobbyScreen.SelectedMode == GameModePreset.MultiPlayerCampaign)
|
||||
{
|
||||
GameMain.NetLobbyScreen.CampaignSubmarines = new List<SubmarineInfo>();
|
||||
foreach (UInt16 campaignSubIndex in campaignSubIndices)
|
||||
foreach (SubmarineInfo sub in ServerSubmarines.Where(s => !ServerSettings.HiddenSubs.Contains(s.Name)))
|
||||
{
|
||||
SubmarineInfo sub = GameMain.Client.ServerSubmarines[campaignSubIndex];
|
||||
if (GameMain.NetLobbyScreen.CheckIfCampaignSubMatches(sub, "campaign"))
|
||||
{
|
||||
GameMain.NetLobbyScreen.CampaignSubmarines.Add(sub);
|
||||
}
|
||||
GameMain.NetLobbyScreen.CheckIfCampaignSubMatches(sub, NetLobbyScreen.SubmarineDeliveryData.Campaign);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2599,7 +2600,6 @@ namespace Barotrauma.Networking
|
||||
NetLobbyScreen.FailedSubInfo failedCampaignSub = GameMain.NetLobbyScreen.FailedCampaignSubs.Find(s => s.Name == newSub.Name && s.Hash == newSub.MD5Hash.Hash);
|
||||
if (failedCampaignSub != default)
|
||||
{
|
||||
GameMain.NetLobbyScreen.CampaignSubmarines.Add(newSub);
|
||||
GameMain.NetLobbyScreen.FailedCampaignSubs.Remove(failedCampaignSub);
|
||||
}
|
||||
|
||||
|
||||
+13
-7
@@ -100,7 +100,7 @@ namespace Barotrauma.Networking
|
||||
if (!isActive) { return; }
|
||||
if (steamId != hostSteamId) { return; }
|
||||
Close($"SteamP2P connection failed: {error}");
|
||||
OnDisconnectMessageReceived?.Invoke($"SteamP2P connection failed: {error}");
|
||||
OnDisconnectMessageReceived?.Invoke($"{DisconnectReason.SteamP2PError}/SteamP2P connection failed: {error}");
|
||||
}
|
||||
|
||||
private void OnP2PData(ulong steamId, byte[] data, int dataLength)
|
||||
@@ -167,14 +167,14 @@ namespace Barotrauma.Networking
|
||||
if (state == null)
|
||||
{
|
||||
Close("SteamP2P connection could not be established");
|
||||
OnDisconnectMessageReceived?.Invoke("SteamP2P connection could not be established");
|
||||
OnDisconnectMessageReceived?.Invoke(DisconnectReason.SteamP2PError.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state?.P2PSessionError != Steamworks.P2PSessionError.None)
|
||||
{
|
||||
Close($"SteamP2P error code: {state?.P2PSessionError}");
|
||||
OnDisconnectMessageReceived?.Invoke($"SteamP2P error code: {state?.P2PSessionError}");
|
||||
OnDisconnectMessageReceived?.Invoke($"{DisconnectReason.SteamP2PError}/SteamP2P error code: {state?.P2PSessionError}");
|
||||
}
|
||||
}
|
||||
connectionStatusTimer = 1.0f;
|
||||
@@ -210,7 +210,7 @@ namespace Barotrauma.Networking
|
||||
if (timeout < 0.0)
|
||||
{
|
||||
Close("Timed out");
|
||||
OnDisconnectMessageReceived?.Invoke("");
|
||||
OnDisconnectMessageReceived?.Invoke(DisconnectReason.SteamP2PTimeOut.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -349,13 +349,19 @@ namespace Barotrauma.Networking
|
||||
outMsg.Write((byte)PacketHeader.IsDisconnectMessage);
|
||||
outMsg.Write(msg ?? "Disconnected");
|
||||
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
try
|
||||
{
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to send a disconnect message to the server using SteamP2P.", e);
|
||||
}
|
||||
|
||||
Thread.Sleep(100);
|
||||
|
||||
Steamworks.SteamNetworking.ResetActions();
|
||||
|
||||
Steamworks.SteamNetworking.CloseP2PSessionWithUser(hostSteamId);
|
||||
|
||||
steamAuthTicket?.Cancel(); steamAuthTicket = null;
|
||||
|
||||
@@ -81,16 +81,15 @@ namespace Barotrauma.Networking
|
||||
|
||||
public bool ContentPackagesMatch()
|
||||
{
|
||||
var myContentPackages = ContentPackage.AllPackages;
|
||||
//make sure we have all the packages the server requires
|
||||
if (ContentPackageHashes.Count != ContentPackageWorkshopIds.Count) { return false; }
|
||||
for (int i = 0; i < ContentPackageWorkshopIds.Count; i++)
|
||||
{
|
||||
string hash = ContentPackageHashes[i];
|
||||
UInt64 id = ContentPackageWorkshopIds[i];
|
||||
if (!myContentPackages.Any(myPackage => myPackage.MD5hash.Hash == hash))
|
||||
if (!GameMain.ServerListScreen.ContentPackagesByHash.ContainsKey(hash))
|
||||
{
|
||||
if (myContentPackages.Any(p => p.SteamWorkshopId == id)) { return false; }
|
||||
if (GameMain.ServerListScreen.ContentPackagesByWorkshopId.ContainsKey(id)) { return false; }
|
||||
if (id == 0) { return false; }
|
||||
}
|
||||
}
|
||||
@@ -98,12 +97,6 @@ namespace Barotrauma.Networking
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ContentPackagesMatch(IEnumerable<string> myContentPackageHashes)
|
||||
{
|
||||
HashSet<string> contentPackageHashes = new HashSet<string>(ContentPackageHashes);
|
||||
return contentPackageHashes.SetEquals(myContentPackageHashes);
|
||||
}
|
||||
|
||||
public void CreatePreviewWindow(GUIFrame frame)
|
||||
{
|
||||
if (frame == null) { return; }
|
||||
@@ -428,7 +421,7 @@ namespace Barotrauma.Networking
|
||||
return;
|
||||
}
|
||||
|
||||
var rules = ((Task<Dictionary<string, string>>)t).Result;
|
||||
t.TryGetResult(out Dictionary<string, string> rules);
|
||||
SteamManager.AssignServerRulesToServerInfo(rules, this);
|
||||
|
||||
onServerRulesReceived(this);
|
||||
|
||||
@@ -94,10 +94,10 @@ namespace Barotrauma.Networking
|
||||
|
||||
public void ClientAdminRead(IReadMessage incMsg)
|
||||
{
|
||||
int count = incMsg.ReadUInt16();
|
||||
for (int i = 0; i < count; i++)
|
||||
while (true)
|
||||
{
|
||||
UInt32 key = incMsg.ReadUInt32();
|
||||
if (key == 0) { break; }
|
||||
if (netProperties.ContainsKey(key))
|
||||
{
|
||||
bool changedLocally = netProperties[key].ChangedLocally;
|
||||
@@ -153,8 +153,11 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
ReadExtraCargo(incMsg);
|
||||
}
|
||||
|
||||
ReadHiddenSubs(incMsg);
|
||||
|
||||
if (requiredFlags.HasFlag(NetFlags.HiddenSubs))
|
||||
{
|
||||
ReadHiddenSubs(incMsg);
|
||||
}
|
||||
GameMain.NetLobbyScreen.UpdateSubVisibility();
|
||||
|
||||
bool isAdmin = incMsg.ReadBoolean();
|
||||
|
||||
@@ -143,8 +143,7 @@ namespace Barotrauma.Steam
|
||||
return;
|
||||
}
|
||||
|
||||
currentLobby = ((Task<Steamworks.Data.Lobby?>)lobby).Result;
|
||||
|
||||
lobby.TryGetResult(out currentLobby);
|
||||
if (currentLobby == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to create Steam lobby: returned lobby was null");
|
||||
@@ -250,7 +249,7 @@ namespace Barotrauma.Steam
|
||||
TaskPool.Add("JoinLobbyAsync", Steamworks.SteamMatchmaking.JoinLobbyAsync(lobbyID),
|
||||
(lobby) =>
|
||||
{
|
||||
currentLobby = ((Task<Steamworks.Data.Lobby?>)lobby).Result;
|
||||
lobby.TryGetResult(out currentLobby);
|
||||
lobbyState = LobbyState.Joined;
|
||||
lobbyID = (currentLobby?.Id).Value;
|
||||
if (joinServer)
|
||||
@@ -293,10 +292,11 @@ namespace Barotrauma.Steam
|
||||
taskDone();
|
||||
return;
|
||||
}
|
||||
var lobbies = ((Task<List<Steamworks.Data.Lobby>>)t).Result;
|
||||
if (lobbies != null)
|
||||
t.TryGetResult(out List<Steamworks.Data.Lobby> lobbies);
|
||||
IEnumerable<CoroutineStatus> lobbyAddCoroutine()
|
||||
{
|
||||
foreach (var lobby in lobbies)
|
||||
int i = 0;
|
||||
foreach (var lobby in lobbies ?? Enumerable.Empty<Steamworks.Data.Lobby>())
|
||||
{
|
||||
if (string.IsNullOrEmpty(lobby.GetData("name"))) { continue; }
|
||||
|
||||
@@ -312,9 +312,13 @@ namespace Barotrauma.Steam
|
||||
AssignLobbyDataToServerInfo(lobby, serverInfo);
|
||||
|
||||
addToServerList(serverInfo);
|
||||
i++;
|
||||
if (i >= 16) { yield return CoroutineStatus.Running; i = 0; }
|
||||
}
|
||||
taskDone();
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
taskDone();
|
||||
CoroutineManager.StartCoroutine(lobbyAddCoroutine());
|
||||
});
|
||||
|
||||
Steamworks.ServerList.Internet serverQuery = new Steamworks.ServerList.Internet();
|
||||
@@ -344,13 +348,10 @@ namespace Barotrauma.Steam
|
||||
return;
|
||||
}
|
||||
|
||||
var rules = ((Task<Dictionary<string, string>>)t).Result;
|
||||
t.TryGetResult(out Dictionary<string, string> rules);
|
||||
AssignServerRulesToServerInfo(rules, serverInfo);
|
||||
|
||||
CrossThread.RequestExecutionOnMainThread(() =>
|
||||
{
|
||||
addToServerList(serverInfo);
|
||||
});
|
||||
addToServerList(serverInfo);
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -618,7 +619,10 @@ namespace Barotrauma.Steam
|
||||
.WithLongDescription();
|
||||
if (requireTags != null) { query = query.WithTags(requireTags); }
|
||||
|
||||
TaskPool.Add("GetSubscribedWorkshopItems", GetWorkshopItemsAsync(query), (task) => { onItemsFound?.Invoke(((Task<List<Steamworks.Ugc.Item>>)task).Result); });
|
||||
TaskPool.Add("GetSubscribedWorkshopItems", GetWorkshopItemsAsync(query), (task) =>
|
||||
{
|
||||
task.TryGetResult(out List<Steamworks.Ugc.Item> result); onItemsFound?.Invoke(result);
|
||||
});
|
||||
}
|
||||
|
||||
public static void GetPopularWorkshopItems(Action<IList<Steamworks.Ugc.Item>> onItemsFound, int amount, List<string> requireTags = null)
|
||||
@@ -632,7 +636,7 @@ namespace Barotrauma.Steam
|
||||
|
||||
TaskPool.Add("GetPopularWorkshopItems", GetWorkshopItemsAsync(query, amount, (item) => !item.IsSubscribed), (task) =>
|
||||
{
|
||||
var entries = ((Task<List<Steamworks.Ugc.Item>>)task).Result;
|
||||
task.TryGetResult(out List<Steamworks.Ugc.Item> entries);
|
||||
|
||||
//count the number of each unique tag
|
||||
foreach (var item in entries)
|
||||
@@ -677,7 +681,10 @@ namespace Barotrauma.Steam
|
||||
.WithLongDescription();
|
||||
if (requireTags != null) query.WithTags(requireTags);
|
||||
|
||||
TaskPool.Add("GetPublishedWorkshopItems", GetWorkshopItemsAsync(query), (task) => { onItemsFound?.Invoke(((Task<List<Steamworks.Ugc.Item>>)task).Result); });
|
||||
TaskPool.Add("GetPublishedWorkshopItems", GetWorkshopItemsAsync(query), (task) =>
|
||||
{
|
||||
task.TryGetResult(out List<Steamworks.Ugc.Item> result); onItemsFound?.Invoke(result);
|
||||
});
|
||||
}
|
||||
|
||||
private static readonly HashSet<ulong> pendingWorkshopSubscriptions = new HashSet<ulong>();
|
||||
@@ -724,7 +731,7 @@ namespace Barotrauma.Steam
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = ((Task<Steamworks.Ugc.Item?>)t).Result;
|
||||
t.TryGetResult(out Steamworks.Ugc.Item? item);
|
||||
if (item != null)
|
||||
{
|
||||
if (item?.IsInstalled ?? false)
|
||||
@@ -1077,7 +1084,7 @@ namespace Barotrauma.Steam
|
||||
GameMain.SteamWorkshopScreen?.SetReinstallButtonStatus(item, true, GUI.Style.Red);
|
||||
return;
|
||||
}
|
||||
string errorMsg = ((Task<string>)task).Result;
|
||||
task.TryGetResult(out string errorMsg);
|
||||
if (!string.IsNullOrWhiteSpace(errorMsg))
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to copy \"{item.Title}\": {errorMsg}");
|
||||
|
||||
Reference in New Issue
Block a user