reward_build_data_runtime.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include "../runtime.h"
  2. #include "../runtime/persistence/publication_transaction.h"
  3. #include "reward_catalog.h"
  4. namespace sunrise::state::build_data {
  5. /** @return True when the reward pools and item wrappers are published. */
  6. bool reward_definitions_ready() noexcept {
  7. return rewards::ready();
  8. }
  9. /** Publishes the complete reward graph in one step. */
  10. bool publish_reward_definitions(rewards::View definitions) noexcept {
  11. runtime::persistence::Transaction transaction;
  12. return transaction.active()
  13. && transaction.finish(rewards::replace(definitions), rewards::clear);
  14. }
  15. /** Checks a reward graph against the catalog's publication rules. */
  16. bool valid_reward_definitions(rewards::View definitions) noexcept {
  17. return rewards::valid(definitions);
  18. }
  19. /** Reads one item's reward row. */
  20. bool find_reward_item(std::uint16_t itemIndex, rewards::Item& item) noexcept {
  21. return rewards::find_item(itemIndex, item);
  22. }
  23. /** Lends the complete reward graph to one callback under the catalog's read lock. */
  24. bool read_reward_definitions(void* context,
  25. bool (*consume)(void*, rewards::View) noexcept) noexcept {
  26. return rewards::read(context, consume);
  27. }
  28. } // namespace sunrise::state::build_data