750 /** Save the values of settings to the inifile. |
751 /** Save the values of settings to the inifile. |
751 * @param ini pointer to IniFile structure |
752 * @param ini pointer to IniFile structure |
752 * @param sd read-only SettingDesc structure which contains the unmodified, |
753 * @param sd read-only SettingDesc structure which contains the unmodified, |
753 * loaded values of the configuration file and various information about it |
754 * loaded values of the configuration file and various information about it |
754 * @param grpname holds the name of the group (eg. [network]) where these will be saved |
755 * @param grpname holds the name of the group (eg. [network]) where these will be saved |
|
756 * @param object pointer to the object been saved |
755 * The function works as follows: for each item in the SettingDesc structure we |
757 * The function works as follows: for each item in the SettingDesc structure we |
756 * have a look if the value has changed since we started the game (the original |
758 * have a look if the value has changed since we started the game (the original |
757 * values are reloaded when saving). If settings indeed have changed, we get |
759 * values are reloaded when saving). If settings indeed have changed, we get |
758 * these and save them. |
760 * these and save them. |
759 */ |
761 */ |
863 |
865 |
864 /** Loads all items from a 'grpname' section into a list |
866 /** Loads all items from a 'grpname' section into a list |
865 * The list parameter can be a NULL pointer, in this case nothing will be |
867 * The list parameter can be a NULL pointer, in this case nothing will be |
866 * saved and a callback function should be defined that will take over the |
868 * saved and a callback function should be defined that will take over the |
867 * list-handling and store the data itself somewhere. |
869 * list-handling and store the data itself somewhere. |
868 * @param IniFile handle to the ini file with the source data |
870 * @param ini IniFile handle to the ini file with the source data |
869 * @param grpname character string identifying the section-header of the ini |
871 * @param grpname character string identifying the section-header of the ini |
870 * file that will be parsed |
872 * file that will be parsed |
871 * @param list pointer to an string(pointer) array that will store the parsed |
873 * @param list pointer to an string(pointer) array that will store the parsed |
872 * entries of the given section |
874 * entries of the given section |
873 * @param len the maximum number of items available for the above list |
875 * @param len the maximum number of items available for the above list |
893 } |
895 } |
894 |
896 |
895 /** Saves all items from a list into the 'grpname' section |
897 /** Saves all items from a list into the 'grpname' section |
896 * The list parameter can be a NULL pointer, in this case a callback function |
898 * The list parameter can be a NULL pointer, in this case a callback function |
897 * should be defined that will provide the source data to be saved. |
899 * should be defined that will provide the source data to be saved. |
898 * @param IniFile handle to the ini file where the destination data is saved |
900 * @param ini IniFile handle to the ini file where the destination data is saved |
899 * @param grpname character string identifying the section-header of the ini file |
901 * @param grpname character string identifying the section-header of the ini file |
900 * @param list pointer to an string(pointer) array that will be used as the |
902 * @param list pointer to an string(pointer) array that will be used as the |
901 * source to be saved into the relevant ini section |
903 * source to be saved into the relevant ini section |
902 * @param len the maximum number of items available for the above list |
904 * @param len the maximum number of items available for the above list |
903 * @param proc callback function that can will provide the source data if defined */ |
905 * @param proc callback function that can will provide the source data if defined */ |
904 static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc) |
906 static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc) |
905 { |
907 { |
906 IniGroup *group = ini_getgroup(ini, grpname, -1); |
908 IniGroup *group = ini_getgroup(ini, grpname, -1); |
1391 SDT_VAR(Patches, colored_news_year,SLE_INT32, 0,NC, 2000, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL), |
1393 SDT_VAR(Patches, colored_news_year,SLE_INT32, 0,NC, 2000, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL), |
1392 SDT_VAR(Patches, starting_year, SLE_INT32, 0,NC, 1950, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_STARTING_YEAR,NULL), |
1394 SDT_VAR(Patches, starting_year, SLE_INT32, 0,NC, 1950, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_STARTING_YEAR,NULL), |
1393 SDT_VAR(Patches, ending_year, SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR, NULL), |
1395 SDT_VAR(Patches, ending_year, SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR, NULL), |
1394 SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL), |
1396 SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL), |
1395 SDT_BOOL(Patches, allow_shares, 0, 0, false, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL), |
1397 SDT_BOOL(Patches, allow_shares, 0, 0, false, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL), |
1396 SDT_CONDVAR(Patches, town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0, 4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH, NULL), |
1398 SDT_CONDVAR(Patches, town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0, 4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH, NULL), |
1397 SDT_CONDVAR(Patches, larger_towns, SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS, NULL), |
1399 SDT_CONDVAR(Patches, larger_towns, SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS, NULL), |
|
1400 SDT_CONDVAR(Patches, initial_city_size, SLE_UINT8, 56, SL_MAX_VERSION, 0, 0, 2, 1, 10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER, NULL), |
1398 |
1401 |
1399 /***************************************************************************/ |
1402 /***************************************************************************/ |
1400 /* AI section of the GUI-configure patches window */ |
1403 /* AI section of the GUI-configure patches window */ |
1401 SDT_BOOL(Patches, ainew_active, 0, 0, false, STR_CONFIG_PATCHES_AINEW_ACTIVE, AiNew_PatchActive_Warning), |
1404 SDT_BOOL(Patches, ainew_active, 0, 0, false, STR_CONFIG_PATCHES_AINEW_ACTIVE, AiNew_PatchActive_Warning), |
1402 SDT_BOOL(Patches, ai_in_multiplayer, 0, 0, false, STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER, Ai_In_Multiplayer_Warning), |
1405 SDT_BOOL(Patches, ai_in_multiplayer, 0, 0, false, STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER, Ai_In_Multiplayer_Warning), |
1877 if (!SlObjectMember(ptr, sld)) continue; |
1882 if (!SlObjectMember(ptr, sld)) continue; |
1878 } |
1883 } |
1879 } |
1884 } |
1880 |
1885 |
1881 /** Loadhandler for a list of global variables |
1886 /** Loadhandler for a list of global variables |
|
1887 * @param sdg pointer for the global variable list SettingDescGlobVarList |
1882 * @note this is actually a stub for LoadSettings with the |
1888 * @note this is actually a stub for LoadSettings with the |
1883 * object pointer set to NULL */ |
1889 * object pointer set to NULL */ |
1884 static inline void LoadSettingsGlobList(const SettingDescGlobVarList *sdg) |
1890 static inline void LoadSettingsGlobList(const SettingDescGlobVarList *sdg) |
1885 { |
1891 { |
1886 LoadSettings((const SettingDesc*)sdg, NULL); |
1892 LoadSettings((const SettingDesc*)sdg, NULL); |
1887 } |
1893 } |
1888 |
1894 |
1889 /** Save and load handler for patches/settings |
1895 /** Save and load handler for patches/settings |
1890 * @param osd SettingDesc struct containing all information |
1896 * @param sd SettingDesc struct containing all information |
1891 * @param object can be either NULL in which case we load global variables or |
1897 * @param object can be either NULL in which case we load global variables or |
1892 * a pointer to a struct which is getting saved */ |
1898 * a pointer to a struct which is getting saved */ |
1893 static void SaveSettings(const SettingDesc *sd, void *object) |
1899 static void SaveSettings(const SettingDesc *sd, void *object) |
1894 { |
1900 { |
1895 /* We need to write the CH_RIFF header, but unfortunately can't call |
1901 /* We need to write the CH_RIFF header, but unfortunately can't call |