Files
ReSkate/Extension/Throwdowns/throwdown_lab.h
T
2026-10-02 14:40:41 -05:00

86 lines
5.9 KiB
C++

#pragma once
#include <array>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
// Research tools for multiplayer throwdowns (analysis/throwdowns-native-mp.md §8):
// inject the events that put a player id with no native player into the local
// throwdown (AddAIParticipantToCommunityEvent), spawn a queue hosted by such an id
// (DebugSpawnThrowdownWithParams), start or destroy it, and log every participant
// change in both realms. Console: `throwdown <verb> ...`.
namespace dingosdk::multiplayer {
// Called once by initialize_native_throwdowns after its own hooks are installed.
void initialize_throwdown_lab(std::uintptr_t base) noexcept;
// Called after every authored expression (vm = the expression that just ran); sends
// queued events from the client realm and reads results off server graphs.
void pump_throwdown_lab(std::uintptr_t vm) noexcept;
// Called by the SendNetworkedEvent hook for every event the local client sends.
void observe_throwdown_send(std::uint32_t hash, std::uintptr_t type, std::uintptr_t payload) noexcept;
// True for ids the lab put into a throwdown; the UI player lookups answer them with
// the local player's record so rows and host lookups resolve.
bool throwdown_lab_player(std::uint32_t player_id) noexcept;
// `skater` is the local skater's position when known (spawn without a recorded placement).
std::string throwdown_lab_command(std::string_view arguments, std::optional<std::array<float, 3>> skater);
// Coop challenge research (analysis/coop-challenges-mp.md): `challenge virtual <n>` gives the
// next challenge start n virtual participants and makes it coop; `challenge attempt [id]`
// replays the local player's last finished attempt as that player. Console: `challenge ...`.
std::string challenge_lab_command(std::string_view arguments);
// Injection for the throwdown relay (throwdown_relay.cpp); game thread, in a world.
// Each queues one event that the local client sends to its own server from the next
// client-realm expression. False when the event types cannot be found.
// Finds the event types once per process by a heap scan on a worker thread: false until it
// has, true from then on. Poll it; it never blocks.
bool prepare_throwdown_injection() noexcept;
// DebugSpawnThrowdownWithParams hosted by `host`; the queue's MMID comes back through
// throwdown_relay_spawned(token, ...).
bool queue_throwdown_spawn(std::uint64_t token, std::uint32_t host, const std::string &series,
const std::vector<std::uint8_t> &placement, const std::vector<std::uint8_t> &settings) noexcept;
bool queue_throwdown_add(std::uint32_t player, const std::string &series, std::uint32_t mmid) noexcept;
bool queue_throwdown_remove(std::uint32_t player) noexcept; // RemoveParticipantFromCommunityEvent as `player`
bool queue_throwdown_start(const std::string &series, std::uint32_t mmid) noexcept;
bool queue_throwdown_destroy(std::uint32_t mmid) noexcept;
// `player`'s total in the running throwdown: its leaderboard row and the server's own
// score list. False until the local client has opened this throwdown's leaderboard.
bool queue_throwdown_score(std::uint32_t player, std::int32_t score) noexcept;
// One leaderboard write as `player`'s own client made it: board index in the event's
// leaderboard manager, added or set. False until this throwdown's leaderboard exists.
bool queue_throwdown_row(std::uint32_t player, std::uint8_t board, bool add, std::int32_t value) noexcept;
// RequestTurnEnd as `player` (ends that player's turn if it is theirs). False while the
// running event's handle is unknown.
bool queue_throwdown_end_turn(std::uint32_t player) noexcept;
// ForceDestroyCurrentEvent as `player`: ends the event on the local server that `player` is in
// (one the local player quit keeps running here with only relayed players otherwise).
bool queue_throwdown_destroy_event(std::uint32_t player) noexcept;
// Coop challenges (throwdown_relay.cpp; analysis/coop-challenges-mp.md). Game thread.
// The local client's own solo start request for challenge `id` of `series`, as its Start button
// sends it; the relay's StartChallenge plan makes it the linked coop copy.
bool queue_challenge_start(const std::string &series, const std::string &id, bool contest) noexcept;
// AttemptFinishedForCriteria as `player`, with its owner's arrays bit-exact.
bool queue_challenge_attempt(std::uint32_t player, std::vector<std::uint8_t> criteria,
std::vector<std::uint8_t> indexes) noexcept;
// SlamObjectHitNetworked {identifier, the local copy's EventHandle} as `player`. False while the
// local copy's handle is unknown (it is read when the local client finishes the onboarding).
bool queue_challenge_slam(std::uint32_t player, std::int32_t identifier) noexcept;
// LeaveInProgressRequested as `player`: the local copy lets that player go.
bool queue_challenge_leave(std::uint32_t player) noexcept;
// Party beacons: MoveSpawnedEntityForPlayer {location, BEACON} as `player` puts that player's
// beacon there (replacing one already standing); DespawnEntityForPlayer removes it. False while
// the event types are not found yet (they are looked for in the background: call again).
bool queue_beacon_move(std::uint32_t player, const std::array<float, 16> &location) noexcept;
bool queue_beacon_remove(std::uint32_t player) noexcept;
// The local coop celebration's spots since the last call: PlayerLocation then Player2..4, each the
// 12 floats of the event's Transform, as CoopChallengeCelebrationRuleData.Activate built them.
struct ChallengeCelebration {
std::array<std::array<float, 12>, 4> spots{};
std::uint32_t count{};
};
std::optional<ChallengeCelebration> take_challenge_celebration() noexcept;
// Skate_SubmitAttempt as `player` (their client's own verdict and trick record, bit-exact).
// False while the running event's handle is unknown.
bool queue_throwdown_attempt(std::uint32_t player, bool landed, const std::array<std::uint8_t, 28> &trick) noexcept;
}