MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsNWidgetTreeClosed

Function IsNWidgetTreeClosed

src/tests/test_window_desc.cpp:68–76  ·  view source on GitHub ↗

* Test if a NWidgetTree is properly closed, meaning the number of container-type parts matches the number of * EndContainer() parts. * @param nwid_parts Span of nested widget parts. * @return True iff nested tree is properly closed. */

Source from the content-addressed store, hash-verified

66 * @return True iff nested tree is properly closed.
67 */
68static bool IsNWidgetTreeClosed(std::span<const NWidgetPart> nwid_parts)
69{
70 int depth = 0;
71 for (const auto nwid : nwid_parts) {
72 if (IsContainerWidgetType(nwid.type)) ++depth;
73 if (nwid.type == WPT_ENDCONTAINER) --depth;
74 }
75 return depth == 0;
76}
77
78TEST_CASE("WindowDesc - NWidgetParts properly closed")
79{

Callers 1

Calls 1

IsContainerWidgetTypeFunction · 0.85

Tested by

no test coverage detected