Преглед на файлове

Document the dialogue list reader and the millisecond rounding

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
stan преди 4 дни
родител
ревизия
e16a91cd7b
променени са 2 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. 6 0
      Sunrise/src/client/content/activity/activity_sdk_dialogue_list.cpp
  2. 3 1
      Sunrise/src/state/activity_sdk/activity_sdk_catalog.cpp

+ 6 - 0
Sunrise/src/client/content/activity/activity_sdk_dialogue_list.cpp

@@ -203,6 +203,12 @@ struct Tree final {
 
 } // namespace
 
+/**
+ * Matches each cue definition to the content trees that carry its hash.
+ * @param list Authored dialogue list blob.
+ * @param output Receives the cues, their lines and the shared hashes; reset first.
+ * @return False when the definition or tree arrays are malformed.
+ */
 bool read(std::span<const std::byte> list, Snapshot& output) {
     output = {};
     std::vector<dialogue_group_index::Definition> definitions{};

+ 3 - 1
Sunrise/src/state/activity_sdk/activity_sdk_catalog.cpp

@@ -813,8 +813,10 @@ std::span<const format::DialogueCueText> cue_dialogue_texts(const Catalog& catal
     });
 }
 
+/** @return Zero for a negative or NaN input; saturates at the 32-bit maximum. */
 std::uint32_t authored_milliseconds(float seconds) noexcept {
-    const double value = std::round(static_cast<double>(seconds) * 1000.0);
+    constexpr double kMillisecondsPerSecond = 1000.0;
+    const double value = std::round(static_cast<double>(seconds) * kMillisecondsPerSecond);
     if (!(value > 0.0)) {
         return 0;
     }