|
@@ -1318,16 +1318,17 @@ bool IsSlopeRefused(Slope current, Slope
|
|
|
/** Are the tiles of the industry free?
|
|
|
* @param tile Position to check.
|
|
|
* @param it Industry tiles table.
|
|
|
* @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 [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, 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 *custom_shape_check = NULL)
|
|
|
{
|
|
|
bool refused_slope = false;
|
|
|
bool custom_shape = false;
|
|
|
|
|
|
do {
|
|
|
IndustryGfx gfx = GetTranslatedIndustryTileID(it->gfx);
|
|
@@ -1353,13 +1354,13 @@ static CommandCost CheckIfIndustryTilesA
|
|
|
|
|
|
/* Perform land/water check if not disabled */
|
|
|
if (!HasBit(its->slopes_refused, 5) && (IsWaterTile(cur_tile) == !(ind_behav & INDUSTRYBEH_BUILT_ONWATER))) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
|
|
|
|
|
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);
|
|
|
CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index, initial_random_bits, founder);
|
|
|
if (ret.Failed()) return ret;
|
|
|
} else {
|
|
|
Slope tileh = GetTileSlope(cur_tile, NULL);
|
|
|
refused_slope |= IsSlopeRefused(tileh, its->slopes_refused);
|
|
|
}
|
|
|
|
|
@@ -1705,17 +1706,17 @@ static CommandCost CreateNewIndustryHelp
|
|
|
assert(itspec_index < indspec->num_table);
|
|
|
const IndustryTileTable *it = indspec->table[itspec_index];
|
|
|
bool custom_shape_check = false;
|
|
|
|
|
|
*ip = NULL;
|
|
|
|
|
|
CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, &custom_shape_check);
|
|
|
CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, founder, &custom_shape_check);
|
|
|
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);
|
|
|
ret = CheckIfCallBackAllowsCreation(tile, type, itspec_index, random_var8f, random_initial_bits, founder);
|
|
|
} else {
|
|
|
ret = _check_new_industry_procs[indspec->check_proc](tile);
|
|
|
}
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
|
|
if (!custom_shape_check && _settings_game.game_creation.land_generator == LG_TERRAGENESIS && _generating_world &&
|
|
@@ -1808,13 +1809,13 @@ CommandCost CmdBuildIndustry(TileIndex t
|
|
|
if (num >= count) return CMD_ERROR;
|
|
|
|
|
|
CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
|
|
|
do {
|
|
|
if (--count < 0) return ret;
|
|
|
if (--num < 0) num = indspec->num_table - 1;
|
|
|
ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it, random_initial_bits);
|
|
|
ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it, random_initial_bits, _current_company);
|
|
|
} while (ret.Failed());
|
|
|
|
|
|
ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, random_var8f, random_initial_bits, _current_company, &ind);
|
|
|
if (ret.Failed()) return ret;
|
|
|
}
|
|
|
|