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:
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

@@ -104,14 +104,14 @@ std::string _windows_file;
/** Window description constructor. */
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad,
WindowClass window_class, WindowClass parent_class, uint32_t flags,
const NWidgetPart *nwid_parts, int16_t nwid_length, HotkeyList *hotkeys) :
const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, HotkeyList *hotkeys) :
default_pos(def_pos),
cls(window_class),
parent_cls(parent_class),
ini_key(ini_key),
flags(flags),
nwid_parts(nwid_parts),
nwid_length(nwid_length),
nwid_begin(nwid_begin),
nwid_end(nwid_end),
hotkeys(hotkeys),
pref_sticky(false),
pref_width(0),
@@ -1798,7 +1798,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, i
void Window::CreateNestedTree(bool fill_nested)
{
int biggest_index = -1;
this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_parts, this->window_desc->nwid_length, &biggest_index, &this->shade_select);
this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &biggest_index, &this->shade_select);
this->nested_array_size = (uint)(biggest_index + 1);
if (fill_nested) {