From 4e3d375ae5d1e987136ab175e62b9ffeb9f3fb78 Mon Sep 17 00:00:00 2001 From: ursinewalrus Date: Mon, 23 Jul 2018 18:57:29 -0500 Subject: [PATCH 1/2] game will now launch on overbuy and extra items will be present on floor, however a GUI error will be generated on match start --- .../BarotraumaShared/Source/GameSession/CargoManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs index 24b1c9c03..941d21b7a 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs @@ -177,8 +177,11 @@ namespace Barotrauma } //reduce the number of available slots in the container - availableContainers[itemContainer]--; - if (availableContainers[itemContainer] <= 0) + if (availableContainers.Count() > 0) + { + availableContainers[itemContainer]--; + } + if (availableContainers.ContainsKey(itemContainer) && availableContainers[itemContainer] <= 0) { availableContainers.Remove(itemContainer); } From c28fd336c9bdbe3790c1e529f385a8a5afcffe33 Mon Sep 17 00:00:00 2001 From: ursinewalrus Date: Mon, 23 Jul 2018 21:32:01 -0500 Subject: [PATCH 2/2] If you buy more than a full box worth of stuff at the store instead of not letting you start the mission it will put the extra stuff in extra boxes for you --- .../Source/GameSession/CargoManager.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs index 941d21b7a..31aa45682 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/CargoManager.cs @@ -110,6 +110,7 @@ namespace Barotrauma } Dictionary availableContainers = new Dictionary(); + ItemPrefab containerPrefab = null; foreach (PurchasedItem Pi in itemsToSpawn) { Vector2 position = new Vector2( @@ -125,7 +126,7 @@ namespace Barotrauma if (itemContainer == null) { - var containerPrefab = MapEntityPrefab.List.Find(ep => + containerPrefab = MapEntityPrefab.List.Find(ep => ep.NameMatches(Pi.itemPrefab.CargoContainerName) || (ep.Tags != null && ep.Tags.Contains(Pi.itemPrefab.CargoContainerName.ToLowerInvariant()))) as ItemPrefab; @@ -151,6 +152,13 @@ namespace Barotrauma } for (int i = 0; i < Pi.quantity; i++) { + if (!availableContainers.ContainsKey(itemContainer)) + { + Item containerItemOverFlow = new Item(containerPrefab, position, wp.Submarine); + itemContainer = containerItemOverFlow.GetComponent(); + availableContainers.Add(itemContainer, itemContainer.Capacity); + } + if (itemContainer == null) { //no container, place at the waypoint @@ -177,7 +185,8 @@ namespace Barotrauma } //reduce the number of available slots in the container - if (availableContainers.Count() > 0) + //if there is a container + if (availableContainers.ContainsKey(itemContainer)) { availableContainers[itemContainer]--; }