Просмотр исходного кода

Remove the unused dialogue group spans

The list reader replaced the only caller of dialogue_group_index::build
and find, so both go with their Span type. definitions() stays; the cue
count and the list reader both use it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
stan 4 дней назад
Родитель
Сommit
2bfaefb914

+ 0 - 67
Sunrise/src/client/content/activity/activity_sdk_dialogue_group_index.cpp

@@ -1,6 +1,5 @@
 #include "activity_sdk_dialogue_group_index.h"
 
-#include <algorithm>
 #include <cmath>
 #include <cstring>
 #include <limits>
@@ -10,8 +9,6 @@
 namespace sunrise::client::content::activity::sdk_generation::dialogue_group_index {
 namespace {
 
-// One dialogue group row is 16 bytes in the blob.
-constexpr std::size_t kGroupStride = 16U;
 // The bank stores a counted definition array at +8 with an eight-byte row stride.
 constexpr std::size_t kDefinitionsField = 8U;
 constexpr std::size_t kDefinitionStride = 8U;
@@ -96,68 +93,4 @@ bool definitions(std::span<const std::byte> bytes, std::vector<Definition>& outp
     }
 }
 
-/** Builds the sorted group index over one dialogue blob. @return False when it is malformed. */
-bool build(std::span<const std::byte> bytes,
-           std::size_t groupRows,
-           std::size_t groupCount,
-           std::vector<Span>& output) noexcept {
-    output.clear();
-    if (groupRows > bytes.size() || groupCount > (bytes.size() - groupRows) / kGroupStride) {
-        return false;
-    }
-    try {
-        output.reserve(groupCount);
-        for (std::size_t index = 0; index < groupCount; ++index) {
-            const std::size_t row = groupRows + index * kGroupStride;
-            Span group{};
-            std::int64_t relative = 0;
-            if (!read_value(bytes, row, group.definitionHash)
-                || !read_value(bytes, row + 8U, relative)
-                || !add_relative(row + 8U, relative, group.begin) || group.begin > bytes.size()) {
-                output.clear();
-                return false;
-            }
-            output.push_back(group);
-        }
-        for (Span& group : output) {
-            group.end = bytes.size();
-            for (const Span& candidate : output) {
-                if (candidate.begin > group.begin && candidate.begin < group.end) {
-                    group.end = candidate.begin;
-                }
-            }
-        }
-        std::sort(output.begin(), output.end(), [](const Span& first, const Span& second) {
-            return first.definitionHash < second.definitionHash;
-        });
-        if (std::adjacent_find(output.begin(),
-                               output.end(),
-                               [](const Span& first, const Span& second) {
-                                   return first.definitionHash == second.definitionHash;
-                               })
-            != output.end()) {
-            output.clear();
-            return false;
-        }
-        return true;
-    } catch (...) {
-        output.clear();
-        return false;
-    }
-}
-
-/** Finds one group by definition hash in the sorted index. */
-bool find(std::span<const Span> groups, std::uint32_t definitionHash, Span& output) noexcept {
-    output = {};
-    const auto row = std::lower_bound(
-        groups.begin(), groups.end(), definitionHash, [](const Span& group, std::uint32_t hash) {
-            return group.definitionHash < hash;
-        });
-    if (row == groups.end() || row->definitionHash != definitionHash) {
-        return false;
-    }
-    output = *row;
-    return true;
-}
-
 } // namespace sunrise::client::content::activity::sdk_generation::dialogue_group_index

+ 0 - 17
Sunrise/src/client/content/activity/activity_sdk_dialogue_group_index.h

@@ -7,13 +7,6 @@
 
 namespace sunrise::client::content::activity::sdk_generation::dialogue_group_index {
 
-/** One content range keyed by its authored dialogue definition hash. */
-struct Span final {
-    std::uint32_t definitionHash{};
-    std::size_t begin{};
-    std::size_t end{};
-};
-
 /** One cue definition's delayed-request expiration window, in seconds. */
 struct Definition final {
     std::uint32_t hash{};
@@ -26,14 +19,4 @@ struct Definition final {
 [[nodiscard]] bool definitions(std::span<const std::byte> bytes,
                                std::vector<Definition>& output) noexcept;
 
-/** Builds a hash-sorted index from the native 16-byte dialogue group rows. */
-[[nodiscard]] bool build(std::span<const std::byte> bytes,
-                         std::size_t groupRows,
-                         std::size_t groupCount,
-                         std::vector<Span>& output) noexcept;
-
-/** Finds the content range for one cue definition hash. */
-[[nodiscard]] bool
-find(std::span<const Span> groups, std::uint32_t definitionHash, Span& output) noexcept;
-
 } // namespace sunrise::client::content::activity::sdk_generation::dialogue_group_index