diff -r 965e0148135b -r 94791c38ce23 src/settings_gui.cpp --- a/src/settings_gui.cpp Sat Nov 15 12:34:04 2008 +0100 +++ b/src/settings_gui.cpp Sat Nov 15 13:45:53 2008 +0100 @@ -587,25 +587,26 @@ /** Data structure describing a single patch in a tab */ struct PatchEntry { + const char *name; ///< Name of the setting const SettingDesc *setting; ///< Setting description of the patch uint index; ///< Index of the setting in the settings table + + PatchEntry(const char *nm); }; -/** - * Data structure describing one page of patches in the patch settings window. - * - * The names of the patches to display are statically defined, and from this - * information, a dynamic array (with length \a num) of PatchEntry entries is - * constructed. - */ +/** Data structure describing one page of patches in the patch settings window. */ struct PatchPage { - const char **names; ///< Static list of strings with patch names that are settable from the tab - PatchEntry *entries; ///< Array of patch entries of the page. Initially \c NULL, filled in at run time + PatchEntry *entries; ///< Array of patch entries of the page. byte num; ///< Number of entries on the page (statically filled). }; -static const char *_patches_ui[] = { +/* == PatchEntry methods == */ + +PatchEntry::PatchEntry(const char *nm): name(nm), setting(NULL), index(0) { } + + +static PatchEntry _patches_ui[] = { "gui.vehicle_speed", "gui.status_long_date", "gui.show_finances", @@ -638,7 +639,7 @@ "gui.show_track_reservation", }; -static const char *_patches_construction[] = { +static PatchEntry _patches_construction[] = { "construction.build_on_slopes", "construction.autoslope", "construction.extra_dynamite", @@ -653,7 +654,7 @@ "gui.cycle_signal_types", }; -static const char *_patches_stations[] = { +static PatchEntry _patches_stations[] = { "station.join_stations", "order.improved_load", "order.selectgoods", @@ -668,7 +669,7 @@ "economy.station_noise_level", }; -static const char *_patches_economy[] = { +static PatchEntry _patches_economy[] = { "economy.inflation", "construction.raw_industry_construction", "economy.multiple_industry_per_town", @@ -687,7 +688,7 @@ "economy.initial_city_size", }; -static const char *_patches_ai[] = { +static PatchEntry _patches_ai[] = { "ai.ainew_active", "ai.ai_in_multiplayer", "ai.ai_disable_veh_train", @@ -696,7 +697,7 @@ "ai.ai_disable_veh_ship", }; -static const char *_patches_vehicles[] = { +static PatchEntry _patches_vehicles[] = { "vehicle.realistic_acceleration", "pf.forbid_90_deg", "vehicle.mammoth_trains", @@ -732,12 +733,12 @@ /** Array of pages (tabs), where each page holds a number of advanced settings. */ static PatchPage _patches_page[] = { - {_patches_ui, NULL, lengthof(_patches_ui)}, - {_patches_construction, NULL, lengthof(_patches_construction)}, - {_patches_vehicles, NULL, lengthof(_patches_vehicles)}, - {_patches_stations, NULL, lengthof(_patches_stations)}, - {_patches_economy, NULL, lengthof(_patches_economy)}, - {_patches_ai, NULL, lengthof(_patches_ai)}, + {_patches_ui, lengthof(_patches_ui)}, + {_patches_construction, lengthof(_patches_construction)}, + {_patches_vehicles, lengthof(_patches_vehicles)}, + {_patches_stations, lengthof(_patches_stations)}, + {_patches_economy, lengthof(_patches_economy)}, + {_patches_ai, lengthof(_patches_ai)}, }; /** Widget numbers of config patches window */ @@ -779,10 +780,9 @@ /* 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++) { - page->entries = MallocT(page->num); for (uint i = 0; i != page->num; i++) { uint index; - const SettingDesc *sd = GetPatchFromName(page->names[i], &index); + const SettingDesc *sd = GetPatchFromName(page->entries[i].name, &index); assert(sd != NULL); page->entries[i].setting = sd;