Skip to content

Commit

Permalink
Fix selling improvements from multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
blabber committed Jan 5, 2025
1 parent 741cc05 commit 4d71cf5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions client/views/view_cities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ void city_widget::display_list_menu(const QPoint)
QString imprname;
const struct impr_type *building;
Impr_type_id impr_id;
int city_id;
bool need_clear = true;
bool sell_ask = true;

Expand Down Expand Up @@ -686,16 +685,18 @@ void city_widget::display_list_menu(const QPoint)
ask->button(QMessageBox::Yes)->setText(_("Yes Sell"));
ask->set_text_title(buf, _("Sell?"));
ask->setAttribute(Qt::WA_DeleteOnClose);
city_id = pcity->id;
impr_id = improvement_number(building);
connect(ask, &hud_message_box::accepted, this, [=]() {
struct city *pcity = game_city_by_number(city_id);
struct impr_type *building = improvement_by_number(impr_id);
if (!pcity || !building) {
if (!building) {
return;
}
if (!pcity->did_sell && city_has_building(pcity, building)) {
city_sell_improvement(pcity, impr_id);

auto saved_selection = selected_cities; // Copy to avoid invalidation
for (auto *pcity : saved_selection) {
if (!pcity->did_sell && city_has_building(pcity, building)) {
city_sell_improvement(pcity, impr_id);
}
}
});
ask->show();
Expand Down

0 comments on commit 4d71cf5

Please sign in to comment.