diff options
author | peter1138 <peter1138@openttd.org> | 2006-12-10 11:32:54 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-12-10 11:32:54 +0000 |
commit | db96bd4b1b26db8f71ab0b471a9c202763f6d4eb (patch) | |
tree | c4fa0b2bbc11b7a56c5aa1fac47b60c0324b92b6 /settings.c | |
parent | 0d5e3344fb92893eab104e287c3d6f88ddf5f409 (diff) | |
download | openttd-db96bd4b1b26db8f71ab0b471a9c202763f6d4eb.tar.xz |
(svn r7465) -Codechange: Save the default GRF configuration.
Diffstat (limited to 'settings.c')
-rw-r--r-- | settings.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/settings.c b/settings.c index 429585e02..ee1f8e675 100644 --- a/settings.c +++ b/settings.c @@ -1495,7 +1495,7 @@ static const SettingDesc _currency_settings[] = { #undef NO #undef CR -const char *GRFProcessParams(const IniItem *item, uint index) +static const char *GRFProcessParams(const IniItem *item, uint index) { GRFConfig *c; @@ -1530,6 +1530,26 @@ const char *GRFProcessParams(const IniItem *item, uint index) return c->filename; } +static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *list) +{ + IniGroup *group = ini_getgroup(ini, grpname, -1); + IniItem **item; + const GRFConfig *c; + + if (group == NULL) return; + group->item = NULL; + item = &group->item; + + for (c = list; c != NULL; c = c->next) { + char params[512]; + GRFBuildParamList(params, c, lastof(params)); + + *item = ini_item_alloc(group, c->filename, strlen(c->filename)); + (*item)->value = pool_strdup(&ini->pool, params, strlen(params)); + item = &(*item)->next; + } +} + /* Common handler for saving/loading variables to the configuration file */ static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescProcList *proc_list) { @@ -1564,6 +1584,7 @@ void SaveToConfig(void) { IniFile *ini = ini_load(_config_file); HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list); + GRFSaveConfig(ini, "newgrf", _grfconfig_newgame); ini_save(_config_file, ini); ini_free(ini); } |