Selaa lähdekoodia

Rebase fixes: cache format 48 and the SrwLock guard form

Master reached cache format 47 with the exotic catalyst records. This
branch renamed the sale row's installedIndex to categoryIndex under an
earlier number, so the two shapes shared one. 48 keeps both changes and
forces a rebuild of the cache.

Master also replaced the build_data Lock class with core::threading::SrwLock
and std::shared_lock. The three vendor and collectible readers this branch
added take the same guard form now.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017y4GeUXaw46fq2mDFGBVHN
stan 4 päivää sitten
vanhempi
commit
7236a22a12

+ 1 - 1
Sunrise/src/state/build_data/cache/records/format.h

@@ -30,7 +30,7 @@ inline constexpr std::array<char, 8> kCacheMagic{'S', 'U', 'N', 'R', 'I', 'S', '
  * Bump it when a stored shape changes, and when the extraction filling it changes what it writes.
  * A cached row survives a code change, so a corrected walk keeps publishing the old rows.
  */
-inline constexpr std::uint32_t kCacheFormatVersion = 47;
+inline constexpr std::uint32_t kCacheFormatVersion = 48;
 /** Signed -1 on disk means there is no equipment slot. */
 inline constexpr std::int8_t kAbsentEquipmentSlot = -1;
 /** The standard 64-bit FNV-1a offset basis starts the payload checksum. */

+ 1 - 1
Sunrise/src/state/build_data/collectibles/collectible_catalog.cpp

@@ -111,7 +111,7 @@ bool find_granting(std::uint16_t itemDefinitionIndex, std::uint16_t& collectible
     if (itemDefinitionIndex == kUnavailableItemDefinitionIndex) {
         return false;
     }
-    const Lock::Shared guard(g_lock);
+    const std::shared_lock guard(g_lock);
     for (const Definition& definition : g_definitions.rows()) {
         if (definition.itemDefinitionIndex == itemDefinitionIndex) {
             collectibleIndex = definition.collectibleIndex;

+ 2 - 2
Sunrise/src/state/build_data/vendors/vendor_catalog.cpp

@@ -271,7 +271,7 @@ bool sale_row(const Definition& definition, std::size_t row, SaleRow& output) no
     if (row >= definition.saleCount) {
         return false;
     }
-    const Lock::Shared guard(g_lock);
+    const std::shared_lock guard(g_lock);
     const auto bank = g_saleRows.rows();
     const std::size_t at = static_cast<std::size_t>(definition.saleRowOffset) + row;
     if (at >= bank.size()) {
@@ -299,7 +299,7 @@ bool installed_row(const Definition& definition, std::size_t row, InstalledRow&
     if (row >= definition.installedCount) {
         return false;
     }
-    const Lock::Shared guard(g_lock);
+    const std::shared_lock guard(g_lock);
     const auto bank = g_installedRows.rows();
     const std::size_t at = static_cast<std::size_t>(definition.installedRowOffset) + row;
     if (at >= bank.size()) {