Codechange: Use begin/end of nwidget parts of begin/length.

This simplifies processing nwidget parts as, unlike the remaining length, the pointer to the end of the list never changes. This is the same principle as we use(d) for tracking end instead of length for C-style strings.

And this removes 160~ instances of the lengthof() macro.
This commit is contained in:
Peter Nelson
2023-09-03 21:54:13 +01:00
committed by PeterN
parent e4613fc04c
commit e8015e497d
65 changed files with 231 additions and 232 deletions

View File

@@ -841,7 +841,7 @@ static WindowDesc _build_rail_desc(
WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_rail_widgets, lengthof(_nested_build_rail_widgets),
std::begin(_nested_build_rail_widgets), std::end(_nested_build_rail_widgets),
&BuildRailToolbarWindow::hotkeys
);
@@ -1631,7 +1631,7 @@ static WindowDesc _station_builder_desc(
WDP_AUTO, "build_station_rail", 350, 0,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_station_builder_widgets, lengthof(_nested_station_builder_widgets),
std::begin(_nested_station_builder_widgets), std::end(_nested_station_builder_widgets),
&BuildRailStationWindow::hotkeys
);
@@ -1889,7 +1889,7 @@ static WindowDesc _signal_builder_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets)
std::begin(_nested_signal_builder_widgets), std::end(_nested_signal_builder_widgets)
);
/**
@@ -1980,7 +1980,7 @@ static WindowDesc _build_depot_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_depot_widgets, lengthof(_nested_build_depot_widgets)
std::begin(_nested_build_depot_widgets), std::end(_nested_build_depot_widgets)
);
static void ShowBuildTrainDepotPicker(Window *parent)
@@ -2208,7 +2208,7 @@ static WindowDesc _build_waypoint_desc(
WDP_AUTO, "build_waypoint", 0, 0,
WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_waypoint_widgets, lengthof(_nested_build_waypoint_widgets)
std::begin(_nested_build_waypoint_widgets), std::end(_nested_build_waypoint_widgets)
);
static void ShowBuildWaypointPicker(Window *parent)