Procházet zdrojové kódy

Tidy the emote wheel changes

Applies the project's clang-format style to the lines this branch touched,
drops an out-parameter that only the validation inside the function reads, and
brings the ensure_character_emote_collection contract comment up to date with
the repair and skip behaviour it gained during review.

No behaviour change. clang-tidy reports nothing on the changed files beyond
the readability-duplicate-include noise the tree already produces everywhere.
Millie před 3 týdny
rodič
revize
f1343185d0

+ 7 - 8
Sunrise/src/server/bap/encrypted/push/queuez/queuez_banner_push.cpp

@@ -356,14 +356,13 @@ bool append_socket_appearance_refresh_notification(
         return false;
         return false;
     }
     }
     snapshot::Prepared prepared{};
     snapshot::Prepared prepared{};
-    if (!snapshot::prepare_character_appearance_refresh(
-            scratch,
-            refresh,
-            mutation.afterCharacter,
-            mutation.characterIndex,
-            nativeEquipmentSlot,
-            true,
-            prepared)) {
+    if (!snapshot::prepare_character_appearance_refresh(scratch,
+                                                        refresh,
+                                                        mutation.afterCharacter,
+                                                        mutation.characterIndex,
+                                                        nativeEquipmentSlot,
+                                                        true,
+                                                        prepared)) {
         return false;
         return false;
     }
     }
     return append_appearance_frame(
     return append_appearance_frame(

+ 8 - 4
Sunrise/src/state/runtime/runtime.h

@@ -58,10 +58,14 @@ struct PendingSubclassSelection {
 [[nodiscard]] bool commit_subclass_selection(PendingSubclassSelection& mutation) noexcept;
 [[nodiscard]] bool commit_subclass_selection(PendingSubclassSelection& mutation) noexcept;
 
 
 /**
 /**
- * Equips each character with the "Emotes" collection item (hash 3183180185) in the emote slot,
- * in place of an individual emote, if it is not already equipped there. The stock client opens
- * its own wheel-configuration screen for this item; the 4 ordinary sockets seed default lanes
- * from its real plug pool so the wheel has something in every slot the first time it opens.
+ * Equips each character with the "Emotes" collection item (hash 3183180185) in the emote slot, in
+ * place of an individual emote. The stock client opens its own wheel-configuration screen for this
+ * item; its 4 ordinary sockets seed default lanes from the item's real plug pool so the wheel has
+ * something in every slot the first time it opens.
+ * Idempotent, and safe to call from more than one boundary: a character already carrying a sound
+ * copy is left alone, one whose sockets no longer resolve is repaired in place and keeps its
+ * existing instance identity, and a build whose content does not match what this expects is
+ * skipped rather than reported as a failure.
  */
  */
 [[nodiscard]] bool ensure_character_emote_collection() noexcept;
 [[nodiscard]] bool ensure_character_emote_collection() noexcept;
 
 

+ 14 - 16
Sunrise/src/state/runtime/state_account_acquisition_runtime.cpp

@@ -602,15 +602,16 @@ constexpr std::array<std::uint32_t, authored_inventory::kEmoteCollectionSocketLa
     };
     };
 
 
 /**
 /**
- * Resolves and cross-checks the "Emotes" collection item's own configured content.
+ * Resolves and cross-checks the "Emotes" collection item's own configured content. The detail row
+ * is only read to validate the definition, so it stays local rather than reaching the caller.
  * @param definition Receives the matching native item-definition row.
  * @param definition Receives the matching native item-definition row.
- * @param detail Receives the matching configured item detail.
  * @return True only when both rows agree with each other, carry no native equipment slot (the one
  * @return True only when both rows agree with each other, carry no native equipment slot (the one
  *         trait that singles this item out among every character-scoped item), and declare exactly
  *         trait that singles this item out among every character-scoped item), and declare exactly
  *         the expected 4 ordinary socket lanes.
  *         the expected 4 ordinary socket lanes.
  */
  */
-[[nodiscard]] bool resolve_emote_collection_definition(build_data::items::Definition& definition,
-                                                        item_details::Definition& detail) noexcept {
+[[nodiscard]] bool
+resolve_emote_collection_definition(build_data::items::Definition& definition) noexcept {
+    item_details::Definition detail{};
     return build_data::find_item_definition_hash(authored_inventory::kEmoteCollectionDefinitionHash,
     return build_data::find_item_definition_hash(authored_inventory::kEmoteCollectionDefinitionHash,
                                                  definition)
                                                  definition)
            && definition.definitionHash == authored_inventory::kEmoteCollectionDefinitionHash
            && definition.definitionHash == authored_inventory::kEmoteCollectionDefinitionHash
@@ -630,7 +631,7 @@ constexpr std::array<std::uint32_t, authored_inventory::kEmoteCollectionSocketLa
     for (std::size_t lane = 0; lane < kEmoteCollectionDefaultPlugHashes.size(); ++lane) {
     for (std::size_t lane = 0; lane < kEmoteCollectionDefaultPlugHashes.size(); ++lane) {
         build_data::items::Definition plugDefinition{};
         build_data::items::Definition plugDefinition{};
         if (!build_data::find_item_definition_hash(kEmoteCollectionDefaultPlugHashes[lane],
         if (!build_data::find_item_definition_hash(kEmoteCollectionDefaultPlugHashes[lane],
-                                                    plugDefinition)
+                                                   plugDefinition)
             || !build_data::is_socket_plug_allowed(collectionDefinitionIndex,
             || !build_data::is_socket_plug_allowed(collectionDefinitionIndex,
                                                    static_cast<std::uint8_t>(lane),
                                                    static_cast<std::uint8_t>(lane),
                                                    plugDefinition.definitionIndex)) {
                                                    plugDefinition.definitionIndex)) {
@@ -644,8 +645,8 @@ constexpr std::array<std::uint32_t, authored_inventory::kEmoteCollectionSocketLa
  * Checks an already-equipped collection item's own socket state, so a corrupted or stale set of
  * Checks an already-equipped collection item's own socket state, so a corrupted or stale set of
  * plugs is repaired instead of trusted just because the definition hash already matches.
  * plugs is repaired instead of trusted just because the definition hash already matches.
  */
  */
-[[nodiscard]] bool
-socket_state_sound(const authored_inventory::Item& item, std::uint16_t collectionDefinitionIndex) noexcept {
+[[nodiscard]] bool socket_state_sound(const authored_inventory::Item& item,
+                                      std::uint16_t collectionDefinitionIndex) noexcept {
     if (item.sockets.policy != authored_inventory::SocketPolicy::authored
     if (item.sockets.policy != authored_inventory::SocketPolicy::authored
         || item.sockets.plugCount != authored_inventory::kEmoteCollectionSocketLaneCount) {
         || item.sockets.plugCount != authored_inventory::kEmoteCollectionSocketLaneCount) {
         return false;
         return false;
@@ -686,8 +687,7 @@ bool ensure_character_emote_collection() noexcept {
     // being wrong -- just isn't ready for the migration; skip this boot without failing the whole
     // being wrong -- just isn't ready for the migration; skip this boot without failing the whole
     // refresh, the same way the account-not-ready check below does.
     // refresh, the same way the account-not-ready check below does.
     build_data::items::Definition collectionDefinition{};
     build_data::items::Definition collectionDefinition{};
-    item_details::Definition collectionDetail{};
-    if (!resolve_emote_collection_definition(collectionDefinition, collectionDetail)
+    if (!resolve_emote_collection_definition(collectionDefinition)
         || !default_plugs_valid(collectionDefinition.definitionIndex)) {
         || !default_plugs_valid(collectionDefinition.definitionIndex)) {
         return true;
         return true;
     }
     }
@@ -700,16 +700,14 @@ bool ensure_character_emote_collection() noexcept {
     }
     }
     bool changed = false;
     bool changed = false;
     bool failed = false;
     bool failed = false;
-    for (std::size_t characterIndex = 0;
-         characterIndex < candidate.characterCount && !failed;
+    for (std::size_t characterIndex = 0; characterIndex < candidate.characterCount && !failed;
          ++characterIndex) {
          ++characterIndex) {
         CharacterState& character = candidate.characters[characterIndex];
         CharacterState& character = candidate.characters[characterIndex];
         auto& collectionSlot = character.equipment.slots[kEmoteCollectionSlot];
         auto& collectionSlot = character.equipment.slots[kEmoteCollectionSlot];
-        const bool present = collectionSlot.has_value()
-                             && collectionSlot->definitionHash
-                                    == authored_inventory::kEmoteCollectionDefinitionHash;
-        if (present
-            && socket_state_sound(*collectionSlot, collectionDefinition.definitionIndex)) {
+        const bool present =
+            collectionSlot.has_value()
+            && collectionSlot->definitionHash == authored_inventory::kEmoteCollectionDefinitionHash;
+        if (present && socket_state_sound(*collectionSlot, collectionDefinition.definitionIndex)) {
             continue;
             continue;
         }
         }
         if (character.nextInventorySerial
         if (character.nextInventorySerial