|
|
@@ -382,72 +382,6 @@ std::size_t apply_character_node_progress(std::span<std::int32_t> characterValue
|
|
|
return written;
|
|
|
}
|
|
|
|
|
|
-/** @return True when this index is already held. */
|
|
|
-bool claimed(std::uint16_t flagIndex) noexcept {
|
|
|
- const std::lock_guard<std::mutex> guard(g_lock);
|
|
|
- return claimed_locked(flagIndex);
|
|
|
-}
|
|
|
-
|
|
|
-/** Claims the first chapter of every lore book still showing a redacted title. */
|
|
|
-std::size_t seed_lore_visibility() noexcept {
|
|
|
- namespace nodes = build_data::nodes;
|
|
|
- std::vector<nodes::Definition> rows(nodes::kDefinitionCapacity);
|
|
|
- std::size_t count = 0;
|
|
|
- if (!nodes::snapshot(std::span<nodes::Definition>{rows}, count)) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- std::size_t seeded = 0;
|
|
|
- for (std::size_t row = 0; row < count; ++row) {
|
|
|
- const nodes::Definition& node = rows[row];
|
|
|
- if (node.definitionIndex < nodes::kLoreNodeFirst
|
|
|
- || node.definitionIndex > nodes::kLoreNodeLast
|
|
|
- || node.childCount == 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // A book that already holds a claim is past its gate and is left as it is.
|
|
|
- bool held = false;
|
|
|
- for (std::size_t child = 0; child < node.childCount && !held; ++child) {
|
|
|
- build_data::records::Definition record{};
|
|
|
- if (build_data::find_record_definition(node.children[child], record)
|
|
|
- && record.completionFlagIndex != build_data::records::kUnavailableFlagIndex) {
|
|
|
- held = claimed(record.completionFlagIndex);
|
|
|
- }
|
|
|
- }
|
|
|
- if (held) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // Skip the first child: a book's first triumph is its parent, the one that counts the
|
|
|
- // rest, and claiming it would not move the category's bar. Naming the parent by the slot it
|
|
|
- // carries is not enough on its own, because that field resolves on only eleven records in
|
|
|
- // the whole table, so position is what actually identifies it and the slot check backs it up.
|
|
|
- for (std::size_t child = 1; child < node.childCount; ++child) {
|
|
|
- build_data::records::Definition record{};
|
|
|
- if (!build_data::find_record_definition(node.children[child], record)
|
|
|
- || record.completionFlagIndex == build_data::records::kUnavailableFlagIndex
|
|
|
- || (node.valueIndex != nodes::kUnavailableValueIndex
|
|
|
- && record.categoryValueIndex == node.valueIndex)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (claim(record.completionFlagIndex, record.scoreValue)) {
|
|
|
- ++seeded;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- std::array<char, 128> line{};
|
|
|
- const int written = std::snprintf(
|
|
|
- line.data(), line.size(), "ev=claims stage=lore_seed result=ok entries=%zu", seeded);
|
|
|
- if (written > 0) {
|
|
|
- core::log::write(core::log::Channel::state, core::log::Level::info,
|
|
|
- {line.data(), static_cast<std::size_t>(written)});
|
|
|
- }
|
|
|
- return seeded;
|
|
|
-}
|
|
|
-
|
|
|
/** @return Total score of every held claim. */
|
|
|
std::uint32_t total_score() noexcept {
|
|
|
const std::lock_guard<std::mutex> guard(g_lock);
|