v0.10.5.1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Barotrauma.Steam;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -7,11 +8,17 @@ namespace Barotrauma.Networking
|
||||
partial class BannedPlayer
|
||||
{
|
||||
public string Name;
|
||||
public string IP; public bool IsRangeBan;
|
||||
public string EndPoint; public bool IsRangeBan;
|
||||
public UInt64 SteamID;
|
||||
public string Reason;
|
||||
public DateTime? ExpirationTime;
|
||||
public UInt16 UniqueIdentifier;
|
||||
|
||||
private void ParseEndPointAsSteamId()
|
||||
{
|
||||
ulong endPointAsSteamId = SteamManager.SteamIDStringToUInt64(EndPoint);
|
||||
if (endPointAsSteamId != 0 && SteamID == 0) { SteamID = endPointAsSteamId; }
|
||||
}
|
||||
}
|
||||
|
||||
partial class BanList
|
||||
@@ -22,9 +29,9 @@ namespace Barotrauma.Networking
|
||||
get { return bannedPlayers.Select(bp => bp.Name); }
|
||||
}
|
||||
|
||||
public IEnumerable<string> BannedIPs
|
||||
public IEnumerable<string> BannedEndPoints
|
||||
{
|
||||
get { return bannedPlayers.Select(bp => bp.IP); }
|
||||
get { return bannedPlayers.Select(bp => bp.EndPoint).Where(endPoint => !string.IsNullOrEmpty(endPoint)); }
|
||||
}
|
||||
|
||||
partial void InitProjectSpecific();
|
||||
@@ -38,6 +45,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
public static string ToRange(string ip)
|
||||
{
|
||||
if (SteamManager.SteamIDStringToUInt64(ip) != 0) { return ip; }
|
||||
for (int i = ip.Length - 1; i > 0; i--)
|
||||
{
|
||||
if (ip[i] == '.')
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace Barotrauma.Networking
|
||||
public byte ID;
|
||||
public UInt64 SteamID;
|
||||
|
||||
public string Language;
|
||||
|
||||
public UInt16 Ping;
|
||||
|
||||
public string PreferredJob;
|
||||
@@ -196,11 +198,13 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
votes[i] = null;
|
||||
}
|
||||
|
||||
kickVoters.Clear();
|
||||
}
|
||||
|
||||
public void AddKickVote(Client voter)
|
||||
{
|
||||
if (!kickVoters.Contains(voter)) kickVoters.Add(voter);
|
||||
if (voter != null && !kickVoters.Contains(voter)) { kickVoters.Add(voter); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -10,13 +11,13 @@ namespace Barotrauma
|
||||
{
|
||||
private enum SpawnableType { Item, Character };
|
||||
|
||||
interface IEntitySpawnInfo
|
||||
public interface IEntitySpawnInfo
|
||||
{
|
||||
Entity Spawn();
|
||||
void OnSpawned(Entity entity);
|
||||
}
|
||||
|
||||
class ItemSpawnInfo : IEntitySpawnInfo
|
||||
public class ItemSpawnInfo : IEntitySpawnInfo
|
||||
{
|
||||
public readonly ItemPrefab Prefab;
|
||||
|
||||
@@ -241,7 +242,7 @@ namespace Barotrauma
|
||||
public void AddToRemoveQueue(Entity entity)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
if (removeQueue.Contains(entity) || entity.Removed || entity == null) { return; }
|
||||
if (removeQueue.Contains(entity) || entity.Removed || entity == null || entity.IdFreed) { return; }
|
||||
if (entity is Character)
|
||||
{
|
||||
Character character = entity as Character;
|
||||
@@ -263,13 +264,33 @@ namespace Barotrauma
|
||||
if (removeQueue.Contains(item) || item.Removed) { return; }
|
||||
|
||||
removeQueue.Enqueue(item);
|
||||
if (item.ContainedItems == null) return;
|
||||
foreach (Item containedItem in item.ContainedItems)
|
||||
var containedItems = item.OwnInventory?.Items;
|
||||
if (containedItems == null) { return; }
|
||||
foreach (Item containedItem in containedItems)
|
||||
{
|
||||
if (containedItem != null) AddToRemoveQueue(containedItem);
|
||||
if (containedItem != null)
|
||||
{
|
||||
AddToRemoveQueue(containedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Are there any entities in the spawn queue that match the given predicate
|
||||
/// </summary>
|
||||
public bool IsInSpawnQueue(Predicate<IEntitySpawnInfo> predicate)
|
||||
{
|
||||
return spawnQueue.Any(s => predicate(s));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How many entities in the spawn queue match the given predicate
|
||||
/// </summary>
|
||||
public int CountSpawnQueue(Predicate<IEntitySpawnInfo> predicate)
|
||||
{
|
||||
return spawnQueue.Count(s => predicate(s));
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
|
||||
@@ -721,10 +721,24 @@ namespace Barotrauma.Networking
|
||||
|
||||
public class ReadWriteMessage : IWriteMessage, IReadMessage
|
||||
{
|
||||
private byte[] buf = new byte[MsgConstants.InitialBufferSize];
|
||||
private byte[] buf;
|
||||
private int seekPos = 0;
|
||||
private int lengthBits = 0;
|
||||
|
||||
public ReadWriteMessage()
|
||||
{
|
||||
buf = new byte[MsgConstants.InitialBufferSize];
|
||||
seekPos = 0;
|
||||
lengthBits = 0;
|
||||
}
|
||||
|
||||
public ReadWriteMessage(byte[] b, int sPos, int lBits, bool copyBuf)
|
||||
{
|
||||
buf = copyBuf ? (byte[])b.Clone() : b;
|
||||
seekPos = sPos;
|
||||
lengthBits = lBits;
|
||||
}
|
||||
|
||||
public int BitPosition
|
||||
{
|
||||
get
|
||||
|
||||
+11
@@ -33,5 +33,16 @@ namespace Barotrauma.Networking
|
||||
SteamID = steamId;
|
||||
EndPointString = IPString;
|
||||
}
|
||||
|
||||
public override bool EndpointMatches(string endPoint)
|
||||
{
|
||||
if (IPEndPoint?.Address == null) { return false; }
|
||||
if (!IPAddress.TryParse(endPoint, out IPAddress addr)) { return false; }
|
||||
|
||||
IPAddress ip1 = IPEndPoint.Address.IsIPv4MappedToIPv6 ? IPEndPoint.Address.MapToIPv4() : IPEndPoint.Address;
|
||||
IPAddress ip2 = addr.IsIPv4MappedToIPv6 ? addr.MapToIPv4() : addr;
|
||||
|
||||
return ip1.ToString() == ip2.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -27,6 +27,13 @@ namespace Barotrauma.Networking
|
||||
protected set;
|
||||
}
|
||||
|
||||
public string Language
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public abstract bool EndpointMatches(string endPoint);
|
||||
|
||||
public NetworkConnectionStatus Status = NetworkConnectionStatus.Disconnected;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -1,12 +1,19 @@
|
||||
using System;
|
||||
using Barotrauma.Steam;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
public class PipeConnection : NetworkConnection
|
||||
{
|
||||
public PipeConnection()
|
||||
public PipeConnection(ulong steamId)
|
||||
{
|
||||
EndPointString = "PIPE";
|
||||
SteamID = steamId;
|
||||
}
|
||||
|
||||
public override bool EndpointMatches(string endPoint)
|
||||
{
|
||||
return SteamManager.SteamIDStringToUInt64(endPoint) == SteamID || endPoint == "PIPE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Barotrauma.Steam;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
@@ -9,7 +10,7 @@ namespace Barotrauma.Networking
|
||||
public SteamP2PConnection(string name, UInt64 steamId)
|
||||
{
|
||||
SteamID = steamId;
|
||||
EndPointString = SteamID.ToString();
|
||||
EndPointString = SteamManager.SteamIDUInt64ToString(SteamID);
|
||||
Name = name;
|
||||
Heartbeat();
|
||||
}
|
||||
@@ -23,5 +24,10 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
Timeout = TimeoutThreshold;
|
||||
}
|
||||
|
||||
public override bool EndpointMatches(string endPoint)
|
||||
{
|
||||
return SteamManager.SteamIDStringToUInt64(endPoint) == SteamID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace Barotrauma.Networking
|
||||
Returning
|
||||
}
|
||||
|
||||
private NetworkMember networkMember;
|
||||
private Steering shuttleSteering;
|
||||
private List<Door> shuttleDoors;
|
||||
private readonly NetworkMember networkMember;
|
||||
private readonly Steering shuttleSteering;
|
||||
private readonly List<Door> shuttleDoors;
|
||||
|
||||
//items created during respawn
|
||||
//any respawn items left in the shuttle are removed when the shuttle despawns
|
||||
@@ -55,8 +55,6 @@ namespace Barotrauma.Networking
|
||||
|
||||
public State CurrentState { get; private set; }
|
||||
|
||||
private DateTime despawnTime;
|
||||
|
||||
private float maxTransportTime;
|
||||
|
||||
private float updateReturnTimer;
|
||||
@@ -187,8 +185,6 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
partial void DispatchShuttle();
|
||||
|
||||
partial void UpdateReturningProjSpecific();
|
||||
|
||||
private IEnumerable<object> ForceShuttleToPos(Vector2 position, float speed)
|
||||
@@ -217,7 +213,10 @@ namespace Barotrauma.Networking
|
||||
private void ResetShuttle()
|
||||
{
|
||||
ReturnTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, milliseconds: (int)(maxTransportTime * 1000));
|
||||
|
||||
#if SERVER
|
||||
despawnTime = ReturnTime + new TimeSpan(0, 0, seconds: 30);
|
||||
#endif
|
||||
|
||||
if (RespawnShuttle == null) return;
|
||||
|
||||
@@ -244,29 +243,23 @@ namespace Barotrauma.Networking
|
||||
|
||||
foreach (Structure wall in Structure.WallList)
|
||||
{
|
||||
if (wall.Submarine != RespawnShuttle) continue;
|
||||
|
||||
if (wall.Submarine != RespawnShuttle) { continue; }
|
||||
for (int i = 0; i < wall.SectionCount; i++)
|
||||
{
|
||||
wall.AddDamage(i, -100000.0f);
|
||||
}
|
||||
}
|
||||
|
||||
var shuttleGaps = Gap.GapList.FindAll(g => g.Submarine == RespawnShuttle && g.ConnectedWall != null);
|
||||
shuttleGaps.ForEach(g => Spawner.AddToRemoveQueue(g));
|
||||
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
if (hull.Submarine != RespawnShuttle) continue;
|
||||
|
||||
if (hull.Submarine != RespawnShuttle) { continue; }
|
||||
hull.OxygenPercentage = 100.0f;
|
||||
hull.WaterVolume = 0.0f;
|
||||
}
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (c.Submarine != RespawnShuttle) continue;
|
||||
|
||||
if (c.Submarine != RespawnShuttle) { continue; }
|
||||
#if CLIENT
|
||||
if (Character.Controlled == c) Character.Controlled = null;
|
||||
#endif
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (type.HasFlag(MessageType.Chat))
|
||||
{
|
||||
Text = $"[{DateTime.Now.ToString()}]\n {text}";
|
||||
Text = $"[{DateTime.Now}]\n {text}";
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = $"[{DateTime.Now.ToString()}]\n {TextManager.GetServerMessage(text)}";
|
||||
Text = $"[{DateTime.Now}]\n {TextManager.GetServerMessage(text)}";
|
||||
}
|
||||
RichData = RichTextData.GetRichTextData(Text, out SanitizedText);
|
||||
|
||||
|
||||
@@ -460,13 +460,6 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(true, true)]
|
||||
public bool EndRoundAtLevelEnd
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(true, true)]
|
||||
public bool SaveServerLogs
|
||||
{
|
||||
|
||||
@@ -148,7 +148,6 @@ namespace Barotrauma.Steam
|
||||
if (Steamworks.SteamServer.IsValid) { Steamworks.SteamServer.RunCallbacks(); }
|
||||
|
||||
SteamAchievementManager.Update(deltaTime);
|
||||
UpdateProjectSpecific(deltaTime);
|
||||
}
|
||||
|
||||
public static void ShutDown()
|
||||
@@ -160,6 +159,56 @@ namespace Barotrauma.Steam
|
||||
isInitialized = false;
|
||||
}
|
||||
|
||||
public static IEnumerable<ulong> ParseWorkshopIds(string workshopIdData)
|
||||
{
|
||||
string[] workshopIds = workshopIdData.Split(',');
|
||||
foreach (string id in workshopIds)
|
||||
{
|
||||
if (ulong.TryParse(id, out ulong idCast))
|
||||
{
|
||||
yield return idCast;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ulong> WorkshopUrlsToIds(IEnumerable<string> urls)
|
||||
{
|
||||
return urls.Select((u) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(u))
|
||||
{
|
||||
return (ulong)0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetWorkshopItemIDFromUrl(u);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static ulong GetWorkshopItemIDFromUrl(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(url);
|
||||
string idStr = HttpUtility.ParseQueryString(uri.Query)["id"];
|
||||
if (ulong.TryParse(idStr, out ulong id))
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to get Workshop item ID from the url \"" + url + "\"!", e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static UInt64 SteamIDStringToUInt64(string str)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str)) { return 0; }
|
||||
|
||||
Reference in New Issue
Block a user