diff options
author | rubidium <rubidium@openttd.org> | 2008-03-27 15:29:42 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-03-27 15:29:42 +0000 |
commit | 63ab877c2763392008c9446dcd172880f2587745 (patch) | |
tree | 826e422a8c419570d4de6ad81686f1aec0718072 | |
parent | 2405ffd8557370d8af8e34e6b7c14e2b69ac19c1 (diff) | |
download | openttd-63ab877c2763392008c9446dcd172880f2587745.tar.xz |
(svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
-rw-r--r-- | src/road_cmd.cpp | 6 | ||||
-rw-r--r-- | src/settings.cpp | 31 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 60bcf85c2..7906650ab 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -235,9 +235,9 @@ static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, Roa * @li on steep slopes * @li if the bits of the other roadtypes result in another foundation * @li if build on slopes is disabled */ - if (IsSteepSlope(tileh) || IsStraightRoad(other) && - (other & _invalid_tileh_slopes_road[0][tileh & SLOPE_ELEVATED]) != ROAD_NONE || - tileh != SLOPE_FLAT && !_patches.build_on_slopes) { + if (IsSteepSlope(tileh) || (IsStraightRoad(other) && + (other & _invalid_tileh_slopes_road[0][tileh & SLOPE_ELEVATED]) != ROAD_NONE) || + (tileh != SLOPE_FLAT && !_patches.build_on_slopes)) { pieces |= MirrorRoadBits(pieces); } diff --git a/src/settings.cpp b/src/settings.cpp index 2debd509f..46dfd72d9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1753,6 +1753,36 @@ static void NewsDisplaySaveConfig(IniFile *ini, const char *grpname, uint news_d } } +/** + * Save the version of OpenTTD to the ini file. + * @param ini the ini to write to + */ +static void SaveVersionInConfig(IniFile *ini) +{ + extern const char _openttd_revision[]; + extern uint32 _openttd_newgrf_version; + + IniGroup *group = ini_getgroup(ini, "version", -1); + + if (group == NULL) return; + group->item = NULL; + IniItem **item = &group->item; + + char version[9]; + snprintf(version, lengthof(version), "%08X", _openttd_newgrf_version); + + const char *versions[][2] = { + { "version_string", _openttd_revision }, + { "version_number", version } + }; + + for (uint i = 0; i < lengthof(versions); i++) { + *item = ini_item_alloc(group, versions[i][0], strlen(versions[i][0])); + (*item)->value = (char*)pool_strdup(&ini->pool, versions[i][1], strlen(versions[i][1])); + item = &(*item)->next; + } +} + /* Save a GRF configuration to the given group name */ static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *list) { @@ -1817,6 +1847,7 @@ void SaveToConfig() GRFSaveConfig(ini, "newgrf", _grfconfig_newgame); GRFSaveConfig(ini, "newgrf-static", _grfconfig_static); NewsDisplaySaveConfig(ini, "news_display", _news_display_opt); + SaveVersionInConfig(ini); ini_save(_config_file, ini); ini_free(ini); } |