Route cellular perception to its owner
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (postgres) (push) Failing after 53s
Foundation / checks (tsan) (push) Failing after 34s
Foundation / checks (network) (push) Failing after 3m0s
Foundation / checks (client) (push) Failing after 4m27s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

This commit is contained in:
dingo
2026-10-11 01:08:03 -04:00
parent 5419a579e8
commit 27778def2c
8 changed files with 124 additions and 16 deletions
+23 -6
View File
@@ -27,6 +27,7 @@ struct RegionSessionClient::Impl {
std::vector<network::PrimitiveLifeReceipt> primitive_life_receipts;
std::vector<network::PrimitiveLifeOutcome> primitive_life_outcomes;
std::optional<network::SnapshotAssembler> snapshots;
std::optional<network::CellularPerception> cellular_perception;
std::uint64_t snapshot_chunks{}, snapshot_bytes{};
std::optional<network::HandoffOffer> handoff; // v4: continue at another region.
std::optional<network::RegionAddress> redirect; // v4: the probe is owned elsewhere.
@@ -129,6 +130,11 @@ struct RegionSessionClient::Impl {
}
if (const auto* m = std::get_if<network::ActionOutcome>(&*decoded))
return keep(action_outcomes, *m);
if (const auto* m = std::get_if<network::CellularPerception>(&*decoded)) {
seen_tick(m->tick);
cellular_perception = *m;
return;
}
if (const auto* m = std::get_if<network::PrimitiveLifeReceipt>(&*decoded)) {
seen_tick(m->server_tick);
return keep(primitive_life_receipts, *m);
@@ -152,7 +158,8 @@ RegionSessionClient::connect(RegionSessionClientConfig config, Clock::time_point
if (config.protocol_version != network::session_protocol_version &&
config.protocol_version != network::session_protocol_v5 &&
config.protocol_version != network::session_protocol_v6 &&
config.protocol_version != network::session_protocol_v7)
config.protocol_version != network::session_protocol_v7 &&
config.protocol_version != network::session_protocol_v8)
return std::unexpected(network::quic::EndpointError::configuration);
auto endpoint = network::quic::Endpoint::connect(config.transport);
if (!endpoint)
@@ -257,7 +264,8 @@ bool RegionSessionClient::send_cellular_action(
std::uint64_t action_id, std::uint64_t tick, std::int16_t move_x, std::int16_t move_y,
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target) {
auto& m = *impl_;
return m.protocol_version == network::session_protocol_v7 &&
return (m.protocol_version == network::session_protocol_v7 ||
m.protocol_version == network::session_protocol_v8) &&
m.state == RegionSessionState::established && m.welcome && action_id != 0 && tick != 0 &&
m.send(network::CellularAction{m.welcome->session, m.welcome->epoch, action_id, tick,
move_x, move_y, intake_target.has_value(),
@@ -268,20 +276,23 @@ bool RegionSessionClient::send_cellular_action(
bool RegionSessionClient::query_action(std::uint64_t action_id) {
auto& m = *impl_;
return (m.protocol_version == network::session_protocol_version ||
m.protocol_version == network::session_protocol_v7) &&
m.protocol_version == network::session_protocol_v7 ||
m.protocol_version == network::session_protocol_v8) &&
m.state == RegionSessionState::established && m.send(network::ActionQuery{action_id});
}
bool RegionSessionClient::request_primitive_life(std::uint64_t request_id) {
auto& m = *impl_;
return m.protocol_version == network::session_protocol_v5 &&
return (m.protocol_version == network::session_protocol_v5 ||
m.protocol_version == network::session_protocol_v8) &&
m.state == RegionSessionState::established && m.welcome && request_id != 0 &&
m.send(network::PrimitiveLifeRequest{m.welcome->session, m.welcome->epoch, request_id});
}
bool RegionSessionClient::query_primitive_life(std::uint64_t request_id) {
auto& m = *impl_;
return m.protocol_version == network::session_protocol_v5 &&
return (m.protocol_version == network::session_protocol_v5 ||
m.protocol_version == network::session_protocol_v8) &&
m.state == RegionSessionState::established && request_id != 0 &&
m.send(network::PrimitiveLifeQuery{request_id});
}
@@ -317,7 +328,8 @@ std::uint64_t RegionSessionClient::server_tick() const noexcept {
bool RegionSessionClient::set_interest(const network::SessionInterest& interest) {
auto& m = *impl_;
return (m.protocol_version == network::session_protocol_version ||
m.protocol_version == network::session_protocol_v7) &&
m.protocol_version == network::session_protocol_v7 ||
m.protocol_version == network::session_protocol_v8) &&
m.state == RegionSessionState::established && m.send(interest);
}
@@ -326,6 +338,11 @@ const network::ReplicatedView* RegionSessionClient::view() const noexcept {
return snapshots ? snapshots->latest() : nullptr;
}
const std::optional<network::CellularPerception>&
RegionSessionClient::cellular_perception() const noexcept {
return impl_->cellular_perception;
}
std::expected<client::EnvironmentPresentation, client::ViewError>
RegionSessionClient::environment() const {
const auto& snapshots = impl_->snapshots;