(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.

This commit is contained in:
Joonas Rikkonen
2019-06-04 15:36:21 +03:00
parent 1a011971d0
commit f6e6218bb1
4 changed files with 14 additions and 8 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -703,13 +703,17 @@ namespace Barotrauma.Networking
Dictionary<ItemPrefab, int> extraCargo = new Dictionary<ItemPrefab, int>();
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<ItemPrefab, int> 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);
}
}
}