From cc95678d0520aa815827f9f2191fc5cf3e1ebed9 Mon Sep 17 00:00:00 2001 From: mayo Date: Sat, 1 Nov 2025 17:22:45 -0400 Subject: [PATCH] bugfix: prevent skipping over 1 Maintainers expect _currentCollectionIdValue to start at 1, and I don't want to change that --- Penumbra/Collections/Manager/CollectionStorage.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Penumbra/Collections/Manager/CollectionStorage.cs b/Penumbra/Collections/Manager/CollectionStorage.cs index c26ce7f9..c20d72bb 100644 --- a/Penumbra/Collections/Manager/CollectionStorage.cs +++ b/Penumbra/Collections/Manager/CollectionStorage.cs @@ -89,8 +89,12 @@ public class CollectionStorage : IReadOnlyList, IDisposable, ISer /// Starts at 1 because the empty collection gets Zero. 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; + } /// Default enumeration skips the empty collection. public IEnumerator GetEnumerator()