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
@@ -1116,7 +1116,7 @@ namespace Barotrauma
}
else
{
GameMain.Server.SendTraitorMessage(client, string.Format("- Traitor {0} has no current objective.", "", t.Character.Name), Identifier.Empty, TraitorMessageType.Console);
GameMain.Server.SendTraitorMessage(client, string.Format("- Traitor {0} has no current objective.", t.Character.Name), Identifier.Empty, TraitorMessageType.Console);
}
}
//GameMain.Server.SendTraitorMessage(client, "The code words are: " + traitorManager.CodeWords + ", response: " + traitorManager.CodeResponse + ".", TraitorMessageType.Console);
@@ -2234,11 +2234,6 @@ namespace Barotrauma
if (args.Length < 2)
{
GameMain.Server.SendConsoleMessage("Invalid parameters. The command should be formatted as \"setclientcharacter [client] [character]\". If the names consist of multiple words, you should surround them with quotation marks.", senderClient, Color.Red);
return;
}
if (args.Length < 2)
{
ThrowError("Invalid parameters. The command should be formatted as \"setclientcharacter [client] [character]\". If the names consist of multiple words, you should surround them with quotation marks.");
return;
}
@@ -7,7 +7,7 @@ namespace Barotrauma
{
partial class CargoManager
{
public void SellBackPurchasedItems(Identifier storeIdentifier, List<PurchasedItem> itemsToSell, Client client = null)
public void SellBackPurchasedItems(Identifier storeIdentifier, List<PurchasedItem> itemsToSell, Client client)
{
// Check all the prices before starting the transaction to make sure the modifiers stay the same for the whole transaction
var buyValues = GetBuyValuesAtCurrentLocation(storeIdentifier, itemsToSell.Select(i => i.ItemPrefab));
@@ -40,7 +40,7 @@ namespace Barotrauma
}
}
public void SellItems(Identifier storeIdentifier, List<SoldItem> itemsToSell, Client client)
public void SellItems(Identifier storeIdentifier, List<SoldItem> itemsToSell)
{
var store = Location.GetStore(storeIdentifier);
if (store == null) { return; }
@@ -564,6 +564,21 @@ namespace Barotrauma
msg.Write((byte)selectedMissionIndex);
}
var subList = GameMain.NetLobbyScreen.GetSubList();
List<int> ownedSubmarineIndices = new List<int>();
for (int i = 0; i < subList.Count; i++)
{
if (GameMain.GameSession.OwnedSubmarines.Any(s => s.Name == subList[i].Name))
{
ownedSubmarineIndices.Add(i);
}
}
msg.Write((ushort)ownedSubmarineIndices.Count);
foreach (int index in ownedSubmarineIndices)
{
msg.Write((ushort)index);
}
msg.Write(map.AllowDebugTeleport);
msg.Write(reputation != null);
if (reputation != null) { msg.Write(reputation.Value); }
@@ -768,8 +783,12 @@ namespace Barotrauma
if (Map.SelectedConnection != null) { Map.SelectMission(selectedMissionIndices); }
CheckTooManyMissions(Map.CurrentLocation, sender);
}
var prevBuyCrateItems = new Dictionary<Identifier, List<PurchasedItem>>(CargoManager.ItemsInBuyCrate);
var prevBuyCrateItems = new Dictionary<Identifier, List<PurchasedItem>>();
foreach (var kvp in CargoManager.ItemsInBuyCrate)
{
prevBuyCrateItems.Add(kvp.Key, new List<PurchasedItem>(kvp.Value));
}
foreach (var store in prevBuyCrateItems)
{
foreach (var item in store.Value)
@@ -784,10 +803,15 @@ namespace Barotrauma
CargoManager.ModifyItemQuantityInBuyCrate(store.Key, item.ItemPrefab, item.Quantity, sender);
}
}
var prevPurchasedItems = new Dictionary<Identifier, List<PurchasedItem>>(CargoManager.PurchasedItems);
var prevPurchasedItems = new Dictionary<Identifier, List<PurchasedItem>>();
foreach (var kvp in CargoManager.PurchasedItems)
{
prevPurchasedItems.Add(kvp.Key, new List<PurchasedItem>(kvp.Value));
}
foreach (var store in prevPurchasedItems)
{
CargoManager.SellBackPurchasedItems(store.Key, store.Value);
CargoManager.SellBackPurchasedItems(store.Key, store.Value, sender);
}
foreach (var store in purchasedItems)
{
@@ -813,6 +837,7 @@ namespace Barotrauma
}
}
}
bool allowedToSellInventoryItems = AllowedToManageCampaign(sender, ClientPermissions.SellInventoryItems);
if (allowedToSellInventoryItems && allowedToSellSubItems)
{
@@ -825,7 +850,7 @@ namespace Barotrauma
}
foreach (var store in soldItems)
{
CargoManager.SellItems(store.Key, store.Value, sender);
CargoManager.SellItems(store.Key, store.Value);
}
}
else if (allowedToSellInventoryItems || allowedToSellSubItems)
@@ -842,7 +867,7 @@ namespace Barotrauma
}
foreach (var store in soldItems)
{
CargoManager.SellItems(store.Key, store.Value, sender);
CargoManager.SellItems(store.Key, store.Value);
}
bool predicate(SoldItem i) => allowedToSellInventoryItems != (i.Origin == SoldItem.SellOrigin.Character);
}
@@ -1,9 +1,6 @@
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
@@ -15,7 +12,7 @@ namespace Barotrauma.Items.Components
item.CreateServerEvent(this);
if (!item.CanClientAccess(c)) return;
if (!item.CanClientAccess(c)) { return; }
if (recipeHash == 0)
{
@@ -64,6 +61,13 @@ namespace Barotrauma.Items.Components
msg.Write(recipeHash);
UInt16 userID = fabricatedItem is null || user is null ? (UInt16)0 : user.ID;
msg.Write(userID);
var reachedLimits = fabricationLimits.Where(kvp => kvp.Value <= 0);
msg.Write((ushort)reachedLimits.Count());
foreach (var kvp in reachedLimits)
{
msg.Write(kvp.Key);
}
}
}
}
@@ -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);
}