gameplay_runtime.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "gameplay_runtime.h"
  2. #include "actor_command_policy.h"
  3. #include "association/association_host.h"
  4. #include "dtls/dtls_host.h"
  5. #include "endpoint/gameplay_endpoint.h"
  6. #include "group/group_host.h"
  7. #include "peer/peer_transport.h"
  8. #include "squad_entity_retirement.h"
  9. namespace sunrise::server::gameplay {
  10. /** Binds the gameplay endpoint for the configured topology. */
  11. bool initialize() noexcept {
  12. squad_entity_retirement::reset();
  13. association::reset();
  14. dtls::reset();
  15. peer::reset();
  16. group::reset();
  17. actor_command_policy::initialize();
  18. if (endpoint::initialize()) {
  19. return true;
  20. }
  21. actor_command_policy::shutdown();
  22. squad_entity_retirement::reset();
  23. return false;
  24. }
  25. /** Runs one bounded gameplay slice. */
  26. void service(std::uint64_t now) noexcept {
  27. endpoint::service(now);
  28. // The retries run before the send so anything they queue leaves in this slice.
  29. group::service(now);
  30. actor_command_policy::service(now);
  31. peer::service(now);
  32. }
  33. /** Stops the endpoint and clears every association and peer. */
  34. void shutdown() noexcept {
  35. endpoint::shutdown();
  36. actor_command_policy::shutdown();
  37. squad_entity_retirement::reset();
  38. peer::reset();
  39. group::reset();
  40. dtls::reset();
  41. association::reset();
  42. }
  43. } // namespace sunrise::server::gameplay