mission_retirement.h 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <cstdint>
  3. #include <span>
  4. namespace sunrise::client::hooks::mission_retirement {
  5. struct RequestId {
  6. std::uint64_t session{}, binding{}, revision{};
  7. bool operator==(const RequestId&) const = default;
  8. };
  9. enum class Status { absent, baselinePending, retiring, complete, failed, failedRetiring };
  10. struct Progress {
  11. Status value{Status::absent};
  12. std::int32_t sourceRegion{-1};
  13. std::uintptr_t owner{};
  14. void observe(std::int32_t region, std::uintptr_t observedOwner,
  15. std::uint32_t groupCount, std::size_t matchingKeys) noexcept {
  16. if (region != sourceRegion || !observedOwner || !groupCount || groupCount > 128) return;
  17. if (value == Status::baselinePending && matchingKeys > 0) {
  18. owner = observedOwner; value = Status::retiring;
  19. } else if (value == Status::retiring && owner == observedOwner && matchingKeys == 0) {
  20. value = Status::complete;
  21. }
  22. }
  23. };
  24. // Keys remain at their wire ordinals. The client observes them before and after removal.
  25. Status prepare(RequestId id, std::int32_t sourceRegion,
  26. std::span<const std::uint32_t> keys) noexcept;
  27. Status status(RequestId id) noexcept;
  28. // Called only from the existing native frame observation point; never changes game memory.
  29. void poll(std::int32_t currentRegion) noexcept;
  30. }