definition.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include <array>
  3. #include <cstddef>
  4. #include <cstdint>
  5. namespace sunrise::state::build_data::nodes {
  6. /** Fixed capacity above the shipped build's 924 presentation nodes. */
  7. inline constexpr std::size_t kDefinitionCapacity = 1024;
  8. /** Child capacity; the widest shipped lore book owns fifteen records. */
  9. inline constexpr std::size_t kChildCapacity = 64;
  10. /** A node whose expression names no addressable value slot carries this instead of an index. */
  11. inline constexpr std::uint16_t kUnavailableValueIndex = 0xFFFFU;
  12. /** Lore-book category bounds derived from the installed node expressions. */
  13. inline constexpr std::uint16_t kLoreNodeFirst = 815U;
  14. inline constexpr std::uint16_t kLoreNodeLast = 854U;
  15. /** @return True when this node is a lore book category, the only kind this build counts. */
  16. [[nodiscard]] constexpr bool lore_category(std::uint16_t definitionIndex) noexcept {
  17. return definitionIndex >= kLoreNodeFirst && definitionIndex <= kLoreNodeLast;
  18. }
  19. /** A node whose gate names no addressable flag carries this instead of an index. */
  20. inline constexpr std::uint16_t kUnavailableFlagIndex = 0xFFFFU;
  21. /** Extracted fields needed to publish one node's visibility and progress. */
  22. struct Definition {
  23. /** Native node row. */
  24. std::uint16_t definitionIndex{};
  25. /** Account value mapping row, or unavailable. */
  26. std::uint16_t valueIndex{kUnavailableValueIndex};
  27. /** Raw account value slot used to resolve contiguous parent slots. */
  28. std::int16_t valueSlot{-1};
  29. /** Raw character value slot, or -1. */
  30. std::int16_t characterValueSlot{-1};
  31. /** Account value index of the parent record's chapter bar. */
  32. std::uint16_t parentValueIndex{kUnavailableValueIndex};
  33. /** Character value index of the parent record's chapter bar. */
  34. std::uint16_t parentCharacterValueIndex{kUnavailableValueIndex};
  35. /** Account flag read by this node's visibility gate. */
  36. std::uint16_t visibilityFlagIndex{kUnavailableFlagIndex};
  37. /** Character flag read by this node's visibility gate. */
  38. std::uint16_t visibilityCharacterFlagIndex{kUnavailableFlagIndex};
  39. /** Character value index read by this node's progress bar. */
  40. std::uint16_t characterValueIndex{kUnavailableValueIndex};
  41. /** Records this node owns, held at node row `+136`. */
  42. std::uint8_t childCount{};
  43. /** Native record rows of the owned records. */
  44. std::array<std::uint16_t, kChildCapacity> children{};
  45. };
  46. } // namespace sunrise::state::build_data::nodes