Mercurial > hg > openttd
changeset 7445:3fbe065e867c draft
(svn r10903) -Feature: [NewGRF] Add support for variable 44 of Variational Action 2 for Industries
author | belugas <belugas@openttd.org> |
---|---|
date | Wed, 15 Aug 2007 00:49:34 +0000 |
parents | e9516aa13439 |
children | d081d27cd66d |
files | src/industry.h src/industry_cmd.cpp src/newgrf_industries.cpp src/saveload.cpp |
diffstat | 4 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/industry.h +++ b/src/industry.h @@ -118,6 +118,7 @@ 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();
--- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1396,7 +1396,7 @@ 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 @@ 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 @@ 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 @@ 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),
--- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -160,6 +160,9 @@ /* 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);
--- 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!