Unstable 0.17.6.0

This commit is contained in:
Markus Isberg
2022-04-04 16:46:08 +09:00
parent 44ded0225a
commit 95764d1fa8
78 changed files with 1265 additions and 703 deletions
@@ -38,7 +38,7 @@ namespace Barotrauma.Networking
public bool CompareTo(string endpointCompare)
{
if (string.IsNullOrEmpty(EndPoint) || string.IsNullOrEmpty(EndPoint)) { return false; }
if (string.IsNullOrEmpty(EndPoint) || string.IsNullOrEmpty(endpointCompare)) { return false; }
if (!IsRangeBan)
{
return endpointCompare == EndPoint;
@@ -173,13 +173,14 @@ namespace Barotrauma.Networking
}
OnStarted(transfer);
GameMain.Server.LastClientListUpdateID++;
return transfer;
}
public void Update(float deltaTime)
{
activeTransfers.RemoveAll(t => t.Connection.Status != NetworkConnectionStatus.Connected);
int numRemoved = activeTransfers.RemoveAll(t => t.Connection.Status != NetworkConnectionStatus.Connected);
var endedTransfers = activeTransfers.FindAll(t =>
t.Connection.Status != NetworkConnectionStatus.Connected ||
@@ -202,6 +203,11 @@ namespace Barotrauma.Networking
Send(transfer);
}
}
if (numRemoved > 0 || endedTransfers.Count > 0)
{
GameMain.Server.LastClientListUpdateID++;
}
}
private void Send(FileTransferOut transfer)
@@ -31,7 +31,7 @@ namespace Barotrauma.Networking
string resultFileName
= dir.StartsWith(ContentPackage.LocalModsDir)
? $"Local_{mod.Name}"
: $"Workshop_{mod.Name}";
: $"Workshop_{mod.Name}_{mod.SteamWorkshopId}";
resultFileName = ToolBox.RemoveInvalidFileNameChars(resultFileName.Replace('\\', '_').Replace('/', '_'));
resultFileName = $"{resultFileName}{Extension}";
return Path.Combine(UploadFolder, resultFileName);
@@ -1587,25 +1587,6 @@ namespace Barotrauma.Networking
outmsg.Write(serverSettings.AllowSpectating);
c.WritePermissions(outmsg);
if (gameStarted)
{
string ownedSubmarineIndexes = string.Empty;
for (int i = 0; i < subList.Count; i++)
{
if (GameMain.GameSession.OwnedSubmarines.Contains(subList[i]))
{
ownedSubmarineIndexes += i.ToString();
ownedSubmarineIndexes += ";";
}
}
if (ownedSubmarineIndexes.Length > 0)
{
ownedSubmarineIndexes.Trim(';');
}
outmsg.Write(ownedSubmarineIndexes);
}
}
private void ClientWriteIngame(Client c)
@@ -1807,29 +1788,30 @@ namespace Barotrauma.Networking
outmsg.Write((byte)connectedClients.Count);
foreach (Client client in connectedClients)
{
outmsg.Write(client.ID);
outmsg.Write(client.SteamID);
outmsg.Write(client.NameID);
outmsg.Write(client.Name);
outmsg.Write(client.Character?.Info?.Job != null && gameStarted ? client.Character.Info.Job.Prefab.Identifier : client.PreferredJob);
outmsg.Write((byte)client.PreferredTeam);
outmsg.Write(client.Character == null || !gameStarted ? (ushort)0 : client.Character.ID);
if (c.HasPermission(ClientPermissions.ServerLog))
var tempClientData = new TempClient
{
outmsg.Write(client.Karma);
}
else
{
outmsg.Write(100.0f);
}
outmsg.Write(client.Muted);
outmsg.Write(client.InGame);
outmsg.Write(client.Permissions != ClientPermissions.None);
outmsg.Write(client.Connection == OwnerConnection);
outmsg.Write(client.Connection != OwnerConnection &&
!client.HasPermission(ClientPermissions.Ban) &&
!client.HasPermission(ClientPermissions.Kick) &&
!client.HasPermission(ClientPermissions.Unban)); //is kicking the player allowed
ID = client.ID,
SteamID = client.SteamID,
NameID = client.NameID,
Name = client.Name,
PreferredJob = client.Character?.Info?.Job != null && gameStarted
? client.Character.Info.Job.Prefab.Identifier
: client.PreferredJob,
PreferredTeam = client.PreferredTeam,
CharacterID = client.Character == null || !gameStarted ? (ushort)0 : client.Character.ID,
Karma = c.HasPermission(ClientPermissions.ServerLog) ? client.Karma : 100.0f,
Muted = client.Muted,
InGame = client.InGame,
HasPermissions = client.Permissions != ClientPermissions.None,
IsOwner = client.Connection == OwnerConnection,
AllowKicking = client.Connection != OwnerConnection &&
!client.HasPermission(ClientPermissions.Ban) &&
!client.HasPermission(ClientPermissions.Kick) &&
!client.HasPermission(ClientPermissions.Unban),
IsDownloading = FileSender.ActiveTransfers.Any(t => t.Connection == client.Connection)
};
outmsg.Write(tempClientData);
outmsg.WritePadBits();
}
}
@@ -3218,7 +3200,7 @@ namespace Barotrauma.Networking
{
Voting.ActiveVote.Finish(Voting, passed: false);
}
else if (yes / max >= serverSettings.VoteRequiredRatio)
else if (yes / (float)max >= serverSettings.VoteRequiredRatio)
{
Voting.ActiveVote.Finish(Voting, passed: true);
}