Add furnished houses, roof views, carpentry, and GCC 16 tests

This commit is contained in:
Codex committed 2026-12-01 11:52:03 +03:00
1 parent 85547b00b9
commit 8bb448cc49
21 files changed
+1256 -331

No files matched your search

+28 -10
View File
@@ -13,7 +13,7 @@ namespace settlement {
namespace {
constexpr std::string_view signature = "SETTLERS";
constexpr std::uint32_t save_version = 10;
constexpr std::uint32_t save_version = 12;
constexpr std::uint32_t last_legacy_footer_version = 8;
constexpr std::size_t max_records = 1'000'000;
constexpr std::size_t max_save_bytes = 128 * 1024 * 1024;
@@ -174,7 +174,7 @@ void flag(Archive& archive, Flag& value) {
struct WorldSaveCodec {
template<class Archive, class State>
static void body(Archive& archive, State& world, std::uint32_t version) {
const auto max_item = version >= 7 ? ItemType::Flax : ItemType::Cloth;
const auto max_item = version >= 12 ? ItemType::WoodenDoor : (version >= 7 ? ItemType::Flax : ItemType::Cloth);
const auto max_item_count = static_cast<std::size_t>(max_item);
archive.field(world.tick_);
archive.field(world.path_searches_);
@@ -214,6 +214,7 @@ struct WorldSaveCodec {
if (version >= 4) archive.field(agent.fatigue);
if (version >= 5) flag(archive, agent.resting_on_ground);
if (version >= 6) archive.field(agent.profession);
require_save(version >= 12 || agent.profession <= Profession::Builder, "Unknown profession for save version.");
});
sequence(archive, world.jobs_, max_records, [&](auto& job) {
archive.field(job.id);
@@ -256,6 +257,8 @@ struct WorldSaveCodec {
require_save(version >= 2 || order.recipe <= RecipeId::BuildCabin, "Unknown recipe for save version.");
require_save(version >= 7 || order.recipe <= RecipeId::BuildBed, "Unknown recipe for save version.");
require_save(version >= 10 || order.recipe <= RecipeId::WeaveCloth, "Unknown recipe for save version.");
require_save(version >= 11 || order.recipe <= RecipeId::BuildDoorAlongY, "Unknown recipe for save version.");
require_save(version >= 12 || order.recipe <= RecipeId::BuildLoom, "Unknown recipe for save version.");
archive.field(order.state);
sequence(archive, order.materials, item_types, [&](auto& material) {
index(archive, material.storage_index);
@@ -362,9 +365,10 @@ void WorldSaveCodec::validate(const World& world) {
std::vector<AgentId> bed_owners;
for (std::size_t i = 0; i < world.production_orders_.size(); ++i) {
const auto& order = world.production_orders_[i];
invalid(order.recipe <= RecipeId::BuildDoorAlongY && order.state <= JobState::Completed &&
invalid(order.recipe <= RecipeId::CraftWoodenDoor && order.state <= JobState::Completed &&
world.is_walkable(order.position) &&
(order.recipe != RecipeId::WeaveCloth || order.state != JobState::Completed));
invalid(order.recipe != RecipeId::CraftWoodenDoor || world.carpenter_workshop() == order.position);
invalid(order.bed_base <= BedBase::Stone && order.bed_stage <= BedStage::Pillow &&
(order.bed_stage == BedStage::Legacy ||
(world.staged_beds_ && order.recipe == RecipeId::BuildBed)) &&
@@ -382,8 +386,8 @@ void WorldSaveCodec::validate(const World& world) {
continue;
}
const bool construction = is_construction(order.recipe);
invalid(order.collected_stops <= order.delivery_stops.size() && (construction || order.delivery_stops.empty()));
const bool delivery = delivers_materials(order.recipe);
invalid(order.collected_stops <= order.delivery_stops.size() && (delivery || order.delivery_stops.empty()));
std::size_t last_storage = 0;
bool first_stop = true;
for (const auto& stop : order.delivery_stops) {
@@ -401,7 +405,7 @@ void WorldSaveCodec::validate(const World& world) {
invalid(material.storage_index < world.storages_.size() && material.count > 0 &&
world.storages_[material.storage_index].kind == StorageKind::Materials);
ingredients[type] += material.count;
if (!construction) {
if (!delivery) {
reserved_items[material.storage_index][type] += material.count;
} else if (!order.delivery_stops.empty()) {
const auto stop = std::find_if(order.delivery_stops.begin(), order.delivery_stops.end(),
@@ -425,10 +429,16 @@ void WorldSaveCodec::validate(const World& world) {
break;
case RecipeId::BuildBed: required[item_index(order.bed_material())] = 1; break;
case RecipeId::WeaveCloth: required[item_index(ItemType::Flax)] = 1; break;
case RecipeId::CraftWoodenDoor: required[item_index(ItemType::Wood)] = 2; break;
case RecipeId::BuildFloor:
case RecipeId::BuildWall:
case RecipeId::BuildDoorAlongX:
case RecipeId::BuildDoorAlongY:
case RecipeId::BuildMedicineCabinet:
case RecipeId::BuildMiningRack:
case RecipeId::BuildLoom:
case RecipeId::InstallDoorAlongX:
case RecipeId::InstallDoorAlongY:
for (const auto& item : world.construction_materials(order.recipe, order.bed_base)) {
if (item.count) required[item_index(item.type)] = item.count;
}
@@ -450,7 +460,7 @@ void WorldSaveCodec::validate(const World& world) {
(world.hunger_enabled_ || agent.hunger == 0) && agent.fatigue <= max_fatigue &&
(world.scenario_active_ || agent.fatigue == 0));
invalid(!agent.resting_on_ground || agent.state == Sleeping || agent.state == GoingToSleep);
invalid(agent.profession <= Profession::Builder);
invalid(agent.profession <= Profession::Carpenter);
valid_route(agent.route);
valid_route(agent.haul_route);
const bool has_job = agent.current_job != 0;
@@ -458,7 +468,9 @@ void WorldSaveCodec::validate(const World& world) {
const bool has_source = agent.resource_node_index != no_entity_index;
const bool has_storage = agent.storage_index != no_entity_index;
invalid(!has_storage || agent.storage_index < world.storages_.size());
invalid(agent.haul_route.empty() || has_source);
const bool door_craft = has_order && agent.production_index < world.production_orders_.size() &&
world.production_orders_[agent.production_index].recipe == RecipeId::CraftWoodenDoor;
invalid(agent.haul_route.empty() || has_source || door_craft);
if (has_job) {
invalid(!has_order && !has_storage && !has_source && agent.inventory.empty() &&
(agent.state == Travelling || agent.state == Working) && agent.work_remaining > 0);
@@ -477,7 +489,13 @@ void WorldSaveCodec::validate(const World& world) {
if (!order.delivery_stops.empty()) {
invalid(agent.state == (order.collected_stops == 0 ? FetchingMaterials : Hauling));
} else {
invalid(agent.state == Working || (agent.state == Travelling && !is_construction(order.recipe)));
invalid(agent.state == Working || (agent.state == Travelling && !delivers_materials(order.recipe)));
}
if (door_craft) {
const auto storage = order.materials.front().storage_index;
const auto destination = world.storages_[storage].position;
invalid(agent.haul_route.empty() ? destination == order.position : agent.haul_route.back() == destination);
if (order.delivery_stops.empty() || order.collected_stops > 0) ++reserved_slots[storage];
}
for (std::size_t i = 0; i < item_types; ++i) {
invalid(agent.inventory.item_count(static_cast<ItemType>(i + 1)) == expected_cargo[agent.production_index][i]);
@@ -497,7 +515,7 @@ void WorldSaveCodec::validate(const World& world) {
} else if (agent.state == Hauling) {
const auto cargo = agent.inventory.first_item();
invalid(has_storage && (cargo == ItemType::Wood || cargo == ItemType::Stone ||
cargo == ItemType::Berries || cargo == ItemType::Flax) &&
cargo == ItemType::Berries || cargo == ItemType::Flax || cargo == ItemType::WoodenDoor) &&
agent.inventory.item_count(cargo) == 1 && agent.work_remaining == 0 &&
world.storages_[agent.storage_index].accepts(cargo));
for (std::size_t i = 1; i <= item_types; ++i) {