entity_position_profile_provider.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "entity_position_profile_provider.h"
  2. #include <string_view>
  3. #include "../../state/activity/runtime.h"
  4. #include "../../state/gameplay/external/entity_position_profiles.h"
  5. namespace sunrise::server::gameplay {
  6. /**
  7. * The admitted activity selects immutable package bounds without reading the client runtime.
  8. * @param context Unused callback context.
  9. * @param source Admitted source generation.
  10. * @param cell Native entity cell index.
  11. * @param output Receives the selector grammar and any validated widths.
  12. * @return True; an unknown profile still permits the raw-position selector arm.
  13. */
  14. bool resolve_entity_position_profile(
  15. const void*,
  16. const state::gameplay::entity_identity::Source& source,
  17. std::uint16_t cell,
  18. middleware::gameplay::external::PositionProfile& output) noexcept {
  19. output = {};
  20. output.selectorPresent = true;
  21. state::activity::SessionBinding binding{};
  22. if (!state::activity::snapshot_binding(source.activitySessionId, binding)
  23. || binding.createdRevision != source.activityRevision)
  24. return true;
  25. const auto& destination = binding.destination;
  26. if (destination.packageNameLength == 0
  27. || destination.packageNameLength > destination.packageName.size())
  28. return true;
  29. const std::string_view activity(reinterpret_cast<const char*>(destination.packageName.data()),
  30. destination.packageNameLength);
  31. output.hasWidths =
  32. state::gameplay::entity_position_profiles::lookup(activity, cell, output.axisBits);
  33. return true;
  34. }
  35. } // namespace sunrise::server::gameplay