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

Method OnInvalidateData

src/smallmap_gui.cpp:1822–1849  ·  view source on GitHub ↗

* Some data on this window has become invalid. * @param data Information about the changed data. * - data = 0: Displayed industries at the industry chain window have changed. * - data = 1: Companies have changed. * - data = 2: Cheat changing the maximum heightlevel has been used, rebuild our heightlevel-to-colour index * @param gui_scope Whether the call is done from GUI scope. You may n

Source from the content-addressed store, hash-verified

1820 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
1821 */
1822 void OnInvalidateData(int data = 0, bool gui_scope = true) override
1823 {
1824 if (!gui_scope) return;
1825
1826 switch (data) {
1827 case 1:
1828 /* The owner legend has already been rebuilt. */
1829 this->ReInit();
1830 break;
1831
1832 case 0: {
1833 extern std::bitset<NUM_INDUSTRYTYPES> _displayed_industries;
1834 if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
1835
1836 for (int i = 0; i != _smallmap_industry_count; i++) {
1837 _legend_from_industries[i].show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
1838 }
1839 break;
1840 }
1841
1842 case 2:
1843 this->RebuildColourIndexIfNecessary();
1844 break;
1845
1846 default: NOT_REACHED();
1847 }
1848 this->SetDirty();
1849 }
1850
1851 bool OnRightClick(Point, WidgetID widget) override
1852 {

Callers

nothing calls this directly

Calls 6

SwitchMapTypeMethod · 0.95
NOT_REACHEDFunction · 0.85
ReInitMethod · 0.80
testMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected