diff --git a/src/picker_gui.h b/src/picker_gui.h index 74489c8494..7d11f51637 100644 --- a/src/picker_gui.h +++ b/src/picker_gui.h @@ -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; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 492d6e75f3..ea953c974b 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -1588,16 +1588,19 @@ public: std::set 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()); } } }