Keep generic job phases and checked ID allocation consistent across loads
This commit is contained in:
1 parent
ccd50ec40c
commit
4f4c038051
4 files changed
+90
-3
No files matched your search
@@ -454,6 +454,9 @@ void World::validate_custody() const {
|
||||
}
|
||||
for (const auto& actor : agents_) add_inventory(actor.inventory, {OwnerKind::Resident, actor.id});
|
||||
for (const auto& order : production_orders_) add_inventory(order.input, {OwnerKind::Production, order.id});
|
||||
std::unordered_map<JobId, const WorkJob*> work_jobs;
|
||||
std::set<JobId> assigned_jobs;
|
||||
for (const auto& job : jobs_) require(work_jobs.emplace(job.id, &job).second);
|
||||
std::unordered_map<AgentId, const Agent*> actors;
|
||||
std::unordered_map<ProductionId, const Agent*> producers;
|
||||
for (const auto& actor : agents_) {
|
||||
@@ -473,9 +476,19 @@ void World::validate_custody() const {
|
||||
actor.state != AgentState::Eating && actor.state != AgentState::GoingToEat &&
|
||||
actor.state != AgentState::Gathering && actor.state != AgentState::FetchingMaterials &&
|
||||
(actor.state != AgentState::Working || actor.current_job != 0));
|
||||
require(actor.storage_id == 0 && actor.haul_route.empty());
|
||||
if (actor.state == AgentState::Working || actor.state == AgentState::Travelling) {
|
||||
const auto job = work_jobs.find(actor.current_job);
|
||||
require(job != work_jobs.end() && job->second->state == JobState::InProgress &&
|
||||
assigned_jobs.insert(actor.current_job).second && actor.work_remaining > 0 && actor.work_remaining <= job->second->work_required);
|
||||
if (actor.state == AgentState::Working) require(actor.position == job->second->position && actor.route_cursor == actor.route.size());
|
||||
else require(actor.route_cursor < actor.route.size() && actor.route.back() == job->second->position);
|
||||
} else require(actor.current_job == 0 && actor.work_remaining == 0 &&
|
||||
(actor.state == AgentState::Idle || actor.state == AgentState::GoingToSleep || actor.state == AgentState::Sleeping));
|
||||
continue;
|
||||
}
|
||||
const auto& execution = *actor.execution;
|
||||
require(actor.current_job == 0 && !actor.resting_on_ground);
|
||||
require(execution.id && execution.id < next_transfer_id_ && transfers.insert(execution.id).second &&
|
||||
execution.kind <= TransferKind::Return && execution.next_operation && actor.next_admission >= 2 &&
|
||||
execution.reservation_count <= custody_reservation_limit && execution.blocked <= CustodyStatus::NoDestination);
|
||||
@@ -577,6 +590,7 @@ void World::validate_custody() const {
|
||||
for (const auto& stack : store.items) require(reserved[store.id][static_cast<std::size_t>(stack.type) - 1] == stack.reserved);
|
||||
}
|
||||
for (const auto& node : resource_nodes_) require(workers[node.id] == node.reserved_workers);
|
||||
for (const auto& job : jobs_) require((job.state == JobState::InProgress) == assigned_jobs.contains(job.id));
|
||||
for (const auto& order : production_orders_) {
|
||||
require(order.state <= JobState::Completed);
|
||||
if (order.state == JobState::InProgress) {
|
||||
|
||||
Reference in new issue
Block a user