Index: src/newgrf_industrytiles.cpp =================================================================== --- src/newgrf_industrytiles.cpp (revision 20915) +++ src/newgrf_industrytiles.cpp (working copy) @@ -258,9 +258,10 @@ * @param itspec_index Layout. * @param initial_random_bits Random bits of industry after construction * @param founder Industry founder + * @param human_placement The object is placed by a human, not randomly. * @return Suceeded or failed command. */ -CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder) +CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder, bool human_placement) { Industry ind; ind.index = INVALID_INDUSTRY; @@ -270,7 +271,7 @@ ind.random = initial_random_bits; ind.founder = founder; - uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, itspec_index, gfx, &ind, ind_tile); + uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, human_placement, itspec_index, gfx, &ind, ind_tile); if (callback_res == CALLBACK_FAILED) { if (!IsSlopeRefused(GetTileSlope(ind_tile, NULL), its->slopes_refused)) return CommandCost(); return_cmd_error(STR_ERROR_SITE_UNSUITABLE); Index: src/newgrf_industries.cpp =================================================================== --- src/newgrf_industries.cpp (revision 20915) +++ src/newgrf_industries.cpp (working copy) @@ -458,9 +458,10 @@ * @param seed Seed for the random generator. * @param initial_random_bits The random bits the industry is going to have after construction. * @param founder Industry founder + * @param human_placement The object is placed by a human, not randomly. * @return Succeeded or failed command. */ -CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder) +CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder, bool human_placement) { const IndustrySpec *indspec = GetIndustrySpec(type); @@ -480,6 +481,7 @@ NewIndustryResolver(&object, tile, &ind, type); object.GetVariable = IndustryLocationGetVariable; object.callback = CBID_INDUSTRY_LOCATION; + object.callback_param1 = human_placement; _industry_creation_random_bits = seed; group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], &object); Index: src/newgrf_industrytiles.h =================================================================== --- src/newgrf_industrytiles.h (revision 20915) +++ src/newgrf_industrytiles.h (working copy) @@ -20,7 +20,7 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds); uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile); -CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder); +CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder, bool human_placement); void AnimateNewIndustryTile(TileIndex tile); bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random()); Index: src/industry_cmd.cpp =================================================================== --- src/industry_cmd.cpp (revision 20915) +++ src/industry_cmd.cpp (working copy) @@ -1311,11 +1311,12 @@ * @param itspec_index The index of the itsepc to build/fund * @param type Type of the industry. * @param initial_random_bits The random bits the industry is going to have after construction. - * @param founder Industry founder + * @param founder Industry founder + * @param human_placement The object is placed by a human, not randomly. * @param [out] custom_shape_check Perform custom check for the site. * @return Failed or succeeded command. */ -static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, uint16 initial_random_bits, Owner founder, bool *custom_shape_check = NULL) +static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, uint16 initial_random_bits, Owner founder, bool human_placement, bool *custom_shape_check = NULL) { bool refused_slope = false; bool custom_shape = false; @@ -1347,7 +1348,7 @@ if (HasBit(its->callback_mask, CBM_INDT_SHAPE_CHECK)) { custom_shape = true; - CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index, initial_random_bits, founder); + CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index, initial_random_bits, founder, human_placement); if (ret.Failed()) return ret; } else { Slope tileh = GetTileSlope(cur_tile, NULL); @@ -1673,12 +1674,13 @@ * @param seed random seed (possibly) used by industries * @param initial_random_bits The random bits the industry is going to have after construction. * @param founder Founder of the industry + * @param human_placement The object is placed by a human, not randomly. * @param [out] ip Pointer to store newly created industry. * @return Succeeded or failed command. * * @post \c *ip contains the newly created industry if all checks are successful and the \a flags request actual creation, else it contains \c NULL afterwards. */ -static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, uint itspec_index, uint32 random_var8f, uint16 random_initial_bits, Owner founder, Industry **ip) +static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, uint itspec_index, uint32 random_var8f, uint16 random_initial_bits, Owner founder, bool human_placement, Industry **ip) { assert(itspec_index < indspec->num_table); const IndustryTileTable *it = indspec->table[itspec_index]; @@ -1687,12 +1689,12 @@ *ip = NULL; SmallVector object_areas(_cleared_object_areas); - CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, founder, &custom_shape_check); + CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, founder, human_placement, &custom_shape_check); _cleared_object_areas = object_areas; if (ret.Failed()) return ret; if (HasBit(GetIndustrySpec(type)->callback_mask, CBM_IND_LOCATION)) { - ret = CheckIfCallBackAllowsCreation(tile, type, itspec_index, random_var8f, random_initial_bits, founder); + ret = CheckIfCallBackAllowsCreation(tile, type, itspec_index, random_var8f, random_initial_bits, founder, human_placement); } else { ret = _check_new_industry_procs[indspec->check_proc](tile); } @@ -1775,7 +1777,7 @@ * because parameter evaluation order is not guaranteed in the c++ standard */ tile = RandomTile(); - CommandCost ret = CreateNewIndustryHelper(tile, it, flags, indspec, RandomRange(indspec->num_table), random_var8f, random_initial_bits, cur_company.GetOriginalValue(), &ind); + CommandCost ret = CreateNewIndustryHelper(tile, it, flags, indspec, RandomRange(indspec->num_table), random_var8f, random_initial_bits, cur_company.GetOriginalValue(), false, &ind); if (ret.Succeeded()) break; } } @@ -1792,11 +1794,11 @@ do { if (--count < 0) return ret; if (--num < 0) num = indspec->num_table - 1; - ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it, random_initial_bits, _current_company); + ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it, random_initial_bits, _current_company, true); _cleared_object_areas = object_areas; } while (ret.Failed()); - ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, random_var8f, random_initial_bits, _current_company, &ind); + ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, random_var8f, random_initial_bits, _current_company, true, &ind); if (ret.Failed()) return ret; } @@ -1824,7 +1826,7 @@ uint32 seed = Random(); uint32 seed2 = Random(); Industry *i = NULL; - CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table), seed, GB(seed2, 0, 16), OWNER_NONE, &i); + CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table), seed, GB(seed2, 0, 16), OWNER_NONE, false, &i); assert(i != NULL || ret.Failed()); return i; } Index: src/newgrf_industries.h =================================================================== --- src/newgrf_industries.h (revision 20915) +++ src/newgrf_industries.h (working copy) @@ -38,7 +38,7 @@ uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile); uint32 GetIndustryIDAtOffset(TileIndex new_tile, const Industry *i, uint32 cur_grfid); void IndustryProductionCallback(Industry *ind, int reason); -CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder); +CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder, bool human_placement); bool CheckIfCallBackAllowsAvailability(IndustryType type, IndustryAvailabilityCallType creation_type); bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type);