1334 size_y = max_y + 4; |
1334 size_y = max_y + 4; |
1335 |
1335 |
1336 /* Check if we don't leave the map */ |
1336 /* Check if we don't leave the map */ |
1337 if (TileX(cur_tile) == 0 || TileY(cur_tile) == 0 || TileX(cur_tile) + size_x >= MapMaxX() || TileY(cur_tile) + size_y >= MapMaxY()) return false; |
1337 if (TileX(cur_tile) == 0 || TileY(cur_tile) == 0 || TileX(cur_tile) + size_x >= MapMaxX() || TileY(cur_tile) + size_y >= MapMaxY()) return false; |
1338 |
1338 |
|
1339 /* _current_player is OWNER_NONE for randomly generated industries and in editor, or the player who funded or prospected the industry. |
|
1340 * Perform terraforming as OWNER_TOWN to disable autoslope. */ |
|
1341 PlayerID old_player = _current_player; |
|
1342 _current_player = OWNER_TOWN; |
|
1343 |
1339 BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) { |
1344 BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) { |
1340 curh = TileHeight(tile_walk); |
1345 curh = TileHeight(tile_walk); |
1341 if (curh != h) { |
1346 if (curh != h) { |
1342 /* This tile needs terraforming. Check if we can do that without |
1347 /* This tile needs terraforming. Check if we can do that without |
1343 * damaging the surroundings too much. */ |
1348 * damaging the surroundings too much. */ |
1344 if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) return false; |
1349 if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) { |
|
1350 _current_player = old_player; |
|
1351 return false; |
|
1352 } |
1345 /* This is not 100% correct check, but the best we can do without modifying the map. |
1353 /* This is not 100% correct check, but the best we can do without modifying the map. |
1346 * What is missing, is if the difference in height is more than 1.. */ |
1354 * What is missing, is if the difference in height is more than 1.. */ |
1347 if (CmdFailed(DoCommand(tile_walk, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND))) return false; |
1355 if (CmdFailed(DoCommand(tile_walk, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND))) { |
|
1356 _current_player = old_player; |
|
1357 return false; |
|
1358 } |
1348 } |
1359 } |
1349 } END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) |
1360 } END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) |
1350 |
1361 |
1351 if (flags & DC_EXEC) { |
1362 if (flags & DC_EXEC) { |
1352 /* Terraform the land under the industry */ |
1363 /* Terraform the land under the industry */ |