Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ END TEMPLATE-->

### Bugfixes

* Fixed a race condition in parallel prototype loading that could corrupt the prototype variant collection and throw an `ArgumentNullException` when freezing prototype kinds.
* Fixed a prototype losing its inherited data when a partial prototype changes its `parent:`.

### Other
Expand Down
19 changes: 11 additions & 8 deletions Robust.Shared/Prototypes/PrototypeManager.Variantization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,24 @@ private void ReplaceVariantNode(MappingDataNode parentNode, string variantNodeNa
/// <param name="collectionVariants">A list of prototype variants derived from the same source prototype.</param>
private void RegisterVariantCollection(KindData kindData, List<string> collectionVariants)
{
if (kindData.UnfrozenVariants == null)
lock (_variantRegistrationLock)
{
kindData.UnfrozenVariants = kindData.Variants.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToList());
}
if (kindData.UnfrozenVariants == null)
{
kindData.UnfrozenVariants = kindData.Variants.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToList());
}

kindData.UnfrozenVariants.EnsureCapacity(kindData.UnfrozenVariants.Count + collectionVariants.Count);
kindData.UnfrozenVariants.EnsureCapacity(kindData.UnfrozenVariants.Count + collectionVariants.Count);

foreach (var collectionMember in collectionVariants)
{
kindData.UnfrozenVariants[collectionMember] = collectionVariants;
foreach (var collectionMember in collectionVariants)
{
kindData.UnfrozenVariants[collectionMember] = collectionVariants;
}
}
}

/// <summary>
/// Tries to get the list of all variants associated with a given prototype.
/// Tries to get the list of all variants associated with a given prototype.
/// </summary>
/// <param name="collectionMember">The prototype being indexed.</param>
/// <param name="collectionVariants">The collection of variants this prototype belongs to.</param>
Expand Down
5 changes: 5 additions & 0 deletions Robust.Shared/Prototypes/PrototypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public abstract partial class PrototypeManager : IPrototypeManagerInternal
private readonly Dictionary<string, Type> _kindNames = new();
private readonly Dictionary<Type, int> _kindPriorities = new();

/// <summary>
/// Guards <see cref="KindData.UnfrozenVariants"/> against concurrent modification.
/// </summary>
private readonly Lock _variantRegistrationLock = new();

protected ISawmill Sawmill = default!;

private bool _initialized;
Expand Down
Loading