diff --git a/config.lib b/config.lib index 17ddd4de5e..ca8346e3e7 100644 --- a/config.lib +++ b/config.lib @@ -1450,7 +1450,11 @@ make_cflags_and_ldflags() { LDFLAGS="$LDFLAGS -noixemul" fi - CFLAGS="-O2 -fomit-frame-pointer $CFLAGS" + if [ "$enable_profiling" = "0" ]; then + # -fomit-frame-pointer and -pg do not go well together (gcc errors they are incompatible) + CFLAGS="-fomit-frame-pointer $CFLAGS" + fi + CFLAGS="-O2 $CFLAGS" else OBJS_SUBDIR="debug" @@ -1494,7 +1498,7 @@ make_cflags_and_ldflags() { fi if [ "$enable_profiling" != "0" ]; then - CFLAGS="$CFLAGS -p" + CFLAGS="$CFLAGS -pg" LDFLAGS="$LDFLAGS -pg" fi diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 4ad4789ff6..cf8cf26285 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -226,8 +226,27 @@ public: this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage); this->OnInvalidateData(); - this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount()); - this->SelectFirstAvailableAirport(true); + /* Ensure airport class is valid (changing NewGRFs). */ + _selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1)); + const AirportClass *ac = AirportClass::Get(_selected_airport_class); + this->vscroll->SetCount(ac->GetSpecCount()); + + /* Ensure the airport index is valid for this class (changing NewGRFs). */ + _selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1); + + /* Only when no valid airport was selected, we want to select the first airport. */ + bool selectFirstAirport = true; + if (_selected_airport_index != -1) { + const AirportSpec *as = ac->GetSpec(_selected_airport_index); + if (as->IsAvailable()) { + /* Ensure the airport layout is valid. */ + _selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1); + selectFirstAirport = false; + this->UpdateSelectSize(); + } + } + + if (selectFirstAirport) this->SelectFirstAvailableAirport(true); } virtual ~BuildAirportWindow() diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 7c655bbb3a..f971dea2b9 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2000,7 +2000,7 @@ struct CargoesRow { if (!hs->enabled) continue; for (uint j = 0; j < lengthof(hs->accepts_cargo); j++) { - if (cargo_fld->u.cargo.vertical_cargoes[i] == hs->accepts_cargo[j]) { + if (hs->cargo_acceptance[j] > 0 && cargo_fld->u.cargo.vertical_cargoes[i] == hs->accepts_cargo[j]) { cargo_fld->ConnectCargo(cargo_fld->u.cargo.vertical_cargoes[i], false); goto next_cargo; } @@ -2192,7 +2192,7 @@ struct IndustryCargoesWindow : public Window { if (!hs->enabled || !(hs->building_availability & climate_mask)) continue; for (uint j = 0; j < lengthof(hs->accepts_cargo); j++) { - if (cargoes[i] == hs->accepts_cargo[j]) return true; + if (hs->cargo_acceptance[j] > 0 && cargoes[i] == hs->accepts_cargo[j]) return true; } } } diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index c9c98ea9f4..0e2512cab2 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -365,10 +365,10 @@ void OSOpenBrowser(const char *url) if (child_pid != 0) return; const char *args[3]; - args[0] = "/usr/bin/xdg-open"; + args[0] = "xdg-open"; args[1] = url; args[2] = NULL; - execv(args[0], const_cast(args)); + execvp(args[0], const_cast(args)); DEBUG(misc, 0, "Failed to open url: %s", url); exit(0); }