Преглед изворни кода

Read the cue definitions through the shared dialogue bank reader

0.5.0 reads the same counted definition array at +8 to bound a type-53 slot's cue
count, so the list reader no longer parses it a second time. It now calls that
reader and keeps only the tree walk, which means both paths accept exactly the
same lists: a definition whose hash is absent, or a bank over the authored cue
ceiling, is refused for the rows as it already is for the count.
Fozkais пре 1 месец
родитељ
комит
fa16187295
1 измењених фајлова са 9 додато и 19 уклоњено
  1. 9 19
      Sunrise/src/client/content/activity/activity_sdk_dialogue_list.cpp

+ 9 - 19
Sunrise/src/client/content/activity/activity_sdk_dialogue_list.cpp

@@ -5,13 +5,12 @@
 #include <cstring>
 #include <limits>
 
+#include "activity_sdk_dialogue_group_index.h"
+
 namespace sunrise::client::content::activity::sdk_generation::dialogue_list {
 namespace {
 
-// List fields: the cue definitions in cue order, then the content trees sorted by hash.
-constexpr std::size_t kDefinitionField = 0x08;
-constexpr std::size_t kDefinitionStride = 8;
-constexpr std::uint32_t kDefinitionArrayClass = 0x80808D18U;
+// The cue definitions come in cue order; the content trees that follow are sorted by hash.
 constexpr std::size_t kTreeField = 0x18;
 constexpr std::size_t kTreeStride = 16;
 constexpr std::uint32_t kTreeArrayClass = 0x80808D19U;
@@ -204,16 +203,10 @@ struct Tree final {
 
 bool read(std::span<const std::byte> list, Snapshot& output) {
     output = {};
-    std::size_t definitions = 0;
-    std::size_t definitionCount = 0;
+    std::vector<dialogue_group_index::Definition> definitions{};
     std::size_t treeRows = 0;
     std::size_t treeCount = 0;
-    if (!read_array(list,
-                    kDefinitionField,
-                    kDefinitionStride,
-                    kDefinitionArrayClass,
-                    definitions,
-                    definitionCount)
+    if (!dialogue_group_index::definitions(list, definitions)
         || !read_array(list, kTreeField, kTreeStride, kTreeArrayClass, treeRows, treeCount)) {
         return false;
     }
@@ -239,14 +232,11 @@ bool read(std::span<const std::byte> list, Snapshot& output) {
         first = last;
     }
 
-    output.cues.resize(definitionCount);
-    for (std::size_t index = 0; index < definitionCount; ++index) {
+    output.cues.resize(definitions.size());
+    for (std::size_t index = 0; index < definitions.size(); ++index) {
         Cue& cue = output.cues[index];
-        const std::size_t row = definitions + index * kDefinitionStride;
-        if (!read_value(list, row, cue.definitionHash) || !read_value(list, row + 4U, cue.seconds)
-            || !std::isfinite(cue.seconds) || cue.seconds < 0.0F) {
-            return false;
-        }
+        cue.definitionHash = definitions[index].hash;
+        cue.seconds = definitions[index].authoredWindowSeconds;
         const auto range = std::equal_range(trees.begin(),
                                             trees.end(),
                                             Tree{cue.definitionHash, 0},