1073 } |
1073 } |
1074 |
1074 |
1075 static bool CheckNewIndustry_OilRefinery(TileIndex tile) |
1075 static bool CheckNewIndustry_OilRefinery(TileIndex tile) |
1076 { |
1076 { |
1077 if (_game_mode == GM_EDITOR) return true; |
1077 if (_game_mode == GM_EDITOR) return true; |
1078 if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true; |
1078 if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings.game_creation.oil_refinery_limit) return true; |
1079 |
1079 |
1080 _error_message = STR_483B_CAN_ONLY_BE_POSITIONED; |
1080 _error_message = STR_483B_CAN_ONLY_BE_POSITIONED; |
1081 return false; |
1081 return false; |
1082 } |
1082 } |
1083 |
1083 |
1085 |
1085 |
1086 static bool CheckNewIndustry_OilRig(TileIndex tile) |
1086 static bool CheckNewIndustry_OilRig(TileIndex tile) |
1087 { |
1087 { |
1088 if (_game_mode == GM_EDITOR && _ignore_restrictions) return true; |
1088 if (_game_mode == GM_EDITOR && _ignore_restrictions) return true; |
1089 if (TileHeight(tile) == 0 && |
1089 if (TileHeight(tile) == 0 && |
1090 DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true; |
1090 DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings.game_creation.oil_refinery_limit) return true; |
1091 |
1091 |
1092 _error_message = STR_483B_CAN_ONLY_BE_POSITIONED; |
1092 _error_message = STR_483B_CAN_ONLY_BE_POSITIONED; |
1093 return false; |
1093 return false; |
1094 } |
1094 } |
1095 |
1095 |
1169 const Town *t; |
1169 const Town *t; |
1170 const Industry *i; |
1170 const Industry *i; |
1171 |
1171 |
1172 t = ClosestTownFromTile(tile, (uint)-1); |
1172 t = ClosestTownFromTile(tile, (uint)-1); |
1173 |
1173 |
1174 if (_patches.multiple_industry_per_town) return t; |
1174 if (_settings.economy.multiple_industry_per_town) return t; |
1175 |
1175 |
1176 FOR_ALL_INDUSTRIES(i) { |
1176 FOR_ALL_INDUSTRIES(i) { |
1177 if (i->type == (byte)type && |
1177 if (i->type == (byte)type && |
1178 i->town == t) { |
1178 i->town == t) { |
1179 _error_message = STR_0287_ONLY_ONE_ALLOWED_PER_TOWN; |
1179 _error_message = STR_0287_ONLY_ONE_ALLOWED_PER_TOWN; |
1255 if (custom_shape_check != NULL) *custom_shape_check = custom_shape; |
1255 if (custom_shape_check != NULL) *custom_shape_check = custom_shape; |
1256 |
1256 |
1257 /* It is almost impossible to have a fully flat land in TG, so what we |
1257 /* It is almost impossible to have a fully flat land in TG, so what we |
1258 * do is that we check if we can make the land flat later on. See |
1258 * do is that we check if we can make the land flat later on. See |
1259 * CheckIfCanLevelIndustryPlatform(). */ |
1259 * CheckIfCanLevelIndustryPlatform(). */ |
1260 return !refused_slope || (_patches.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions); |
1260 return !refused_slope || (_settings.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions); |
1261 } |
1261 } |
1262 |
1262 |
1263 static bool CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t) |
1263 static bool CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t) |
1264 { |
1264 { |
1265 if ((GetIndustrySpec(type)->behaviour & INDUSTRYBEH_TOWN1200_MORE) && t->population < 1200) { |
1265 if ((GetIndustrySpec(type)->behaviour & INDUSTRYBEH_TOWN1200_MORE) && t->population < 1200) { |
1385 static bool CheckIfFarEnoughFromIndustry(TileIndex tile, int type) |
1385 static bool CheckIfFarEnoughFromIndustry(TileIndex tile, int type) |
1386 { |
1386 { |
1387 const IndustrySpec *indspec = GetIndustrySpec(type); |
1387 const IndustrySpec *indspec = GetIndustrySpec(type); |
1388 const Industry *i; |
1388 const Industry *i; |
1389 |
1389 |
1390 if (_patches.same_industry_close && indspec->IsRawIndustry()) |
1390 if (_settings.economy.same_industry_close && indspec->IsRawIndustry()) |
1391 /* Allow primary industries to be placed close to any other industry */ |
1391 /* Allow primary industries to be placed close to any other industry */ |
1392 return true; |
1392 return true; |
1393 |
1393 |
1394 FOR_ALL_INDUSTRIES(i) { |
1394 FOR_ALL_INDUSTRIES(i) { |
1395 /* Within 14 tiles from another industry is considered close */ |
1395 /* Within 14 tiles from another industry is considered close */ |
1399 if (in_low_distance && |
1399 if (in_low_distance && |
1400 !indspec->IsRawIndustry() && // not a primary industry? |
1400 !indspec->IsRawIndustry() && // not a primary industry? |
1401 indspec->accepts_cargo[0] == i->accepts_cargo[0] && ( |
1401 indspec->accepts_cargo[0] == i->accepts_cargo[0] && ( |
1402 /* at least one of those options must be true */ |
1402 /* at least one of those options must be true */ |
1403 _game_mode != GM_EDITOR || // editor must not be stopped |
1403 _game_mode != GM_EDITOR || // editor must not be stopped |
1404 !_patches.same_industry_close || |
1404 !_settings.economy.same_industry_close || |
1405 !_patches.multiple_industry_per_town)) { |
1405 !_settings.economy.multiple_industry_per_town)) { |
1406 _error_message = STR_INDUSTRY_TOO_CLOSE; |
1406 _error_message = STR_INDUSTRY_TOO_CLOSE; |
1407 return false; |
1407 return false; |
1408 } |
1408 } |
1409 |
1409 |
1410 /* check if there are any conflicting industry types around */ |
1410 /* check if there are any conflicting industry types around */ |
1447 i->accepts_cargo[2] = indspec->accepts_cargo[2]; |
1447 i->accepts_cargo[2] = indspec->accepts_cargo[2]; |
1448 i->production_rate[0] = indspec->production_rate[0]; |
1448 i->production_rate[0] = indspec->production_rate[0]; |
1449 i->production_rate[1] = indspec->production_rate[1]; |
1449 i->production_rate[1] = indspec->production_rate[1]; |
1450 |
1450 |
1451 /* don't use smooth economy for industries using production related callbacks */ |
1451 /* don't use smooth economy for industries using production related callbacks */ |
1452 if (_patches.smooth_economy && |
1452 if (_settings.economy.smooth_economy && |
1453 !(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks |
1453 !(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks |
1454 !(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE)) // production change callbacks |
1454 !(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE)) // production change callbacks |
1455 ) { |
1455 ) { |
1456 i->production_rate[0] = min((RandomRange(256) + 128) * i->production_rate[0] >> 8 , 255); |
1456 i->production_rate[0] = min((RandomRange(256) + 128) * i->production_rate[0] >> 8 , 255); |
1457 i->production_rate[1] = min((RandomRange(256) + 128) * i->production_rate[1] >> 8 , 255); |
1457 i->production_rate[1] = min((RandomRange(256) + 128) * i->production_rate[1] >> 8 , 255); |
1575 if (!CheckIfCallBackAllowsCreation(tile, type, itspec_index, seed)) return NULL; |
1575 if (!CheckIfCallBackAllowsCreation(tile, type, itspec_index, seed)) return NULL; |
1576 } else { |
1576 } else { |
1577 if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL; |
1577 if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL; |
1578 } |
1578 } |
1579 |
1579 |
1580 if (!custom_shape_check && _patches.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL; |
1580 if (!custom_shape_check && _settings.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL; |
1581 if (!CheckIfFarEnoughFromIndustry(tile, type)) return NULL; |
1581 if (!CheckIfFarEnoughFromIndustry(tile, type)) return NULL; |
1582 |
1582 |
1583 const Town *t = CheckMultipleIndustryInTown(tile, type); |
1583 const Town *t = CheckMultipleIndustryInTown(tile, type); |
1584 if (t == NULL) return NULL; |
1584 if (t == NULL) return NULL; |
1585 |
1585 |
1619 return CMD_ERROR; |
1619 return CMD_ERROR; |
1620 } |
1620 } |
1621 |
1621 |
1622 /* If the patch for raw-material industries is not on, you cannot build raw-material industries. |
1622 /* If the patch for raw-material industries is not on, you cannot build raw-material industries. |
1623 * Raw material industries are industries that do not accept cargo (at least for now) */ |
1623 * Raw material industries are industries that do not accept cargo (at least for now) */ |
1624 if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 0 && indspec->IsRawIndustry()) { |
1624 if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 0 && indspec->IsRawIndustry()) { |
1625 return CMD_ERROR; |
1625 return CMD_ERROR; |
1626 } |
1626 } |
1627 |
1627 |
1628 if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indspec->IsRawIndustry()) { |
1628 if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 2 && indspec->IsRawIndustry()) { |
1629 if (flags & DC_EXEC) { |
1629 if (flags & DC_EXEC) { |
1630 /* Prospecting has a chance to fail, however we cannot guarantee that something can |
1630 /* Prospecting has a chance to fail, however we cannot guarantee that something can |
1631 * be built on the map, so the chance gets lower when the map is fuller, but there |
1631 * be built on the map, so the chance gets lower when the map is fuller, but there |
1632 * is nothing we can really do about that. */ |
1632 * is nothing we can really do about that. */ |
1633 if (Random() <= indspec->prospecting_chance) { |
1633 if (Random() <= indspec->prospecting_chance) { |
2029 bool closeit = false; |
2029 bool closeit = false; |
2030 const IndustrySpec *indspec = GetIndustrySpec(i->type); |
2030 const IndustrySpec *indspec = GetIndustrySpec(i->type); |
2031 bool standard = true; |
2031 bool standard = true; |
2032 bool suppress_message = false; |
2032 bool suppress_message = false; |
2033 /* don't use smooth economy for industries using production related callbacks */ |
2033 /* don't use smooth economy for industries using production related callbacks */ |
2034 bool smooth_economy = _patches.smooth_economy && |
2034 bool smooth_economy = _settings.economy.smooth_economy && |
2035 !(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks |
2035 !(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks |
2036 !(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE)); // production change callbacks |
2036 !(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE)); // production change callbacks |
2037 byte div = 0; |
2037 byte div = 0; |
2038 byte mul = 0; |
2038 byte mul = 0; |
2039 int8 increment = 0; |
2039 int8 increment = 0; |
2255 } |
2255 } |
2256 |
2256 |
2257 Money IndustrySpec::GetConstructionCost() const |
2257 Money IndustrySpec::GetConstructionCost() const |
2258 { |
2258 { |
2259 return (_price.build_industry * |
2259 return (_price.build_industry * |
2260 (_patches.raw_industry_construction == 1 && this->IsRawIndustry() ? |
2260 (_settings.construction.raw_industry_construction == 1 && this->IsRawIndustry() ? |
2261 this->raw_industry_cost_multiplier : |
2261 this->raw_industry_cost_multiplier : |
2262 this->cost_multiplier |
2262 this->cost_multiplier |
2263 )) >> 8; |
2263 )) >> 8; |
2264 } |
2264 } |
2265 |
2265 |