Skip to content

Commit

Permalink
v1.6.19.1 (Unto the Breach Hotfix 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Regalis11 committed Oct 31, 2024
1 parent c015059 commit 26ffd21
Show file tree
Hide file tree
Showing 28 changed files with 177 additions and 56 deletions.
7 changes: 7 additions & 0 deletions Barotrauma/BarotraumaClient/ClientSource/GUI/GUITextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -918,5 +918,12 @@ private void CalculateSelection()
DebugConsole.ThrowError($"GUITextBox: Invalid selection: ({exception})");
}
}

public void ResetDelegates()
{
OnKeyHit = null;
OnEnterPressed = null;
OnTextChanged = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ private bool StartButtonClicked(GUIButton button, object obj)
{
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;
Expand Down
30 changes: 20 additions & 10 deletions Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ private void UpdatePlayerFrame(CharacterInfo characterInfo, bool allowEditing, G
UpdateJobPreferences(GameMain.Client?.CharacterInfo ?? Character.Controlled?.Info);
JobSelectionFrame = null;
RefreshChatrow(); // to enable/disable team chat according to current selection

return true;
};

Expand Down Expand Up @@ -4772,19 +4772,29 @@ public void RefreshChatrow()
{
TeamChatSelected = false;
}
chatInput = new GUITextBox(new RectTransform(new Vector2(0.75f, 1.0f), chatRow.RectTransform, Anchor.CenterRight))

if (chatInput != null)
{
MaxTextLength = ChatMessage.MaxLength,
Font = GUIStyle.SmallFont,
DeselectAfterMessage = false
};
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();
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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5937,7 +5937,7 @@ void TryDragItemsToInventory(Inventory inv)
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;
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/LinuxClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>1.6.18.1</Version>
<Version>1.6.19.1</Version>
<Copyright>Copyright © FakeFish 2018-2024</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/MacClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>1.6.18.1</Version>
<Version>1.6.19.1</Version>
<Copyright>Copyright © FakeFish 2018-2024</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/WindowsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>1.6.18.1</Version>
<Version>1.6.19.1</Version>
<Copyright>Copyright © FakeFish 2018-2024</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/LinuxServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>1.6.18.1</Version>
<Version>1.6.19.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/MacServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>1.6.18.1</Version>
<Version>1.6.19.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
29 changes: 28 additions & 1 deletion Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,34 @@ string eventDebugStr(ServerEntityEvent ev)
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<string>(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);
}
}
);
Expand Down
12 changes: 10 additions & 2 deletions Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,17 @@ private void ClientReadIngame(IReadMessage inc)
{
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;
}
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/WindowsServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>1.6.18.1</Version>
<Version>1.6.19.1</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
1 change: 1 addition & 0 deletions Barotrauma/BarotraumaShared/Data/permissionpresets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Command name="showperm"/>
<Command name="spawn"/>
<Command name="spawnitem"/>
<Command name="give"/>
<Command name="disablecrewai"/>
<Command name="gamemode"/>
<Command name="sub"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,9 @@ private void AddLimbAffliction(LimbHealth limbHealth, Limb limb, Affliction newA
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Xml.Linq;
using System.Xml.Linq;

namespace Barotrauma
{
Expand Down Expand Up @@ -77,12 +77,15 @@ public override void LoadFile()

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
Expand All @@ -92,6 +95,9 @@ public override void Sort()
{
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
Expand Down
10 changes: 8 additions & 2 deletions Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,18 @@ void printMapEntityPrefabs<T>(IEnumerable<T> prefabs) where T : MapEntityPrefab
{
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<string>(args);
modifiedArgs.Insert(1, "inventory");

TrySpawnItem(modifiedArgs.ToArray());
},
getValidArgs: () =>
Expand Down
37 changes: 29 additions & 8 deletions Barotrauma/BarotraumaShared/SharedSource/Events/EventSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,46 @@ public static Sprite GetEventSprite(string identifier)
}
#endif

public static List<EventPrefab> GetAllEventPrefabs()
private static readonly Dictionary<Identifier, EventPrefab> AllEventPrefabs = new Dictionary<Identifier, EventPrefab>();

public static IEnumerable<EventPrefab> GetAllEventPrefabs()
{
List<EventPrefab> eventPrefabs = EventPrefab.Prefabs.ToList();
return AllEventPrefabs.Values;
}

/// <summary>
/// Finds all the event prefabs (both "normal prefabs" that exists by themselves, present in <see cref="EventPrefab.Prefabs"/>, and the ones that exists only inside child event sets),
/// and adds them to <see cref="AllEventPrefabs"/>.
/// </summary>
public static void RefreshAllEventPrefabs()
{
AllEventPrefabs.Clear();
foreach (var eventPrefab in EventPrefab.Prefabs)
{
AllEventPrefabs.TryAdd(eventPrefab.Identifier, eventPrefab);
}
foreach (var eventSet in Prefabs)
{
AddSetEventPrefabsToList(eventPrefabs, eventSet);
AddChildEventPrefabs(eventSet);
}
return eventPrefabs;
}

public static void AddSetEventPrefabsToList(List<EventPrefab> list, EventSet set)
private static void AddChildEventPrefabs(EventSet set)
{
list.AddRange(set.EventPrefabs.SelectMany(ep => ep.EventPrefabs).Where(ep => !list.Contains(ep)));
foreach (var childSet in set.ChildSets) { AddSetEventPrefabsToList(list, childSet); }
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);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void DetermineCargo()
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,7 @@ protected override void StartMissionSpecific(Level level)
}
#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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private static List<Item> CreateItems(ItemPrefab itemPrefab, List<ItemContainer>
}
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public static ItemContainer GetOrCreateCargoContainerFor(ItemPrefab item, ISpati
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)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ private void SpawnAlwaysContainedItems()
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void RemoveFabricationRecipes(IEnumerable<Identifier> allowedIdentifiers)
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;
Expand Down
Loading

0 comments on commit 26ffd21

Please sign in to comment.