Changeset - r14557:0378093d1b51
[Not reviewed]
master
0 1 0
alberth - 14 years ago 2010-02-15 11:04:27
alberth@openttd.org
(svn r19138) -Codechange: Rename CheckMultipleIndustryInTown() to FindTownForIndustry().
1 file changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1268,25 +1268,31 @@ typedef bool CheckNewIndustryProc(TileIn
 
static CheckNewIndustryProc * const _check_new_industry_procs[CHECK_END] = {
 
	CheckNewIndustry_NULL,        ///< CHECK_NOTHING
 
	CheckNewIndustry_Forest,      ///< CHECK_FOREST
 
	CheckNewIndustry_OilRefinery, ///< CHECK_REFINERY
 
	CheckNewIndustry_Farm,        ///< CHECK_FARM
 
	CheckNewIndustry_Plantation,  ///< CHECK_PLANTATION
 
	CheckNewIndustry_Water,       ///< CHECK_WATER
 
	CheckNewIndustry_Lumbermill,  ///< CHECK_LUMBERMILL
 
	CheckNewIndustry_BubbleGen,   ///< CHECK_BUBBLEGEN
 
	CheckNewIndustry_OilRig,      ///< CHECK_OIL_RIG
 
};
 

	
 
static const Town *CheckMultipleIndustryInTown(TileIndex tile, int type)
 
/** Find a town for the industry, while checking for multiple industries in the same town.
 
 * @param tile Position of the industry to build.
 
 * @param type Industry type.
 
 * @param [out] err_mesg Error message, if any.
 
 * @return Town for the new industry, \c NULL if no good town can be found.
 
 */
 
static const Town *FindTownForIndustry(TileIndex tile, int type)
 
{
 
	const Town *t;
 
	const Industry *i;
 

	
 
	t = ClosestTownFromTile(tile, UINT_MAX);
 

	
 
	if (_settings_game.economy.multiple_industry_per_town) return t;
 

	
 
	FOR_ALL_INDUSTRIES(i) {
 
		if (i->type == (byte)type &&
 
				i->town == t) {
 
			_error_message = STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN;
 
@@ -1692,25 +1698,25 @@ static Industry *CreateNewIndustryHelper
 

	
 
	if (!CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, &custom_shape_check)) return NULL;
 

	
 
	if (HasBit(GetIndustrySpec(type)->callback_mask, CBM_IND_LOCATION)) {
 
		if (!CheckIfCallBackAllowsCreation(tile, type, itspec_index, seed)) return NULL;
 
	} else {
 
		if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL;
 
	}
 

	
 
	if (!custom_shape_check && _settings_game.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, DC_NO_WATER, it, type)) return NULL;
 
	if (!CheckIfFarEnoughFromIndustry(tile, type)) return NULL;
 

	
 
	const Town *t = CheckMultipleIndustryInTown(tile, type);
 
	const Town *t = FindTownForIndustry(tile, type);
 
	if (t == NULL) return NULL;
 

	
 
	if (!CheckIfIndustryIsAllowed(tile, type, t)) return NULL;
 

	
 
	if (!Industry::CanAllocateItem()) return NULL;
 

	
 
	if (flags & DC_EXEC) {
 
		Industry *i = new Industry(tile);
 
		if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_NO_WATER | DC_EXEC, it, type);
 
		DoCreateNewIndustry(i, tile, type, it, itspec_index, t, OWNER_NONE, founder);
 

	
 
		return i;
0 comments (0 inline, 0 general)