diff --git a/Barotrauma/BarotraumaClient/ClientSource/GUI/GUITextBox.cs b/Barotrauma/BarotraumaClient/ClientSource/GUI/GUITextBox.cs index 7dca6fcbc..3d0299054 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GUI/GUITextBox.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GUI/GUITextBox.cs @@ -918,5 +918,12 @@ namespace Barotrauma DebugConsole.ThrowError($"GUITextBox: Invalid selection: ({exception})"); } } + + public void ResetDelegates() + { + OnKeyHit = null; + OnEnterPressed = null; + OnTextChanged = null; + } } } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Fabricator.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Fabricator.cs index 0596825f6..1d5066db2 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Fabricator.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Fabricator.cs @@ -1031,7 +1031,7 @@ namespace Barotrauma.Items.Components { if (selectedItem == null) { return false; } if (fabricatedItem == null && - !outputContainer.Inventory.CanBePut(selectedItem.TargetItem, selectedItem.OutCondition * selectedItem.TargetItem.Health)) + !outputContainer.Inventory.CanProbablyBePut(selectedItem.TargetItem, selectedItem.OutCondition * selectedItem.TargetItem.Health)) { outputSlot.Flash(GUIStyle.Red); return false; diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs index 924795c5b..af3705aaf 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs @@ -2726,7 +2726,7 @@ namespace Barotrauma UpdateJobPreferences(GameMain.Client?.CharacterInfo ?? Character.Controlled?.Info); JobSelectionFrame = null; RefreshChatrow(); // to enable/disable team chat according to current selection - + return true; }; @@ -4772,19 +4772,29 @@ namespace Barotrauma { TeamChatSelected = false; } - - chatInput = new GUITextBox(new RectTransform(new Vector2(0.75f, 1.0f), chatRow.RectTransform, Anchor.CenterRight)) - { - MaxTextLength = ChatMessage.MaxLength, - Font = GUIStyle.SmallFont, - DeselectAfterMessage = false - }; - micIcon = new GUIImage(new RectTransform(new Vector2(0.05f, 1.0f), chatRow.RectTransform), style: "GUIMicrophoneUnavailable"); - - chatInput.Select(); + if (chatInput != null) + { + chatInput.RectTransform.Parent = chatRow.RectTransform; + } + else + { + chatInput = new GUITextBox(new RectTransform(new Vector2(0.75f, 1.0f), chatRow.RectTransform, Anchor.CenterRight)) + { + MaxTextLength = ChatMessage.MaxLength, + Font = GUIStyle.SmallFont, + DeselectAfterMessage = false + }; + + micIcon = new GUIImage(new RectTransform(new Vector2(0.05f, 1.0f), chatRow.RectTransform), style: "GUIMicrophoneUnavailable"); + chatInput.Select(); + } + + //this needs to be done even if we're using the existing chatinput instance instead of creating a new one, + //because the client might not have existed when the input box was first created if (GameMain.Client != null) { + chatInput.ResetDelegates(); chatInput.OnEnterPressed = GameMain.Client.EnterChatMessage; chatInput.OnTextChanged += GameMain.Client.TypingChatMessage; chatInput.OnDeselected += (sender, key) => diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs index 03870cdd9..562615199 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs @@ -5937,7 +5937,7 @@ namespace Barotrauma newItem.Remove(); } } - else if (itemContainer != null && itemContainer.Inventory.CanBePut(itemPrefab)) + else if (itemContainer != null && itemContainer.Inventory.CanProbablyBePut(itemPrefab)) { bool placedItem = itemContainer.Inventory.TryPutItem(newItem, dummyCharacter); spawnedItem |= placedItem; diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index 2abd5bb41..9248cc15d 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 1.6.18.1 + 1.6.19.1 Copyright © FakeFish 2018-2024 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index 2bfa8e135..9b6e9ca4f 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 1.6.18.1 + 1.6.19.1 Copyright © FakeFish 2018-2024 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index bede07262..584b9485d 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 1.6.18.1 + 1.6.19.1 Copyright © FakeFish 2018-2024 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index 9ea7200bb..7bb8aad50 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 1.6.18.1 + 1.6.19.1 Copyright © FakeFish 2018-2023 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index 2f9c63b57..0e91806d9 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 1.6.18.1 + 1.6.19.1 Copyright © FakeFish 2018-2023 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs index 33c011b33..0eac85551 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs @@ -1711,7 +1711,34 @@ namespace Barotrauma SpawnItem(args, cursorWorldPos, client.Character, out string errorMsg); if (!string.IsNullOrWhiteSpace(errorMsg)) { - GameMain.Server.SendConsoleMessage(errorMsg, client); + GameMain.Server.SendConsoleMessage(errorMsg, client, Color.Red); + } + } + ); + + AssignOnClientRequestExecute( + "give", + (Client client, Vector2 cursorWorldPos, string[] args) => + { + if (client.Character == null) + { + GameMain.Server.SendConsoleMessage("No character is selected!", client, Color.Red); + return; + } + + if (args.Length == 0) + { + GameMain.Server.SendConsoleMessage("Please give the name or identifier of the item to spawn.", client, Color.Red); + return; + } + + var modifiedArgs = new List(args); + modifiedArgs.Insert(1, "inventory"); + + SpawnItem(modifiedArgs.ToArray(), cursorWorldPos, client.Character, out string errorMsg); + if (!string.IsNullOrWhiteSpace(errorMsg)) + { + GameMain.Server.SendConsoleMessage(errorMsg, client, Color.Red); } } ); diff --git a/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs index 8f5bc4565..d6b837cb7 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs @@ -1290,9 +1290,17 @@ namespace Barotrauma.Networking { mpCampaign.SendCrewState(); } - else if (GameMain.GameSession.GameMode is PvPMode && c.TeamID == CharacterTeamType.None) + else if (GameMain.GameSession.GameMode is PvPMode) { - AssignClientToPvpTeamMidgame(c); + if (c.TeamID == CharacterTeamType.None) + { + AssignClientToPvpTeamMidgame(c); + } + } + else + { + //everyone's in team 1 in non-pvp game modes + c.TeamID = CharacterTeamType.Team1; } c.InGame = true; } diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 7ded7773a..05e5b5635 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 1.6.18.1 + 1.6.19.1 Copyright © FakeFish 2018-2023 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaShared/Data/permissionpresets.xml b/Barotrauma/BarotraumaShared/Data/permissionpresets.xml index 038059a5d..68be436bb 100644 --- a/Barotrauma/BarotraumaShared/Data/permissionpresets.xml +++ b/Barotrauma/BarotraumaShared/Data/permissionpresets.xml @@ -56,6 +56,7 @@ + diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs index bb796b36e..8e276723c 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs @@ -818,8 +818,9 @@ namespace Barotrauma newStrength += existingAffliction.Strength; } newStrength = Math.Min(existingAffliction.Prefab.MaxStrength, newStrength); - if (existingAffliction == stunAffliction) { Character.SetStun(newStrength, true, true); } existingAffliction.Strength = newStrength; + //set stun after setting the strength, because stun multipliers might want to set the strength to something else + if (existingAffliction == stunAffliction) { Character.SetStun(newStrength, allowStunDecrease: true, isNetworkMessage: true); } existingAffliction.Duration = existingAffliction.Prefab.Duration; if (newAffliction.Source != null) { existingAffliction.Source = newAffliction.Source; } if (recalculateVitality) diff --git a/Barotrauma/BarotraumaShared/SharedSource/ContentManagement/ContentFile/RandomEventsFile.cs b/Barotrauma/BarotraumaShared/SharedSource/ContentManagement/ContentFile/RandomEventsFile.cs index 51518e428..7896e1214 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/ContentManagement/ContentFile/RandomEventsFile.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/ContentManagement/ContentFile/RandomEventsFile.cs @@ -1,4 +1,4 @@ -using System.Xml.Linq; +using System.Xml.Linq; namespace Barotrauma { @@ -77,12 +77,15 @@ namespace Barotrauma var rootElement = doc.Root.FromPackage(ContentPackage); LoadFromXElement(rootElement, false); + + EventSet.RefreshAllEventPrefabs(); } public override void UnloadFile() { EventPrefab.Prefabs.RemoveByFile(this); EventSet.Prefabs.RemoveByFile(this); + EventSet.RefreshAllEventPrefabs(); #if CLIENT EventSprite.Prefabs.RemoveByFile(this); #endif @@ -92,6 +95,9 @@ namespace Barotrauma { EventPrefab.Prefabs.SortAll(); EventSet.Prefabs.SortAll(); + //need to referesh, because the order of the prefabs may affect which content package overrides some event + EventSet.RefreshAllEventPrefabs(); + #if CLIENT EventSprite.Prefabs.SortAll(); #endif diff --git a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs index d9188707d..e1442dc70 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs @@ -273,12 +273,18 @@ namespace Barotrauma { if (Character.Controlled == null) { - NewMessage("No character is selected!", Color.Red); + ThrowError("No character is selected!"); + return; + } + + if (args.Length == 0) + { + ThrowError("Please give the name or identifier of the item to spawn."); + return; } var modifiedArgs = new List(args); modifiedArgs.Insert(1, "inventory"); - TrySpawnItem(modifiedArgs.ToArray()); }, getValidArgs: () => diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/EventSet.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/EventSet.cs index 0c201b596..915795961 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Events/EventSet.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Events/EventSet.cs @@ -61,25 +61,46 @@ namespace Barotrauma } #endif - public static List GetAllEventPrefabs() + private static readonly Dictionary AllEventPrefabs = new Dictionary(); + + public static IEnumerable GetAllEventPrefabs() { - List eventPrefabs = EventPrefab.Prefabs.ToList(); - foreach (var eventSet in Prefabs) - { - AddSetEventPrefabsToList(eventPrefabs, eventSet); - } - return eventPrefabs; + return AllEventPrefabs.Values; } - public static void AddSetEventPrefabsToList(List list, EventSet set) + /// + /// Finds all the event prefabs (both "normal prefabs" that exists by themselves, present in , and the ones that exists only inside child event sets), + /// and adds them to . + /// + public static void RefreshAllEventPrefabs() { - list.AddRange(set.EventPrefabs.SelectMany(ep => ep.EventPrefabs).Where(ep => !list.Contains(ep))); - foreach (var childSet in set.ChildSets) { AddSetEventPrefabsToList(list, childSet); } + AllEventPrefabs.Clear(); + foreach (var eventPrefab in EventPrefab.Prefabs) + { + AllEventPrefabs.TryAdd(eventPrefab.Identifier, eventPrefab); + } + foreach (var eventSet in Prefabs) + { + AddChildEventPrefabs(eventSet); + } + } + + private static void AddChildEventPrefabs(EventSet set) + { + foreach (var subEventPrefabs in set.EventPrefabs) + { + foreach (var eventPrefab in subEventPrefabs.EventPrefabs) + { + AllEventPrefabs.TryAdd(eventPrefab.Identifier, eventPrefab); + } + } + + foreach (var childSet in set.ChildSets) { AddChildEventPrefabs(childSet); } } public static EventPrefab GetEventPrefab(Identifier identifier) { - return GetAllEventPrefabs().Find(prefab => prefab.Identifier == identifier); + return AllEventPrefabs.GetValueOrDefault(identifier); } /// diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/CargoMission.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/CargoMission.cs index 47b0092de..1303cded9 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/CargoMission.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/CargoMission.cs @@ -150,7 +150,7 @@ namespace Barotrauma int maxCount = subElement.GetAttributeInt("maxcount", 10); if (itemsToSpawn.Count(it => it.element == subElement) >= maxCount) { continue; } ItemPrefab itemPrefab = FindItemPrefab(subElement); - while (containers[i].freeSlots > 0 && containers[i].container.Inventory.CanBePut(itemPrefab)) + while (containers[i].freeSlots > 0 && containers[i].container.Inventory.CanProbablyBePut(itemPrefab)) { containers[i] = (containers[i].container, containers[i].freeSlots - 1); itemsToSpawn.Add((subElement, containers[i].container)); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/PirateMission.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/PirateMission.cs index d70a16c03..37736d608 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/PirateMission.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Events/Missions/PirateMission.cs @@ -479,10 +479,7 @@ namespace Barotrauma } #endif enemySub.SetPosition(spawnPos); - if (!IsClient) - { - InitPirateShip(); - } + InitPirateShip(); // flipping the sub on the frame it is moved into place must be done after it's been moved, or it breaks item connections in the submarine // creating the pirates has to be done after the sub has been flipped, or it seems to break the AI pathing diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs b/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs index 3e9057807..9a6228b27 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/GameSession/AutoItemPlacer.cs @@ -333,7 +333,7 @@ namespace Barotrauma } var existingItem = validContainer.Key.Inventory.AllItems.FirstOrDefault(it => it.Prefab == itemPrefab); int quality = existingItem?.Quality ?? Quality.GetSpawnedItemQuality(validContainer.Key.Item.Submarine, Level.Loaded, Rand.RandSync.ServerAndClient); - if (!validContainer.Key.Inventory.CanBePut(itemPrefab, quality: quality)) { break; } + if (!validContainer.Key.Inventory.CanProbablyBePut(itemPrefab, quality: quality)) { break; } var item = new Item(itemPrefab, validContainer.Key.Item.Position, validContainer.Key.Item.Submarine, callOnItemLoaded: false) { SpawnedInCurrentOutpost = validContainer.Key.Item.SpawnedInCurrentOutpost, diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameSession/CargoManager.cs b/Barotrauma/BarotraumaShared/SharedSource/GameSession/CargoManager.cs index 7177df8f2..a517c2317 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/GameSession/CargoManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/GameSession/CargoManager.cs @@ -546,7 +546,7 @@ namespace Barotrauma if (!string.IsNullOrEmpty(item.CargoContainerIdentifier)) { itemContainer = availableContainers.Find(ac => - ac.Inventory.CanBePut(item) && + ac.Inventory.CanProbablyBePut(item) && (ac.Item.Prefab.Identifier == item.CargoContainerIdentifier || ac.Item.Prefab.Tags.Contains(item.CargoContainerIdentifier))); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs index 8e6f90d4d..f8860ee1b 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/ItemContainer.cs @@ -1160,7 +1160,7 @@ namespace Barotrauma.Items.Components foreach (string id in splitIds) { ItemPrefab prefab = ItemPrefab.Prefabs.Find(m => m.Identifier == id); - if (prefab != null && Inventory != null && Inventory.CanBePut(prefab)) + if (prefab != null && Inventory != null && Inventory.CanProbablyBePut(prefab)) { bool isEditor = false; #if CLIENT diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Fabricator.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Fabricator.cs index 84a9286b8..0b310a0da 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Fabricator.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Fabricator.cs @@ -206,7 +206,7 @@ namespace Barotrauma.Items.Components private void StartFabricating(FabricationRecipe selectedItem, Character user, bool addToServerLog = true) { if (selectedItem == null) { return; } - if (!outputContainer.Inventory.CanBePut(selectedItem.TargetItem, selectedItem.OutCondition * selectedItem.TargetItem.Health)) { return; } + if (!outputContainer.Inventory.CanProbablyBePut(selectedItem.TargetItem, selectedItem.OutCondition * selectedItem.TargetItem.Health)) { return; } IsActive = true; this.user = user; diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Inventory.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Inventory.cs index 58556d074..35d324850 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Inventory.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Inventory.cs @@ -58,7 +58,12 @@ namespace Barotrauma return true; } - public bool CanBePut(ItemPrefab itemPrefab, float? condition = null, int? quality = null) + /// + /// Can an instance of the item prefab be put into the slot? + /// Note that if the condition and quality aren't given, they are ignored, and the method can return true even if the item can't go in the slot + /// due to it being occupied by another item with a different condition or quality (which disallows stacking). + /// + public bool CanProbablyBePut(ItemPrefab itemPrefab, float? condition = null, int? quality = null) { if (itemPrefab == null) { return false; } if (items.Count > 0) @@ -518,7 +523,12 @@ namespace Barotrauma return slots[i].CanBePut(item, ignoreCondition); } - public bool CanBePut(ItemPrefab itemPrefab, float? condition = null, int? quality = null) + /// + /// Can an instance of the item prefab be put into the inventory? + /// Note that if the condition and quality aren't given, they are ignored, and the method can return true even if the item can't go in the inventory + /// due to the slots being occupied by another item with a different condition or quality (which disallows stacking). + /// + public bool CanProbablyBePut(ItemPrefab itemPrefab, float? condition = null, int? quality = null) { for (int i = 0; i < capacity; i++) { @@ -530,7 +540,7 @@ namespace Barotrauma public virtual bool CanBePutInSlot(ItemPrefab itemPrefab, int i, float? condition = null, int? quality = null) { if (i < 0 || i >= slots.Length) { return false; } - return slots[i].CanBePut(itemPrefab, condition); + return slots[i].CanProbablyBePut(itemPrefab, condition, quality); } public int HowManyCanBePut(ItemPrefab itemPrefab, float? condition = null) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/ItemInventory.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/ItemInventory.cs index bc8f2f41f..1a8cf3cc1 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/ItemInventory.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/ItemInventory.cs @@ -55,7 +55,7 @@ namespace Barotrauma { if (i < 0 || i >= slots.Length) { return false; } if (!container.CanBeContained(itemPrefab, i)) { return false; } - return itemPrefab != null && slots[i].CanBePut(itemPrefab, condition, quality) && slots[i].Items.Count < container.GetMaxStackSize(i); + return itemPrefab != null && slots[i].CanProbablyBePut(itemPrefab, condition, quality) && slots[i].Items.Count < container.GetMaxStackSize(i); } public override int HowManyCanBePut(ItemPrefab itemPrefab, int i, float? condition, bool ignoreItemsInSlot = false) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Networking/EntitySpawner.cs b/Barotrauma/BarotraumaShared/SharedSource/Networking/EntitySpawner.cs index 22a4b39f4..885953314 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Networking/EntitySpawner.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Networking/EntitySpawner.cs @@ -70,11 +70,14 @@ namespace Barotrauma Item spawnedItem; if (Inventory?.Owner != null) { - if (!SpawnIfInventoryFull && !Inventory.CanBePut(Prefab)) + if (!SpawnIfInventoryFull && !Inventory.CanProbablyBePut(Prefab)) { return null; } spawnedItem = new Item(Prefab, Vector2.Zero, null); + //this needs to be done before attempting to put the item in the inventory, + //because the quality and condition may affect whether it can go in the inventory (into an existing stack) + SetItemProperties(spawnedItem); var slot = Slot != InvSlotType.None ? Slot.ToEnumerable() : spawnedItem.AllowedSlots; if (!Inventory.Owner.Removed && !Inventory.TryPutItem(spawnedItem, null, slot)) @@ -96,16 +99,21 @@ namespace Barotrauma else { spawnedItem = new Item(Prefab, Position, Submarine); - } - if (Condition.TryUnwrap(out float condition)) - { - spawnedItem.Condition = condition; - } - if (Quality.TryUnwrap(out int quality)) - { - spawnedItem.Quality = quality; + SetItemProperties(spawnedItem); } return spawnedItem; + + void SetItemProperties(Item spawnedItem) + { + if (Condition.TryUnwrap(out float condition)) + { + spawnedItem.Condition = condition; + } + if (Quality.TryUnwrap(out int quality)) + { + spawnedItem.Quality = quality; + } + } } public void OnSpawned(Entity spawnedItem) diff --git a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs index b85b39080..84a77ba6a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs @@ -2473,7 +2473,7 @@ namespace Barotrauma return; } } - if (inventory != null && (inventory.CanBePut(chosenItemSpawnInfo.ItemPrefab) || chosenItemSpawnInfo.SpawnIfInventoryFull)) + if (inventory != null && (inventory.CanProbablyBePut(chosenItemSpawnInfo.ItemPrefab) || chosenItemSpawnInfo.SpawnIfInventoryFull)) { Entity.Spawner.AddItemToSpawnQueue(chosenItemSpawnInfo.ItemPrefab, inventory, spawnIfInventoryFull: chosenItemSpawnInfo.SpawnIfInventoryFull, onSpawned: item => { @@ -2540,7 +2540,7 @@ namespace Barotrauma foreach (Item item in thisInventory.AllItems) { Inventory containedInventory = item.GetComponent()?.Inventory; - if (containedInventory != null && (containedInventory.CanBePut(chosenItemSpawnInfo.ItemPrefab) || chosenItemSpawnInfo.SpawnIfInventoryFull)) + if (containedInventory != null && (containedInventory.CanProbablyBePut(chosenItemSpawnInfo.ItemPrefab) || chosenItemSpawnInfo.SpawnIfInventoryFull)) { Entity.Spawner.AddItemToSpawnQueue(chosenItemSpawnInfo.ItemPrefab, containedInventory, spawnIfInventoryFull: chosenItemSpawnInfo.SpawnIfInventoryFull, onSpawned: (Item newItem) => { diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt index 1f0207ea3..39ff218e0 100644 --- a/Barotrauma/BarotraumaShared/changelog.txt +++ b/Barotrauma/BarotraumaShared/changelog.txt @@ -1,4 +1,23 @@ ------------------------------------------------------------------------------------------------------------------------------------------------- +v1.6.19.1 +------------------------------------------------------------------------------------------------------------------------------------------------- + +- Fixed chat input box getting cleared whenever someone changes their team, or when the game mode or team selection mode changes. +- Fixed stun resistance PvP setting doing nothing. +- Made Crimson Acid less powerful against large monsters. +- Fixed everyone's name tags being shown in red until you spawn when you join a campaign mid-round. +- Fixed stackable items with a non-default quality (e.g. grenades) failing to stack in the fabricator's output slot, instead just falling to the floor. +- Fixed very large PvP outposts often clipping into the level walls. +- Fixed decorative structures such as background walls not showing up on hostile (non-player) subs in multiplayer. +- Fixed "giveitem" command crashing the game when used with no arguments. +- Fixed Gravity Flak Shell's "gravity pull effect" being affected by gravity. +- Fixed Fulgurium Batteries sometimes spawning automatically in tools at the start of a campaign. +- Changed cargo scooter recipe to be more consistent with the normal scooter recipe (Underwater Scooter + x2 Ti-Al Alloy). + +Modding: +- Fixed freezes / lag spikes in multiplayer when a scripted event uses StatusEffectAction when there's lots of mods with custom events enabled. + +------------------------------------------------------------------------------------------------------------------------------------------------- v1.6.18.1 -------------------------------------------------------------------------------------------------------------------------------------------------