Unstable v0.15.17.0 (Hex is out of town edition)
This commit is contained in:
@@ -74,24 +74,12 @@ namespace Barotrauma
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Prefabs.Add(new DecalPrefab(element, configFile), allowOverriding || sourceElement.IsOverride());
|
||||
var newPrefab = new DecalPrefab(element, configFile);
|
||||
Prefabs.Add(newPrefab, allowOverriding || sourceElement.IsOverride());
|
||||
newPrefab.CalculatePrefabUIntIdentifier(Prefabs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
using MD5 md5 = MD5.Create();
|
||||
foreach (DecalPrefab prefab in Prefabs)
|
||||
{
|
||||
prefab.UIntIdentifier = ToolBox.StringToUInt32Hash(prefab.Identifier, md5);
|
||||
|
||||
//it's theoretically possible for two different values to generate the same hash, but the probability is astronomically small
|
||||
var collision = Prefabs.Find(p => p != prefab && p.UIntIdentifier == prefab.UIntIdentifier);
|
||||
if (collision != null)
|
||||
{
|
||||
DebugConsole.ThrowError("Hashing collision when generating uint identifiers for Decals: " + prefab.Identifier + " has the same identifier as " + collision.Identifier + " (" + prefab.UIntIdentifier + ")");
|
||||
collision.UIntIdentifier++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveByFile(string filePath)
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class DecalPrefab : IPrefab, IDisposable
|
||||
class DecalPrefab : IPrefab, IHasUintIdentifier, IDisposable
|
||||
{
|
||||
public readonly string Name;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
||||
/// Unique identifier that's generated by hashing the prefab's string identifier.
|
||||
/// Used to reduce the amount of bytes needed to write decal data into network messages in multiplayer.
|
||||
/// </summary>
|
||||
public uint UIntIdentifier;
|
||||
public uint UIntIdentifier { get; set; }
|
||||
|
||||
public string FilePath { get; private set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user