From 7385e780ac2861ca98e10d660ba4a6351a6b2741 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 29 Apr 2021 20:04:50 +0100 Subject: [PATCH] Cleanup: nested_array should not be accessed directly. Replace accesses with GetWidget() as documented. --- src/airport_gui.cpp | 2 +- src/depot_gui.cpp | 2 +- src/object_gui.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index cfe0ca4cb3..4d09fbdfdf 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -485,7 +485,7 @@ public: break; case WID_AP_AIRPORT_LIST: { - int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height; + int num_clicked = this->vscroll->GetPosition() + (pt.y - this->GetWidget(widget)->pos_y) / this->line_height; if (num_clicked >= this->vscroll->GetCount()) break; const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked); if (as->IsAvailable()) this->SelectOtherAirport(num_clicked); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 151eb928d8..d6f4d900cf 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -1046,7 +1046,7 @@ struct DepotWindow : Window { this->RaiseWidget(WID_D_SELL); this->SetWidgetDirty(WID_D_SELL); } - if (this->nested_array[WID_D_SELL] != nullptr && !this->IsWidgetDisabled(WID_D_SELL_CHAIN)) { + if (this->GetWidget(WID_D_SELL) != nullptr && !this->IsWidgetDisabled(WID_D_SELL_CHAIN)) { this->RaiseWidget(WID_D_SELL_CHAIN); this->SetWidgetDirty(WID_D_SELL_CHAIN); } diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 05e9b0092d..4e5c5815d6 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -515,7 +515,7 @@ public: { switch (GB(widget, 0, 16)) { case WID_BO_CLASS_LIST: { - int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height; + int num_clicked = this->vscroll->GetPosition() + (pt.y - this->GetWidget(widget)->pos_y) / this->line_height; if (num_clicked >= (int)this->object_classes.size()) break; this->SelectOtherClass(this->object_classes[num_clicked]);