Complete PAPER declarations
PAPER provider API 2.0 is five headers in PAPER's include/PAPER/: the shared Abi.h, Discovery.h and the header-only Client.h helper, and one header per interface, Provider.h and PhysicalReload.h. They are reproduced below exactly as published. See the API index and the runtime contract before using them.
Complete public declarations: PAPER/Abi.h
PAPER/Abi.h
#pragma once
#include <cstddef>
#include <cstdint>
#include <type_traits>
#define PAPER_CALL __cdecl
// PAPER's shared ABI vocabulary. Each interface header carries its own
// kMajor and kMinor; records and tables belong to their interface headers.
#pragma pack(push, 8)
namespace paper::api
{
// Layout version of every size/version-tagged record. Interface versions
// are separate and negotiated through discovery.
inline constexpr std::uint32_t kRecordVersion = 1;
enum class Status : std::uint32_t
{
Ok = 0,
InvalidArgument = 1,
UnsupportedVersion = 2,
NotReady = 3,
CapacityReached = 4,
UnknownOwner = 5,
PermissionDenied = 6,
NotFound = 7,
WrongThread = 8,
OwnerConflict = 9,
InvalidSize = 10,
StaleSnapshot = 11,
OutOfRange = 12,
// Discovery.
UnknownInterface = 100,
UnsupportedMajor = 101,
UnsupportedMinor = 102,
TableTooSmall = 103,
InternalError = 104,
};
// Issued by the Provider interface's registerConsumer; every other
// interface takes the same token.
using OwnerToken = std::uint64_t;
// Interface IDs are permanent and never reused.
enum class InterfaceId : std::uint32_t
{
Provider = 1,
PhysicalReload = 2,
};
static_assert(sizeof(void*) == 8, "PAPER requires a 64-bit consumer");
static_assert(sizeof(Status) == 4 && sizeof(InterfaceId) == 4);
}
#pragma pack(pop)
Complete public declarations: PAPER/Discovery.h
PAPER/Discovery.h
#pragma once
#include "Abi.h"
// Resolve kQueryExportName from PAPER.dll and ask for an interface by ID,
// exact major, minimum minor and minimum table size. A major this PAPER does
// not serve returns UnsupportedMajor and no table; PAPER logs the refusal once.
// The pre-2.0 exports (PAPERAPI_GetProviderApi,
// PAPERAPI_GetProviderDescriptorV1 and PAPERAPI_QueryPhysicalReloadV1/V2/V3)
// only refuse outdated consumers; their names are never reused.
#pragma pack(push, 8)
namespace paper::api
{
struct InterfaceDescriptorV1
{
std::uint32_t size{ sizeof(InterfaceDescriptorV1) };
InterfaceId interfaceId{};
std::uint32_t major{};
std::uint32_t minor{};
std::uint32_t tableByteSize{};
// Owner tokens come from the Provider interface; a consumer checks it
// negotiated at least this Provider version.
std::uint32_t requiredProviderMajor{};
std::uint32_t requiredProviderMinor{};
std::uint32_t reserved{};
const void* table{};
};
// Any thread. The descriptor and table stay valid for the process lifetime.
using QueryInterfaceV1 = Status(PAPER_CALL*)(InterfaceId interfaceId,
std::uint32_t exactMajor, std::uint32_t minimumMinor,
std::uint32_t minimumTableBytes,
const InterfaceDescriptorV1** outDescriptor) noexcept;
inline constexpr char kQueryExportName[] = "PAPERAPI_QueryInterfaceV1";
static_assert(sizeof(InterfaceDescriptorV1) == 40);
}
#pragma pack(pop)
Complete public declarations: PAPER/Client.h
PAPER/Client.h
#pragma once
#include "Discovery.h"
#include "Provider.h"
#include <cstring>
namespace paper::api
{
// Consumer-side helper only; it is not part of the DLL ABI. Pass the
// kQueryExportName export resolved from PAPER.dll.
class Client
{
QueryInterfaceV1 _query{};
const provider::Api* _provider{};
OwnerToken _owner{};
std::uint32_t _granted{};
public:
Client() = default;
Client(const Client&) = delete;
Client& operator=(const Client&) = delete;
// Game thread, once PAPER is ready (NotReady before). capabilities is a
// ConsumerCapability mask; PAPER grants only the bits it knows. One
// owner per mod name; a name already registered gets OwnerConflict.
Status connect(QueryInterfaceV1 query, const char* name, std::uint32_t capabilities) noexcept
{
if (_owner) return Status::OwnerConflict;
if (!query || !name) return Status::InvalidArgument;
ConsumerRegistration registration{};
std::size_t length = 0;
while (length < sizeof(registration.modName) && name[length]) ++length;
if (!length || length == sizeof(registration.modName)) return Status::InvalidArgument;
std::memcpy(registration.modName, name, length);
registration.requestedCapabilities = capabilities;
const InterfaceDescriptorV1* descriptor{};
auto status = query(provider::kInterfaceId, provider::kMajor, provider::kMinor, sizeof(provider::Api), &descriptor);
if (status != Status::Ok) return status;
if (!descriptor || descriptor->size != sizeof(InterfaceDescriptorV1) ||
descriptor->interfaceId != provider::kInterfaceId || descriptor->major != provider::kMajor ||
descriptor->tableByteSize < sizeof(provider::Api) || !descriptor->table) return Status::InvalidSize;
const auto* api = static_cast<const provider::Api*>(descriptor->table);
ConsumerHandle handle{};
status = api->registerConsumer(®istration, &handle);
if (status != Status::Ok) return status;
_query = query;
_provider = api;
_owner = handle.ownerToken;
_granted = handle.grantedCapabilities;
return Status::Ok;
}
// Any further interface, for example physical_reload::Api. Its calls
// take owner().
template <class Table>
Status acquire(const Table*& output) const noexcept
{
output = nullptr;
if (!_owner || !_query) return Status::UnknownOwner;
const InterfaceDescriptorV1* descriptor{};
const auto status = _query(Table::interfaceId, Table::majorVersion, Table::minorVersion, sizeof(Table), &descriptor);
if (status != Status::Ok) return status;
if (!descriptor || descriptor->size != sizeof(InterfaceDescriptorV1) ||
descriptor->interfaceId != Table::interfaceId || descriptor->major != Table::majorVersion ||
descriptor->minor < Table::minorVersion || descriptor->tableByteSize < sizeof(Table) ||
descriptor->requiredProviderMajor != provider::kMajor ||
descriptor->requiredProviderMinor > provider::kMinor || !descriptor->table) return Status::InvalidSize;
output = static_cast<const Table*>(descriptor->table);
return Status::Ok;
}
// Game thread. Ends every lease, authority request and callback the
// owner holds.
Status close() noexcept
{
if (!_owner) return Status::Ok;
const auto status = _provider->unregisterConsumer(_owner);
if (status == Status::Ok || status == Status::UnknownOwner) {
_owner = 0;
_granted = 0;
_provider = nullptr;
_query = nullptr;
}
return status;
}
[[nodiscard]] OwnerToken owner() const noexcept { return _owner; }
[[nodiscard]] std::uint32_t grantedCapabilities() const noexcept { return _granted; }
[[nodiscard]] const provider::Api* providerApi() const noexcept { return _provider; }
};
}
Complete public declarations: PAPER/Provider.h
PAPER/Provider.h
#pragma once
#include "Abi.h"
// PAPER's main interface: consumer registration, runtime and configuration
// state, captured native transforms and hand poses, native animation
// authority, frame events and the native pose pipeline.
// Records are value copies; no engine pointer crosses this boundary.
#pragma pack(push, 8)
namespace paper::api
{
inline constexpr std::uint32_t kMaxConsumers = 16;
inline constexpr std::uint32_t kMaxCallbacks = 16;
inline constexpr std::uint32_t kMaxCapturedTransforms = 192;
inline constexpr std::uint32_t kFingerTransformCount = 15;
inline constexpr std::uint32_t kTransformNameCapacity = 64;
inline constexpr std::uint32_t kMaxAuthorityLeaseFrames = 1200;
// Requested at registration; granted capabilities gate every owner-scoped
// call. Bits are local to this interface major. Bits 5 to 9 and 11 to 14
// are retired (reload observation, animation evidence, reload stages,
// weapon motion and development capture) and are never reused.
enum class ConsumerCapability : std::uint32_t
{
None = 0,
RuntimeState = 1u << 0,
CapturedTransforms = 1u << 1,
NativeHandPose = 1u << 2,
AnimationAuthority = 1u << 3,
FrameCallbacks = 1u << 4,
NativePosePipeline = 1u << 10,
All = (1u << 0) | (1u << 1) | (1u << 2) | (1u << 3) | (1u << 4) |
(1u << 10),
};
enum class NativeAnimationAuthorityFlag : std::uint32_t
{
None = 0,
Arms = 1u << 0,
Hands = 1u << 1,
Weapon = 1u << 2,
ReloadPose = (1u << 0) | (1u << 1) | (1u << 2),
};
enum class RuntimeStatusFlag : std::uint32_t
{
None = 0,
ProviderReady = 1u << 0,
RockConnected = 1u << 1,
RockSkeletonReady = 1u << 2,
HookInstalled = 1u << 3,
RuntimeEnabled = 1u << 4,
CaptureValid = 1u << 5,
ReloadEventActive = 1u << 6,
ManualCycleActive = 1u << 7,
HookInstallFailed = 1u << 8,
ThreadMismatch = 1u << 9,
CaptureFault = 1u << 10,
};
enum class Hand : std::uint32_t
{
Right = 0,
Left = 1,
};
enum class NativePoseMode : std::uint32_t
{
Inactive = 0,
FullReload = 1,
PartialReload = 2,
ManualCycle = 3,
ConsumerAuthority = 4,
};
enum class NativePoseCompatibilityReason : std::uint32_t
{
None = 0,
HandlingStateUnavailable = 1,
LeftFiringHand = 2,
PartCarry = 3,
WeaponUnavailable = 4,
WeaponIdentityChanged = 5,
AnimationRequestResetRequired = 6,
};
enum class NativePoseApplicationResult : std::uint32_t
{
Inactive = 0,
WaitingForCapture = 1,
Applied = 2,
CompatibilityRejected = 3,
ApplyFailed = 4,
RuntimeUnavailable = 5,
};
enum class NativePoseFrameFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
AuthorityRequested = 1u << 1,
RuntimeOperational = 1u << 2,
CapturePrepared = 1u << 3,
BeforeRockApplied = 1u << 4,
AfterRockApplied = 1u << 5,
FullPose = 1u << 6,
WeaponFixedHands = 1u << 7,
PartialReload = 1u << 8,
ManualCycle = 1u << 9,
CompatibilityRejected = 1u << 10,
ApplicationFailed = 1u << 11,
RockWeaponWorldValid = 1u << 12,
NativeWeaponBaselineWorldValid = 1u << 13,
ResolvedWeaponWorldValid = 1u << 14,
PresentedReadbackAvailable = 1u << 15,
};
enum class NativeHandRole : std::uint32_t
{
Primary = 0,
Support = 1,
};
enum class NativeHandTargetMode : std::uint32_t
{
None = 0,
LiveGripDelta = 1,
NativeWeaponRelative = 2,
};
enum class NativeHandSolutionFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
NativeHandInWeaponValid = 1u << 1,
NativeBaselineHandInWeaponValid = 1u << 2,
RockBaselineHandInWeaponValid = 1u << 3,
ResolvedTargetInWeaponValid = 1u << 4,
ResolvedTargetWorldValid = 1u << 5,
PresentedHandWorldValid = 1u << 6,
NativeFingerLocalsValid = 1u << 7,
PresentedFingerLocalsValid = 1u << 8,
MotionGateApplicable = 1u << 9,
MotionQualified = 1u << 10,
TargetPublished = 1u << 11,
TargetSuppressed = 1u << 12,
ResidualValid = 1u << 13,
PresentedPoseCoherent = 1u << 14,
};
// Values 4 to 10 are retired (weapon motion and manipulation events) and
// are never reused.
enum class EventKind : std::uint32_t
{
FrameComplete = 1,
RuntimeReset = 2,
ConfigReloaded = 3,
// Final native-pose readback is published. FrameComplete remains the
// control/lease boundary; this observation does not advance leases.
PresentationComplete = 11,
};
struct Transform
{
float rotate[3][3]{};
float translate[3]{};
float scale{ 1.0f };
};
struct ConsumerRegistration
{
std::uint32_t size{ sizeof(ConsumerRegistration) };
std::uint32_t version{ kRecordVersion };
char modName[64]{};
std::uint32_t requestedCapabilities{ 0 };
std::uint32_t reserved[7]{};
};
struct ConsumerHandle
{
std::uint32_t size{ sizeof(ConsumerHandle) };
std::uint32_t version{ kRecordVersion };
std::uint64_t ownerToken{ 0 };
std::uint32_t grantedCapabilities{ 0 };
std::uint32_t providerGeneration{ 0 };
std::uint32_t reserved[6]{};
};
struct AuthorityRequest
{
std::uint32_t size{ sizeof(AuthorityRequest) };
std::uint32_t version{ kRecordVersion };
std::uint32_t flags{ 0 };
// Zero is persistent until clear/unregister. Non-zero requests expire
// after this many Paper frame callbacks.
std::uint32_t leaseFrames{ 0 };
std::uint32_t reserved[8]{};
};
struct ConfigState
{
std::uint32_t size{ sizeof(ConfigState) };
std::uint32_t version{ kRecordVersion };
std::uint32_t enabled{ 0 };
std::uint32_t nativeReloadAuthorityEnabled{ 0 };
std::uint32_t partialReloadAuthorityEnabled{ 0 };
std::int32_t logLevel{ 0 };
std::uint64_t revision{ 0 };
std::uint32_t reserved[4]{};
};
struct RuntimeState
{
std::uint32_t size{ sizeof(RuntimeState) };
std::uint32_t version{ kRecordVersion };
std::uint32_t statusFlags{ 0 };
std::uint32_t activeAuthorityFlags{ 0 };
std::uint32_t localAuthorityFlags{ 0 };
std::uint32_t consumerAuthorityFlags{ 0 };
std::uint32_t capturedTransformCount{ 0 };
std::uint32_t weaponFormId{ 0 };
std::uint64_t captureSequence{ 0 };
std::uint64_t reloadStartSequence{ 0 };
std::uint64_t reloadEndSequence{ 0 };
std::uint64_t frameIndex{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t rockProviderGeneration{ 0 };
std::uint32_t paperProviderGeneration{ 0 };
std::uint32_t reserved[8]{};
};
struct CapturedTransform
{
std::uint32_t size{ sizeof(CapturedTransform) };
std::uint32_t version{ kRecordVersion };
char name[kTransformNameCapacity]{};
Transform local{};
std::uint32_t authorityFlags{ 0 };
std::int32_t sourceIndex{ -1 };
std::int32_t destinationIndex{ -1 };
std::uint32_t reserved[4]{};
};
struct NativeHandPose
{
std::uint32_t size{ sizeof(NativeHandPose) };
std::uint32_t version{ kRecordVersion };
Hand hand{ Hand::Right };
std::uint16_t fingerLocalTransformMask{ 0 };
std::uint16_t reserved0{ 0 };
Transform handInWeapon{};
Transform fingerLocalTransforms[
kFingerTransformCount]{};
std::uint64_t captureSequence{ 0 };
std::uint32_t reserved[8]{};
};
/*
* Native-pose pipeline records are observational. They describe PAPER's
* native animation decision and ROCK's final presented pose for the same
* completed frame; they do not grant pose-write or IK authority.
*/
struct NativePoseFrameState
{
std::uint32_t size{ sizeof(NativePoseFrameState) };
std::uint32_t version{ kRecordVersion };
std::uint32_t flags{ 0 };
NativePoseMode mode{ NativePoseMode::Inactive };
NativePoseCompatibilityReason compatibilityReason{
NativePoseCompatibilityReason::None
};
NativePoseApplicationResult applicationResult{
NativePoseApplicationResult::Inactive
};
std::uint32_t activeAuthorityFlags{ 0 };
std::uint32_t localAuthorityFlags{ 0 };
std::uint32_t consumerAuthorityFlags{ 0 };
std::uint32_t weaponFormId{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint64_t snapshotSequence{ 0 };
std::uint64_t frameIndex{ 0 };
std::uint64_t captureSequence{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t rockProviderGeneration{ 0 };
std::uint32_t paperProviderGeneration{ 0 };
Transform rockWeaponWorld{};
Transform nativeWeaponBaselineWorld{};
Transform resolvedWeaponWorld{};
std::uint32_t reserved[5]{};
};
struct NativeHandSolution
{
std::uint32_t size{ sizeof(NativeHandSolution) };
std::uint32_t version{ kRecordVersion };
Hand hand{ Hand::Right };
std::uint32_t flags{ 0 };
NativeHandRole role{ NativeHandRole::Primary };
NativeHandTargetMode targetMode{
NativeHandTargetMode::None
};
std::uint16_t nativeFingerLocalTransformMask{ 0 };
std::uint16_t presentedFingerLocalTransformMask{ 0 };
std::uint32_t reserved0{ 0 };
std::uint64_t snapshotSequence{ 0 };
std::uint64_t frameIndex{ 0 };
std::uint64_t captureSequence{ 0 };
std::uint64_t presentationSequence{ 0 };
Transform nativeHandInWeapon{};
Transform nativeBaselineHandInWeapon{};
Transform rockBaselineHandInWeapon{};
Transform resolvedTargetInWeapon{};
Transform resolvedTargetWorld{};
Transform presentedHandWorld{};
Transform nativeFingerLocalTransforms[
kFingerTransformCount]{};
Transform presentedFingerLocalTransforms[
kFingerTransformCount]{};
float motionTranslationGameUnits{ 0.0f };
float motionRotationDegrees{ 0.0f };
float residualTranslationGameUnits{ 0.0f };
float residualRotationDegrees{ 0.0f };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t rockProviderGeneration{ 0 };
std::uint32_t paperProviderGeneration{ 0 };
std::uint32_t reserved[8]{};
};
struct Event
{
std::uint32_t size{ sizeof(Event) };
std::uint32_t version{ kRecordVersion };
EventKind kind{ EventKind::FrameComplete };
std::uint32_t reserved0{ 0 };
RuntimeState runtime{};
};
// Game thread, inside PAPER's frame. eventData is borrowed for the call.
using EventCallback =
void(PAPER_CALL*)(const Event* eventData, void* userData);
static_assert(sizeof(Transform) == 52);
static_assert(alignof(Transform) == 4);
static_assert(std::is_standard_layout_v<Transform>);
static_assert(std::is_trivially_copyable_v<Transform>);
static_assert(sizeof(ConsumerRegistration) == 104);
static_assert(alignof(ConsumerRegistration) == 4);
static_assert(std::is_standard_layout_v<ConsumerRegistration>);
static_assert(std::is_trivially_copyable_v<ConsumerRegistration>);
static_assert(sizeof(ConsumerHandle) == 48);
static_assert(alignof(ConsumerHandle) == 8);
static_assert(std::is_standard_layout_v<ConsumerHandle>);
static_assert(std::is_trivially_copyable_v<ConsumerHandle>);
static_assert(sizeof(AuthorityRequest) == 48);
static_assert(alignof(AuthorityRequest) == 4);
static_assert(std::is_standard_layout_v<AuthorityRequest>);
static_assert(std::is_trivially_copyable_v<AuthorityRequest>);
static_assert(sizeof(ConfigState) == 48);
static_assert(alignof(ConfigState) == 8);
static_assert(std::is_standard_layout_v<ConfigState>);
static_assert(std::is_trivially_copyable_v<ConfigState>);
static_assert(sizeof(RuntimeState) == 120);
static_assert(alignof(RuntimeState) == 8);
static_assert(std::is_standard_layout_v<RuntimeState>);
static_assert(std::is_trivially_copyable_v<RuntimeState>);
static_assert(sizeof(CapturedTransform) == 152);
static_assert(alignof(CapturedTransform) == 4);
static_assert(std::is_standard_layout_v<CapturedTransform>);
static_assert(std::is_trivially_copyable_v<CapturedTransform>);
static_assert(sizeof(NativeHandPose) == 888);
static_assert(alignof(NativeHandPose) == 8);
static_assert(std::is_standard_layout_v<NativeHandPose>);
static_assert(std::is_trivially_copyable_v<NativeHandPose>);
static_assert(sizeof(NativePoseFrameState) == 264);
static_assert(alignof(NativePoseFrameState) == 8);
static_assert(std::is_standard_layout_v<NativePoseFrameState>);
static_assert(std::is_trivially_copyable_v<NativePoseFrameState>);
static_assert(sizeof(NativeHandSolution) == 2000);
static_assert(alignof(NativeHandSolution) == 8);
static_assert(std::is_standard_layout_v<NativeHandSolution>);
static_assert(std::is_trivially_copyable_v<NativeHandSolution>);
static_assert(sizeof(Event) == 136);
static_assert(alignof(Event) == 8);
static_assert(std::is_standard_layout_v<Event>);
static_assert(std::is_trivially_copyable_v<Event>);
}
namespace paper::api::provider
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::Provider;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;
/*
* getModVersion and isReady run on any thread. Every other call is
* game-thread only and fails closed on a wrong thread or when ownerToken
* lacks the matching granted capability. Returned records are value
* copies; event pointers are valid only for the callback.
*/
struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;
// PAPER's own version string (for example "1.2.0"), valid for the
// process lifetime.
const char*(PAPER_CALL* getModVersion)();
bool(PAPER_CALL* isReady)();
bool(PAPER_CALL* getRuntimeState)(
OwnerToken ownerToken,
RuntimeState* outState);
bool(PAPER_CALL* getConfigState)(
OwnerToken ownerToken,
ConfigState* outState);
std::uint32_t(PAPER_CALL* getCapturedTransformCount)(
OwnerToken ownerToken);
std::uint32_t(PAPER_CALL* copyCapturedTransforms)(
OwnerToken ownerToken,
CapturedTransform* outTransforms,
std::uint32_t maxTransforms);
bool(PAPER_CALL* getNativeHandPose)(
OwnerToken ownerToken,
Hand hand,
NativeHandPose* outPose);
Status(PAPER_CALL* registerConsumer)(
const ConsumerRegistration* registration,
ConsumerHandle* outHandle);
Status(PAPER_CALL* unregisterConsumer)(
OwnerToken ownerToken);
std::uint32_t(PAPER_CALL* getGrantedCapabilities)(
OwnerToken ownerToken);
Status(PAPER_CALL* setAnimationAuthority)(
OwnerToken ownerToken,
const AuthorityRequest* request);
Status(PAPER_CALL* clearAnimationAuthority)(
OwnerToken ownerToken);
Status(PAPER_CALL* registerEventCallback)(
OwnerToken ownerToken,
EventCallback callback,
void* userData,
std::uint64_t* outCallbackToken);
Status(PAPER_CALL* unregisterEventCallback)(
OwnerToken ownerToken,
std::uint64_t callbackToken);
Status(PAPER_CALL* getNativePoseFrameState)(
OwnerToken ownerToken,
NativePoseFrameState* outState);
Status(PAPER_CALL* getNativeHandSolution)(
OwnerToken ownerToken,
Hand hand,
NativeHandSolution* outSolution);
};
static_assert(sizeof(Api) == 128);
static_assert(std::is_standard_layout_v<Api>);
static_assert(std::is_trivially_copyable_v<Api>);
}
#pragma pack(pop)
Complete public declarations: PAPER/PhysicalReload.h
PAPER/PhysicalReload.h
#pragma once
#include "Abi.h"
// Physical reload control: a consumer that drives a reload or manual cycle
// with its own hands takes the equipped weapon away from PAPER's native
// reload animation for a short, renewed lease.
#pragma pack(push, 8)
namespace paper::api::physical_reload
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::PhysicalReload;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;
inline constexpr std::uint32_t kMaxLeaseFrames = 120;
enum class Flag : std::uint32_t
{
// The consumer owns bolt cycling, chambering, casing ejection and
// their sounds; PAPER suppresses the native automatic cycle.
ManualCycle = 1u << 0,
};
inline constexpr std::uint32_t kKnownFlags = 1;
/*
* Binds the exact native equipped item (form, equipped data and
* instance). observedFrame is the ROCK frame the caller acted on and must
* be within one frame of PAPER's; the lease ends after observedFrame +
* leaseFrames (1..kMaxLeaseFrames), when the equipped item is replaced, on
* a world reset, or when the owner is revoked. Renew it every frame while
* physical control lasts. No PAPER animation snapshot or weapon-part
* readiness is required. Generation fields describe the caller.
*/
struct Request
{
std::uint32_t size{ sizeof(Request) };
std::uint32_t version{ kRecordVersion };
std::uint32_t weaponFormId{ 0 };
std::uint32_t leaseFrames{ 2 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint64_t observedFrame{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t rockProviderGeneration{ 0 };
std::uint32_t flags{ 0 };
};
// active 0: no live lease; every other field is zero.
struct State
{
std::uint32_t size{ sizeof(State) };
std::uint32_t version{ kRecordVersion };
std::uint32_t active{ 0 };
std::uint32_t weaponFormId{ 0 };
OwnerToken owner{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint64_t expiresAfterFrame{ 0 };
std::uint32_t flags{ 0 };
std::uint32_t reserved{ 0 };
};
// Every call runs on the game thread (PAPER's owner thread) and copies its
// arguments. Owner tokens come from the Provider interface.
struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;
// Needs the AnimationAuthority capability. OwnerConflict while another
// owner holds a live lease or any consumer holds animation authority;
// StaleSnapshot when the item or frame does not match; NotReady before
// PAPER is ready.
Status(PAPER_CALL* acquire)(OwnerToken owner, const Request* request) noexcept;
// Ends the caller's lease; OwnerConflict while another owner's lease
// is live.
Status(PAPER_CALL* clear)(OwnerToken owner) noexcept;
// Needs the RuntimeState capability.
Status(PAPER_CALL* read)(OwnerToken owner, State* output) noexcept;
};
static_assert(sizeof(Request) == 48 && alignof(Request) == 8);
static_assert(sizeof(State) == 48 && alignof(State) == 8);
static_assert(sizeof(Api) == 24);
}
#pragma pack(pop)