bugfix: prevent skipping over 1

Maintainers expect _currentCollectionIdValue to start at 1, and I don't want to change that
This commit is contained in:
mayo 2025-11-01 17:22:45 -04:00
parent 1d7603bb8c
commit cc95678d05
No known key found for this signature in database
GPG key ID: 5B138E78344184A6

View file

@ -89,8 +89,12 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable, ISer
/// <remarks> Starts at 1 because the empty collection gets Zero. </remarks>
public LocalCollectionId CurrentCollectionId => new(_currentCollectionIdValue);
private LocalCollectionId AllocateNextId ()
=> new(Interlocked.Increment(ref _currentCollectionIdValue));
private LocalCollectionId AllocateNextId ()
{
var newLocalId = new LocalCollectionId(_currentCollectionIdValue);
Interlocked.Increment(ref _currentCollectionIdValue);
return newLocalId;
}
/// <summary> Default enumeration skips the empty collection. </summary>
public IEnumerator<ModCollection> GetEnumerator()