diff -r 2088de2580fa -r 34c6c2026f14 src/settings_gui.cpp --- a/src/settings_gui.cpp Sat Nov 15 13:46:29 2008 +0100 +++ b/src/settings_gui.cpp Sat Nov 15 13:56:55 2008 +0100 @@ -592,18 +592,38 @@ uint index; ///< Index of the setting in the settings table PatchEntry(const char *nm); + + void Init(); }; /** Data structure describing one page of patches in the patch settings window. */ struct PatchPage { PatchEntry *entries; ///< Array of patch entries of the page. byte num; ///< Number of entries on the page (statically filled). + + void Init(); }; - /* == PatchEntry methods == */ +/** Constructor a patch setting */ PatchEntry::PatchEntry(const char *nm): name(nm), setting(NULL), index(0) { } + +/** Initialization of a patch entry */ +void PatchEntry::Init() +{ + setting = GetPatchFromName(name, &index); + assert(setting != NULL); +} + +/* == PatchPage methods == */ + +/** Initialization of an entire patch page */ +void PatchPage::Init() +{ + for (uint fld = 0; fld < num; fld++) + entries[fld].Init(); +} static PatchEntry _patches_ui[] = { @@ -779,16 +799,8 @@ /* Build up the dynamic settings-array only once per OpenTTD session */ if (first_time) { - for (PatchPage *page = &_patches_page[0]; page != endof(_patches_page); page++) { - for (uint i = 0; i != page->num; i++) { - uint index; - const SettingDesc *sd = GetPatchFromName(page->entries[i].name, &index); - assert(sd != NULL); - - page->entries[i].setting = sd; - page->entries[i].index = index; - } - } + for (PatchPage *page = &_patches_page[0]; page != endof(_patches_page); page++) + page->Init(); first_time = false; }