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

Function CheckSoftLimit

src/window.cpp:3037–3057  ·  view source on GitHub ↗

* Check the soft limit of deletable (non vital, non sticky) windows. */

Source from the content-addressed store, hash-verified

3035 * Check the soft limit of deletable (non vital, non sticky) windows.
3036 */
3037static void CheckSoftLimit()
3038{
3039 if (_settings_client.gui.window_soft_limit == 0) return;
3040
3041 for (;;) {
3042 uint deletable_count = 0;
3043 Window *last_deletable = nullptr;
3044 for (Window *w : Window::IterateFromFront()) {
3045 if (w->window_class == WC_MAIN_WINDOW || IsVitalWindow(w) || w->flags.Test(WindowFlag::Sticky)) continue;
3046
3047 last_deletable = w;
3048 deletable_count++;
3049 }
3050
3051 /* We've not reached the soft limit yet. */
3052 if (deletable_count <= _settings_client.gui.window_soft_limit) break;
3053
3054 assert(last_deletable != nullptr);
3055 last_deletable->Close();
3056 }
3057}
3058
3059/**
3060 * Regular call from the global game loop

Callers 1

InputLoopFunction · 0.85

Calls 3

IsVitalWindowFunction · 0.85
TestMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected