diff options
author | rubidium <rubidium@openttd.org> | 2010-08-11 18:57:48 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-08-11 18:57:48 +0000 |
commit | d6004d17d4f7616cff4f905ada03fa7d1626aa0e (patch) | |
tree | a2c1e4382dc2455ca2f605829572657b156d40be /src/saveload/town_sl.cpp | |
parent | e0a3a0fd54cff08f8d721dded1dc9651296de1d2 (diff) | |
download | openttd-d6004d17d4f7616cff4f905ada03fa7d1626aa0e.tar.xz |
(svn r20449) -Codechange: unduplicate saving/loading of NewGRF ID + local id -> OpenTTD spec mappings
Diffstat (limited to 'src/saveload/town_sl.cpp')
-rw-r--r-- | src/saveload/town_sl.cpp | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index bc95ba8ab..af255ee91 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -11,10 +11,10 @@ #include "../stdafx.h" #include "../newgrf_house.h" -#include "../newgrf_commons.h" #include "../town.h" #include "saveload.h" +#include "newgrf_sl.h" /** * Check and update town and house values. @@ -139,36 +139,14 @@ static const SaveLoad _town_desc[] = { SLE_END() }; -/* Save and load the mapping between the house id on the map, and the grf file - * it came from. */ -static const SaveLoad _house_id_mapping_desc[] = { - SLE_VAR(EntityIDMapping, grfid, SLE_UINT32), - SLE_VAR(EntityIDMapping, entity_id, SLE_UINT8), - SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8), - SLE_END() -}; - -static void Save_HOUSEIDS() +static void Save_HIDS() { - uint j = _house_mngr.GetMaxMapping(); - - for (uint i = 0; i < j; i++) { - SlSetArrayIndex(i); - SlObject(&_house_mngr.mapping_ID[i], _house_id_mapping_desc); - } + Save_NewGRFMapping(_house_mngr); } -static void Load_HOUSEIDS() +static void Load_HIDS() { - int index; - - _house_mngr.ResetMapping(); - uint max_id = _house_mngr.GetMaxMapping(); - - while ((index = SlIterateArray()) != -1) { - if ((uint)index >= max_id) break; - SlObject(&_house_mngr.mapping_ID[index], _house_id_mapping_desc); - } + Load_NewGRFMapping(_house_mngr); } static void Save_TOWN() @@ -192,6 +170,6 @@ static void Load_TOWN() } extern const ChunkHandler _town_chunk_handlers[] = { - { 'HIDS', Save_HOUSEIDS, Load_HOUSEIDS, NULL, NULL, CH_ARRAY }, - { 'CITY', Save_TOWN, Load_TOWN, NULL, NULL, CH_ARRAY | CH_LAST}, + { 'HIDS', Save_HIDS, Load_HIDS, NULL, NULL, CH_ARRAY }, + { 'CITY', Save_TOWN, Load_TOWN, NULL, NULL, CH_ARRAY | CH_LAST}, }; |