mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r10903) -Feature: [NewGRF] Add support for variable 44 of Variational Action 2 for Industries
This commit is contained in:
parent
ba8c451485
commit
fafe33cdd2
|
@ -118,6 +118,7 @@ struct Industry : PoolItem<Industry, IndustryID, &_Industry_pool> {
|
||||||
Date construction_date; ///< Date of the construction of the industry
|
Date construction_date; ///< Date of the construction of the industry
|
||||||
uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
|
uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
|
||||||
Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry
|
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(TileIndex tile = 0) : xy(tile) {}
|
||||||
~Industry();
|
~Industry();
|
||||||
|
|
|
@ -1396,7 +1396,7 @@ static bool CheckIfTooCloseToIndustry(TileIndex tile, int type)
|
||||||
return true;
|
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);
|
const IndustrySpec *indspec = GetIndustrySpec(type);
|
||||||
uint32 r;
|
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 :
|
i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR :
|
||||||
(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY);
|
(_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;
|
if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0;
|
||||||
|
|
||||||
i->prod_level = 0x10;
|
i->prod_level = 0x10;
|
||||||
|
@ -1514,7 +1519,7 @@ static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, uint
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_EXEC, it, type);
|
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();
|
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_date, SLE_INT32, 70, SL_MAX_VERSION),
|
||||||
SLE_CONDVAR(Industry, construction_type, SLE_UINT8, 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, 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) */
|
/* reserve extra space in savegame here. (currently 32 bytes) */
|
||||||
SLE_CONDNULL(32, 2, SL_MAX_VERSION),
|
SLE_CONDNULL(32, 2, SL_MAX_VERSION),
|
||||||
|
|
|
@ -160,6 +160,9 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
|
||||||
/* Manhattan distance of closes dry/water tile */
|
/* Manhattan distance of closes dry/water tile */
|
||||||
case 0x43: return GetClosestWaterDistance(tile, (object->u.industry_location.spec->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0);
|
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 */
|
/* Get industry ID at offset param */
|
||||||
case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->xy), tile, industry);
|
case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->xy), tile, industry);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
extern const uint16 SAVEGAME_VERSION = 72;
|
extern const uint16 SAVEGAME_VERSION = 73;
|
||||||
uint16 _sl_version; ///< the major savegame version identifier
|
uint16 _sl_version; ///< the major savegame version identifier
|
||||||
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
|
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue