diff options
author | belugas <belugas@openttd.org> | 2007-08-15 00:49:34 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2007-08-15 00:49:34 +0000 |
commit | fafe33cdd2dfe8252501c7a7b824f8c36dd3c3a3 (patch) | |
tree | 3db01e63b9e6b1620a1c3f32e99f699aeea710e0 | |
parent | ba8c451485736d1e60d4f5069bcf913dc281e1d2 (diff) | |
download | openttd-fafe33cdd2dfe8252501c7a7b824f8c36dd3c3a3.tar.xz |
(svn r10903) -Feature: [NewGRF] Add support for variable 44 of Variational Action 2 for Industries
-rw-r--r-- | src/industry.h | 1 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 10 | ||||
-rw-r--r-- | src/newgrf_industries.cpp | 3 | ||||
-rw-r--r-- | src/saveload.cpp | 2 |
4 files changed, 13 insertions, 3 deletions
diff --git a/src/industry.h b/src/industry.h index 408c85860..68c19ebc1 100644 --- a/src/industry.h +++ b/src/industry.h @@ -118,6 +118,7 @@ struct Industry : PoolItem<Industry, IndustryID, &_Industry_pool> { Date construction_date; ///< Date of the construction of the industry uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry + byte selected_layout; ///< Which tile layout was used when creating the industry Industry(TileIndex tile = 0) : xy(tile) {} ~Industry(); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index a592642dd..ce9e15ae8 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1396,7 +1396,7 @@ static bool CheckIfTooCloseToIndustry(TileIndex tile, int type) return true; } -static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, const Town *t, Owner owner) +static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, byte layout, const Town *t, Owner owner) { const IndustrySpec *indspec = GetIndustrySpec(type); uint32 r; @@ -1443,6 +1443,11 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR : (_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY); + /* Adding 1 here makes it conform to specs of var44 of varaction2 for industries + * 0 = created prior of newindustries + * else, chosen layout + 1 */ + i->selected_layout = layout + 1; + if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0; i->prod_level = 0x10; @@ -1514,7 +1519,7 @@ static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, uint if (flags & DC_EXEC) { if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_EXEC, it, type); - DoCreateNewIndustry(i, tile, type, it, t, OWNER_NONE); + DoCreateNewIndustry(i, tile, type, it, itspec_index, t, OWNER_NONE); i_auto_delete.Detach(); } @@ -2017,6 +2022,7 @@ static const SaveLoad _industry_desc[] = { SLE_CONDVAR(Industry, construction_date, SLE_INT32, 70, SL_MAX_VERSION), SLE_CONDVAR(Industry, construction_type, SLE_UINT8, 70, SL_MAX_VERSION), SLE_CONDVAR(Industry, last_cargo_accepted_at, SLE_INT32, 70, SL_MAX_VERSION), + SLE_CONDVAR(Industry, selected_layout, SLE_UINT8, 73, SL_MAX_VERSION), /* reserve extra space in savegame here. (currently 32 bytes) */ SLE_CONDNULL(32, 2, SL_MAX_VERSION), diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index a627376fa..f972e8e8a 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -160,6 +160,9 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par /* Manhattan distance of closes dry/water tile */ case 0x43: return GetClosestWaterDistance(tile, (object->u.industry_location.spec->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0); + /* Layout number */ + case 0x44: return industry->selected_layout; + /* Get industry ID at offset param */ case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->xy), tile, industry); diff --git a/src/saveload.cpp b/src/saveload.cpp index 105be14d9..535b5c9ef 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -30,7 +30,7 @@ #include <setjmp.h> #include <list> -extern const uint16 SAVEGAME_VERSION = 72; +extern const uint16 SAVEGAME_VERSION = 73; uint16 _sl_version; ///< the major savegame version identifier byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! |