activity_arrival.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <cstdint>
  3. #include <string_view>
  4. #include "../../../../../state/activity/defaults/definition.h"
  5. #include "../../../../../state/activity/definition.h"
  6. #include "../../../../../state/activity/destination/definition.h"
  7. #include "../../../../../state/activity/membership/activity_membership_query.h"
  8. #include "../../../../../state/build_data/scenarios/definition.h"
  9. namespace sunrise::server::bap::encrypted::push::activity {
  10. /**
  11. * Finds the slice-set index a destination arrives in.
  12. * Order: authored override, the bubble the client named, the default destination's, then its first
  13. * live one. A fallback never crosses destinations; a foreign index loads wrong geometry silently.
  14. *
  15. * @param defaults Authored default destination and its numeric launch policy.
  16. * @param selection Destination the session committed, carrying any wire arrival hash or override.
  17. * @param name Destination package name.
  18. * @param layout Extracted layout for that name, or a zero-bubble layout when there is none.
  19. * @return The slice-set index to publish.
  20. */
  21. [[nodiscard]] std::uint16_t
  22. arrival_slice_set(const state::activity::defaults::DefaultDestination& defaults,
  23. const state::activity::destination::DestinationSelection& selection,
  24. std::string_view name,
  25. const state::build_data::scenarios::Definition& layout) noexcept;
  26. /** The region one session publishes, with the arrival slice set behind it. */
  27. struct EffectiveRegion final {
  28. /** Region index. The roster and the citizen advertisement both publish this value. */
  29. std::int32_t index{};
  30. /** The destination's own arrival slice set. The spawn override always names it. */
  31. std::uint16_t arrival{};
  32. /** True when the client reported the region, false when the arrival stood in. */
  33. bool reported{};
  34. };
  35. /**
  36. * Resolves the one region a session publishes.
  37. * The client's report wins. Before the first report the destination's arrival slice set stands in.
  38. * @param binding Exact joined activity-session generation.
  39. * @return The published region index, its source, and the destination's arrival slice set.
  40. */
  41. [[nodiscard]] EffectiveRegion
  42. effective_region(const state::activity::SessionBinding& binding) noexcept;
  43. /**
  44. * Resolves the region one prepared membership body publishes.
  45. * Staging runs before the commit, so committed State still names the region just left. The body
  46. * must name the delta's region or its advertisement fills the wrong record.
  47. * @param mutation Prepared membership operation, whose sparse input may carry a new region.
  48. * @param binding Exact joined activity-session generation used when the delta names no region.
  49. * @return The region this body publishes, its source, and the destination's arrival slice set.
  50. */
  51. [[nodiscard]] EffectiveRegion
  52. planned_region(const state::activity::membership::PendingMutation& mutation,
  53. const state::activity::SessionBinding& binding) noexcept;
  54. } // namespace sunrise::server::bap::encrypted::push::activity