From f6e6218bb13596626331e9e62609c6155cbcd92a Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 4 Jun 2019 15:36:21 +0300 Subject: [PATCH] (6736960da) Fixes to name-based item checks that wouldn't work correctly if playing in a language other than English: - Fixed Item.ReadSpawnData failing to find the correct prefab if the client is using a different language than the server, a couple of fixes to name-based item checks. - Fixed extra cargo spawning. - Fixed clients not getting correct ID card tags for the respawn shuttle. --- Barotrauma/BarotraumaServer/Source/Items/Item.cs | 2 +- .../Source/Networking/RespawnManager.cs | 2 +- .../BarotraumaShared/Source/Map/WayPoint.cs | 2 +- .../Source/Networking/ServerSettings.cs | 16 +++++++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Barotrauma/BarotraumaServer/Source/Items/Item.cs b/Barotrauma/BarotraumaServer/Source/Items/Item.cs index beb831abf..8e29b0a21 100644 --- a/Barotrauma/BarotraumaServer/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaServer/Source/Items/Item.cs @@ -193,7 +193,7 @@ namespace Barotrauma { if (GameMain.Server == null) return; - msg.Write(Prefab.Name); + msg.Write(Prefab.OriginalName); msg.Write(Prefab.Identifier); msg.Write(Description != prefab.Description); if (Description != prefab.Description) diff --git a/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs b/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs index 593bec08f..a27e15083 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/RespawnManager.cs @@ -232,7 +232,7 @@ namespace Barotrauma.Networking //add the ID card tags they should've gotten when spawning in the shuttle foreach (Item item in character.Inventory.Items) { - if (item == null || item.Prefab.Name != "ID Card") continue; + if (item == null || item.Prefab.Identifier != "idcard") continue; foreach (string s in shuttleSpawnPoints[i].IdCardTags) { item.AddTag(s); diff --git a/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs b/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs index 7d1dac36e..e2df8eafb 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs @@ -91,7 +91,7 @@ namespace Barotrauma public WayPoint(MapEntityPrefab prefab, Rectangle rectangle) : this (rectangle, Submarine.MainSub) { - if (prefab.Name.Contains("Spawn")) + if (prefab.Identifier.Contains("spawn")) { spawnType = SpawnType.Human; } diff --git a/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs b/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs index 5dd5f1546..c4725de49 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/ServerSettings.cs @@ -703,13 +703,17 @@ namespace Barotrauma.Networking Dictionary extraCargo = new Dictionary(); for (int i = 0; i < count; i++) { + string prefabIdentifier = msg.ReadString(); string prefabName = msg.ReadString(); byte amount = msg.ReadByte(); - ItemPrefab ip = MapEntityPrefab.List.Find(p => p is ItemPrefab && p.Name.Equals(prefabName, StringComparison.InvariantCulture)) as ItemPrefab; - if (ip != null && amount > 0) + + var itemPrefab = string.IsNullOrEmpty(prefabIdentifier) ? + MapEntityPrefab.Find(prefabName, null, showErrorMessages: false) as ItemPrefab : + MapEntityPrefab.Find(prefabName, prefabIdentifier, showErrorMessages: false) as ItemPrefab; + if (itemPrefab != null && amount > 0) { - if (changed || !ExtraCargo.ContainsKey(ip) || ExtraCargo[ip] != amount) changed = true; - extraCargo.Add(ip, amount); + if (changed || !ExtraCargo.ContainsKey(itemPrefab) || ExtraCargo[itemPrefab] != amount) changed = true; + extraCargo.Add(itemPrefab, amount); } } if (changed) ExtraCargo = extraCargo; @@ -727,7 +731,9 @@ namespace Barotrauma.Networking msg.Write((UInt32)ExtraCargo.Count); foreach (KeyValuePair kvp in ExtraCargo) { - msg.Write(kvp.Key.Name); msg.Write((byte)kvp.Value); + msg.Write(kvp.Key.Identifier ?? ""); + msg.Write(kvp.Key.OriginalName ?? ""); + msg.Write((byte)kvp.Value); } } }