1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-06 03:52:37 +01:00

Fix ed67aedabf: Saved default houses had incorrect class and index information. (#14812)

Saved default houses would not appear properly in the 'Saved' tab after restarting the game.
This commit is contained in:
Peter Nelson
2025-11-22 12:15:14 +00:00
committed by GitHub
parent 821a496495
commit f3b24d51c3
2 changed files with 8 additions and 5 deletions

View File

@@ -136,9 +136,9 @@ public:
for (const auto &item : src) {
const auto *spec = T::GetByGrf(item.grfid, item.local_id);
if (spec == nullptr) {
dst.insert({item.grfid, item.local_id, -1, -1});
dst.emplace(item.grfid, item.local_id, -1, -1);
} else {
dst.insert(GetPickerItem(spec));
dst.emplace(GetPickerItem(spec));
}
}
return dst;

View File

@@ -1588,16 +1588,19 @@ public:
std::set<PickerItem> dst;
for (const auto &item : src) {
if (item.grfid == 0) {
dst.insert(item);
const HouseSpec *hs = HouseSpec::Get(item.local_id);
if (hs == nullptr) continue;
int class_index = GetClassIdFromHouseZone(hs->building_availability);
dst.emplace(item.grfid, item.local_id, class_index, item.local_id);
} else {
/* Search for spec by grfid and local index. */
auto it = std::ranges::find_if(specs, [&item](const HouseSpec &spec) { return spec.grf_prop.grfid == item.grfid && spec.grf_prop.local_id == item.local_id; });
if (it == specs.end()) {
/* Not preset, hide from UI. */
dst.insert({item.grfid, item.local_id, -1, -1});
dst.emplace(item.grfid, item.local_id, -1, -1);
} else {
int class_index = GetClassIdFromHouseZone(it->building_availability);
dst.insert( {item.grfid, item.local_id, class_index, it->Index()});
dst.emplace(item.grfid, item.local_id, class_index, it->Index());
}
}
}