seen_state.h 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <array>
  3. #include <cstdint>
  4. #include <span>
  5. namespace sunrise::state::account::inventory {
  6. /** The profile and character writebacks carry 704 and 352 new-item bits. */
  7. using ProfileNewItems = std::array<std::uint32_t, 22>;
  8. using CharacterNewItems = std::array<std::uint32_t, 11>;
  9. /** A delivered acquisition can temporarily place an item outside its usual row. */
  10. struct PresentedItemRow {
  11. std::uint64_t instanceSoid{};
  12. std::uint16_t inventoryRow{};
  13. };
  14. [[nodiscard]] bool record_profile_seen(const ProfileNewItems& newItems) noexcept;
  15. [[nodiscard]] bool
  16. record_character_seen(const CharacterNewItems& newItems,
  17. std::span<const PresentedItemRow> presentation = {}) noexcept;
  18. /** A clear bit means the item at that published row has been seen. */
  19. template <std::size_t N>
  20. [[nodiscard]] bool seen_at(const std::array<std::uint32_t, N>& bits, std::size_t row) noexcept {
  21. constexpr std::size_t kWordBits = 32;
  22. return row < N * kWordBits && (bits[row / kWordBits] & (1U << (row % kWordBits))) == 0;
  23. }
  24. } // namespace sunrise::state::account::inventory