Implement M6.5a coupled resource snapshots and restore
This commit is contained in:
@@ -52,7 +52,10 @@ enum class TransferError : std::uint8_t {
|
||||
unknown_organism,
|
||||
insufficient,
|
||||
conflict,
|
||||
stale_command
|
||||
stale_command,
|
||||
format,
|
||||
version,
|
||||
checksum
|
||||
};
|
||||
class EnvironmentalTransfers {
|
||||
public:
|
||||
@@ -76,6 +79,11 @@ class EnvironmentalTransfers {
|
||||
[[nodiscard]] std::span<const OrganismResources> organisms() const noexcept {
|
||||
return std::span{organisms_}.first(count_);
|
||||
}
|
||||
static constexpr std::size_t max_snapshot_bytes = std::size_t{72} * 1024 * 1024;
|
||||
[[nodiscard]] std::expected<WorldBytes, TransferError> snapshot() const;
|
||||
[[nodiscard]] static std::expected<std::unique_ptr<EnvironmentalTransfers>, TransferError>
|
||||
restore(std::span<const std::uint8_t> bytes, WorldIdentity identity, std::size_t byte_budget,
|
||||
std::size_t field_budget, std::size_t terrain_budget);
|
||||
[[nodiscard]] accounting::Inventory totals() const noexcept;
|
||||
[[nodiscard]] std::size_t accounted_bytes() const noexcept;
|
||||
[[nodiscard]] std::expected<EnvironmentalReceipt, TransferError>
|
||||
@@ -93,5 +101,6 @@ class EnvironmentalTransfers {
|
||||
std::array<OrganismResources, max_organisms> organisms_{};
|
||||
std::array<History, retained_commands> history_{};
|
||||
std::size_t count_{}, budget_{}, next_history_{};
|
||||
std::uint64_t adoption_command_{};
|
||||
};
|
||||
} // namespace evo::world
|
||||
|
||||
Reference in New Issue
Block a user