Preserve production order identities and preflight whole placement batches
This commit is contained in:
1 parent
4ba64f7e62
commit
2a3ec924de
16 files changed
+661
-88
No files matched your search
@@ -165,7 +165,7 @@ std::expected<std::string, CheckpointDiagnostic> encode_checkpoint(
|
||||
fail(CheckpointError::LimitExceeded, "metadata_length", "Checkpoint metadata exceeds 64 KiB.");
|
||||
}
|
||||
std::ostringstream stream(std::ios::binary);
|
||||
world.write_save(stream);
|
||||
world.write_save(stream, WorldSaveFormat::Current14);
|
||||
auto body = std::move(stream).str();
|
||||
if (body.size() > max_checkpoint_body_bytes) {
|
||||
fail(CheckpointError::LimitExceeded, "body_length", "Checkpoint world exceeds 128 MiB.");
|
||||
@@ -212,7 +212,8 @@ std::expected<WorldCheckpoint, CheckpointDiagnostic> decode_checkpoint(
|
||||
if (!std::ranges::equal(get_bytes(header, checkpoint_signature.size(), "magic"), wire_bytes(checkpoint_signature))) {
|
||||
fail(CheckpointError::InvalidFrame, "magic", "Checkpoint signature does not match.");
|
||||
}
|
||||
if (get<std::uint32_t>(header, "version") != checkpoint_version) {
|
||||
const auto schema = get<std::uint32_t>(header, "version");
|
||||
if (schema != 1 && schema != checkpoint_version) {
|
||||
fail(CheckpointError::UnsupportedVersion, "version", "Checkpoint schema is not supported.");
|
||||
}
|
||||
const auto metadata_size = get<std::uint32_t>(header, "metadata_length");
|
||||
@@ -263,6 +264,15 @@ std::expected<WorldCheckpoint, CheckpointDiagnostic> decode_checkpoint(
|
||||
}
|
||||
auto rules = validate_rules(saved, fingerprint, installed);
|
||||
const auto body = bytes.substr(header_size + metadata_size, static_cast<std::size_t>(body_size));
|
||||
if (body.size() < 12 || body.substr(0, 8) != "SETTLERS") {
|
||||
fail(CheckpointError::InvalidWorld, "world.version", "Checkpoint world header is invalid.");
|
||||
}
|
||||
Void::Binary::Reader body_header(wire_bytes(body).subspan(8, 4));
|
||||
const auto body_version = get<std::uint32_t>(body_header, "world.version");
|
||||
if ((schema == 1 && (body_version < 1 || body_version > 13)) ||
|
||||
(schema == 2 && body_version != 14)) {
|
||||
fail(CheckpointError::InvalidWorld, "world.version", "Checkpoint schema and world version do not match.");
|
||||
}
|
||||
std::ispanstream stream(std::span<const char>{body.data(), body.size()});
|
||||
auto world = World::read_save(stream, workers, mode);
|
||||
if (world->tick() != tick) {
|
||||
|
||||
Reference in new issue
Block a user