Format M11 cellular code with clang-format 19
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (client) (push) Failing after 4m25s
Foundation / checks (network) (push) Failing after 3m2s
Foundation / checks (tsan) (push) Failing after 33s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 5m47s
Foundation / checks (postgres) (push) Canceled after 1m24s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (client) (push) Failing after 4m25s
Foundation / checks (network) (push) Failing after 3m2s
Foundation / checks (tsan) (push) Failing after 33s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 5m47s
Foundation / checks (postgres) (push) Canceled after 1m24s
This commit is contained in:
@@ -30,8 +30,7 @@ bool all_zero(std::span<const std::uint8_t> bytes) {
|
||||
bool valid_header(const CellularBatchHeader& h, std::size_t ticks) {
|
||||
return h.world != 0 && h.region != 0 && h.frame != 0 && !all_zero(h.predecessor) &&
|
||||
!all_zero(h.predecessor_digest) && h.end_tick > h.begin_tick &&
|
||||
h.end_tick - h.begin_tick == ticks && ticks > 0 &&
|
||||
ticks <= max_cellular_batch_ticks;
|
||||
h.end_tick - h.begin_tick == ticks && ticks > 0 && ticks <= max_cellular_batch_ticks;
|
||||
}
|
||||
bool valid_intent(const CellularLifeIntent& life) {
|
||||
const auto& step = life.intent;
|
||||
@@ -48,16 +47,14 @@ bool valid_ticks(std::span<const CellularTickIntents> ticks) {
|
||||
return false;
|
||||
for (std::size_t i = 0; i < tick.lives.size(); ++i) {
|
||||
const auto& life = tick.lives[i];
|
||||
if (!valid_intent(life) ||
|
||||
(i > 0 && tick.lives[i - 1].life_id >= life.life_id))
|
||||
if (!valid_intent(life) || (i > 0 && tick.lives[i - 1].life_id >= life.life_id))
|
||||
return false;
|
||||
}
|
||||
for (std::size_t i = 0; i < tick.births.size(); ++i) {
|
||||
const auto& birth = tick.births[i];
|
||||
if (all_zero(birth.account) || birth.request == 0 || birth.generation == 0 ||
|
||||
birth.identity == 0 ||
|
||||
(i > 0 && std::tie(tick.births[i - 1].account,
|
||||
tick.births[i - 1].request) >=
|
||||
(i > 0 && std::tie(tick.births[i - 1].account, tick.births[i - 1].request) >=
|
||||
std::tie(birth.account, birth.request)))
|
||||
return false;
|
||||
if (!identities.insert(birth.identity).second || !accounts.insert(birth.account).second)
|
||||
@@ -73,22 +70,19 @@ bool valid_action_input(const CellularActionRecord& action, std::uint64_t begin_
|
||||
std::uint64_t end_tick) {
|
||||
const auto input = std::span<const std::uint8_t>{action.input};
|
||||
const auto tick = action_tick(action);
|
||||
const auto move_x = std::bit_cast<std::int16_t>(
|
||||
static_cast<std::uint16_t>(get(input, 8, 2)));
|
||||
const auto move_y = std::bit_cast<std::int16_t>(
|
||||
static_cast<std::uint16_t>(get(input, 10, 2)));
|
||||
const auto move_x = std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(input, 8, 2)));
|
||||
const auto move_y = std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(input, 10, 2)));
|
||||
return !all_zero(action.account) && action.action_id != 0 && tick > begin_tick &&
|
||||
tick <= end_tick && move_x >= -movement_limit && move_x <= movement_limit &&
|
||||
move_y >= -movement_limit && move_y <= movement_limit && input[12] <= 1 &&
|
||||
all_zero(input.subspan(13, 3)) &&
|
||||
(input[12] == 1 || all_zero(input.subspan(16, 8)));
|
||||
all_zero(input.subspan(13, 3)) && (input[12] == 1 || all_zero(input.subspan(16, 8)));
|
||||
}
|
||||
bool action_less(const CellularActionRecord& a, const CellularActionRecord& b) {
|
||||
const auto a_tick = action_tick(a);
|
||||
const auto b_tick = action_tick(b);
|
||||
return a_tick < b_tick ||
|
||||
(a_tick == b_tick && (a.account < b.account ||
|
||||
(a.account == b.account && a.action_id < b.action_id)));
|
||||
(a_tick == b_tick &&
|
||||
(a.account < b.account || (a.account == b.account && a.action_id < b.action_id)));
|
||||
}
|
||||
bool valid_actions(std::span<const CellularActionRecord> actions, std::uint64_t begin_tick,
|
||||
std::uint64_t end_tick) {
|
||||
@@ -215,14 +209,14 @@ decode_cellular_batch(std::span<const std::uint8_t> bytes) {
|
||||
return std::unexpected{CellularBatchError::format};
|
||||
CellularLifeIntent life;
|
||||
life.life_id = get(record, 0, 8);
|
||||
life.intent.movement.x = std::bit_cast<std::int16_t>(
|
||||
static_cast<std::uint16_t>(get(record, 8, 2)));
|
||||
life.intent.movement.y = std::bit_cast<std::int16_t>(
|
||||
static_cast<std::uint16_t>(get(record, 10, 2)));
|
||||
life.intent.movement.x =
|
||||
std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(record, 8, 2)));
|
||||
life.intent.movement.y =
|
||||
std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(record, 10, 2)));
|
||||
if (record[12] == 1) {
|
||||
life.intent.intake_target = biology::CellularPatchAddress{
|
||||
static_cast<std::uint32_t>(get(record, 16, 4)),
|
||||
static_cast<std::uint32_t>(get(record, 20, 4))};
|
||||
life.intent.intake_target =
|
||||
biology::CellularPatchAddress{static_cast<std::uint32_t>(get(record, 16, 4)),
|
||||
static_cast<std::uint32_t>(get(record, 20, 4))};
|
||||
} else if (!all_zero(record.subspan(16, 8))) {
|
||||
return std::unexpected{CellularBatchError::format};
|
||||
}
|
||||
@@ -275,8 +269,11 @@ replay_cellular_batch(const CellularLives& base, const CellularBatch& batch) {
|
||||
return std::unexpected{CellularBatchError::state};
|
||||
for (const auto& birth : tick.births) {
|
||||
const LifeRequest request{birth.account, birth.request};
|
||||
const LifeAllocation allocation{birth.identity, birth.identity, birth.identity,
|
||||
birth.identity, {(*replay)->tick()}};
|
||||
const LifeAllocation allocation{birth.identity,
|
||||
birth.identity,
|
||||
birth.identity,
|
||||
birth.identity,
|
||||
{(*replay)->tick()}};
|
||||
auto born = (*replay)->birth_candidate(request, allocation);
|
||||
if (!born)
|
||||
return std::unexpected{CellularBatchError::state};
|
||||
@@ -331,28 +328,27 @@ match_cellular_actions_to_trace(const CellularLives& predecessor, const Cellular
|
||||
predecessor.frame() != batch.header.frame || predecessor.tick() != batch.header.begin_tick)
|
||||
return std::unexpected{CellularActionBlockError::mismatch};
|
||||
for (const auto& action : actions) {
|
||||
const auto life = std::ranges::find(predecessor.lives(), action.account,
|
||||
&CellularOwnedLife::account);
|
||||
const auto life =
|
||||
std::ranges::find(predecessor.lives(), action.account, &CellularOwnedLife::account);
|
||||
if (life == predecessor.lives().end())
|
||||
return std::unexpected{CellularActionBlockError::mismatch};
|
||||
const auto index = static_cast<std::size_t>(action_tick(action) - batch.header.begin_tick - 1);
|
||||
const auto index =
|
||||
static_cast<std::size_t>(action_tick(action) - batch.header.begin_tick - 1);
|
||||
const auto& intents = batch.ticks[index].lives;
|
||||
const auto intent = std::ranges::lower_bound(
|
||||
intents, life->identity.life, {}, [](const CellularLifeIntent& value) {
|
||||
return value.life_id;
|
||||
});
|
||||
const auto intent =
|
||||
std::ranges::lower_bound(intents, life->identity.life, {},
|
||||
[](const CellularLifeIntent& value) { return value.life_id; });
|
||||
if (intent == intents.end() || intent->life_id != life->identity.life)
|
||||
return std::unexpected{CellularActionBlockError::mismatch};
|
||||
const auto input = std::span<const std::uint8_t>{action.input};
|
||||
std::optional<biology::CellularPatchAddress> target;
|
||||
if (input[12] != 0)
|
||||
target = biology::CellularPatchAddress{
|
||||
static_cast<std::uint32_t>(get(input, 16, 4)),
|
||||
static_cast<std::uint32_t>(get(input, 20, 4))};
|
||||
if (intent->intent.movement.x != std::bit_cast<std::int16_t>(
|
||||
static_cast<std::uint16_t>(get(input, 8, 2))) ||
|
||||
intent->intent.movement.y != std::bit_cast<std::int16_t>(
|
||||
static_cast<std::uint16_t>(get(input, 10, 2))) ||
|
||||
target = biology::CellularPatchAddress{static_cast<std::uint32_t>(get(input, 16, 4)),
|
||||
static_cast<std::uint32_t>(get(input, 20, 4))};
|
||||
if (intent->intent.movement.x !=
|
||||
std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(input, 8, 2))) ||
|
||||
intent->intent.movement.y !=
|
||||
std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(input, 10, 2))) ||
|
||||
intent->intent.intake_target != target)
|
||||
return std::unexpected{CellularActionBlockError::mismatch};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user