diff options
author | smatz <smatz@openttd.org> | 2009-02-04 20:17:25 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-02-04 20:17:25 +0000 |
commit | 832e392855c652766de1bdd15851f81d651eb9d6 (patch) | |
tree | 5a4050971fc92ae40d7612fdd0947e42eb1ae263 /src/saveload | |
parent | 030984a763c0111ba17c8907a22cffe0eeb05f68 (diff) | |
download | openttd-832e392855c652766de1bdd15851f81d651eb9d6.tar.xz |
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
-Fix: use a flag instead of TL_NO_ROADS to forbid towns to build roads. The flag is ignored during world generation, so there won't be 'ghost' towns anymore
-Feature: town layout is now stored per town, so it is possible to (manually) set different layout for each town
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 32 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 2 | ||||
-rw-r--r-- | src/saveload/saveload_internal.h | 1 | ||||
-rw-r--r-- | src/saveload/town_sl.cpp | 7 |
4 files changed, 32 insertions, 10 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 2b34622fc..f34d5fda0 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -482,8 +482,6 @@ bool AfterLoadGame() /* Update all waypoints */ if (CheckSavegameVersion(12)) FixOldWaypoints(); - AfterLoadTown(); - /* make sure there is a town in the game */ if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) { SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); @@ -1694,6 +1692,36 @@ bool AfterLoadGame() } } + if (CheckSavegameVersion(113)) { + /* allow_town_roads is added, set it if town_layout wasn't TL_NO_ROADS */ + if (_settings_game.economy.town_layout == 0) { // was TL_NO_ROADS + _settings_game.economy.allow_town_roads = false; + _settings_game.economy.town_layout = TL_BETTER_ROADS; + } else { + _settings_game.economy.allow_town_roads = true; + _settings_game.economy.town_layout = _settings_game.economy.town_layout - 1; + } + + /* Initialize layout of all towns. Older versions were using different + * generator for random town layout, use it if needed. */ + Town *t; + FOR_ALL_TOWNS(t) { + if (_settings_game.economy.town_layout != TL_RANDOM) { + t->layout = _settings_game.economy.town_layout; + continue; + } + + /* Use old layout randomizer code */ + byte layout = TileHash(TileX(t->xy), TileY(t->xy)) % 6; + switch (layout) { + default: break; + case 5: layout = 1; break; + case 0: layout = 2; break; + } + t->layout = layout - 1; + } + } + GamelogPrintDebug(1); bool ret = InitializeWindowsAndCaches(); diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 43b0616f5..2044eb9b4 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -38,7 +38,7 @@ #include "saveload_internal.h" -extern const uint16 SAVEGAME_VERSION = 112; +extern const uint16 SAVEGAME_VERSION = 113; SavegameType _savegame_type; ///< type of savegame we are loading diff --git a/src/saveload/saveload_internal.h b/src/saveload/saveload_internal.h index d364bebab..19a5b5cbf 100644 --- a/src/saveload/saveload_internal.h +++ b/src/saveload/saveload_internal.h @@ -21,7 +21,6 @@ void FixOldWaypoints(); void AfterLoadWaypoints(); void AfterLoadVehicles(bool part_of_load); void AfterLoadStations(); -void AfterLoadTown(); void UpdateHousesAndTowns(); void UpdateOldAircraft(); diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index c1b59876e..2b25356a7 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -127,6 +127,7 @@ static const SaveLoad _town_desc[] = { SLE_CONDVAR(Town, exclusive_counter, SLE_UINT8, 2, SL_MAX_VERSION), SLE_CONDVAR(Town, larger_town, SLE_BOOL, 56, SL_MAX_VERSION), + SLE_CONDVAR(Town, layout, SLE_UINT8, 113, SL_MAX_VERSION), /* reserve extra space in savegame here. (currently 30 bytes) */ SLE_CONDNULL(30, 2, SL_MAX_VERSION), @@ -195,12 +196,6 @@ static void Load_TOWN() _cur_town_ctr = 0; } -void AfterLoadTown() -{ - Town *t; - FOR_ALL_TOWNS(t) t->InitializeLayout(); -} - extern const ChunkHandler _town_chunk_handlers[] = { { 'HIDS', Save_HOUSEIDS, Load_HOUSEIDS, CH_ARRAY }, { 'CITY', Save_TOWN, Load_TOWN, CH_ARRAY | CH_LAST}, |