equal
deleted
inserted
replaced
1620 return false; |
1620 return false; |
1621 |
1621 |
1622 return CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR)); |
1622 return CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR)); |
1623 } |
1623 } |
1624 |
1624 |
1625 |
1625 /** Returns the bit corresponding to the town zone of the specified tile |
1626 uint GetTownRadiusGroup(const Town* t, TileIndex tile) |
1626 * @param t Town on which radius is to be found |
|
1627 * @param tile TileIndex where radius needs to be found |
|
1628 * @return the bit position of the given zone, as defined in HouseZones |
|
1629 */ |
|
1630 HouseZonesBits GetTownRadiusGroup(const Town* t, TileIndex tile) |
1627 { |
1631 { |
1628 uint dist = DistanceSquare(tile, t->xy); |
1632 uint dist = DistanceSquare(tile, t->xy); |
1629 uint smallest; |
1633 HouseZonesBits smallest; |
1630 uint i; |
1634 uint i; |
1631 |
1635 |
1632 if (t->fund_buildings_months && dist <= 25) return 4; |
1636 if (t->fund_buildings_months && dist <= 25) return HZB_TOWN_CENTRE; |
1633 |
1637 |
1634 smallest = 0; |
1638 smallest = HZB_TOWN_EDGE; |
1635 for (i = 0; i != lengthof(t->radius); i++) { |
1639 for (i = 0; i != lengthof(t->radius); i++) { |
1636 if (dist < t->radius[i]) smallest = i; |
1640 if (dist < t->radius[i]) smallest = (HouseZonesBits)i; |
1637 } |
1641 } |
1638 |
1642 |
1639 return smallest; |
1643 return smallest; |
1640 } |
1644 } |
1641 |
1645 |
1675 HouseSpec *hs; |
1679 HouseSpec *hs; |
1676 |
1680 |
1677 /* Above snow? */ |
1681 /* Above snow? */ |
1678 slope = GetTileSlope(tile, &z); |
1682 slope = GetTileSlope(tile, &z); |
1679 |
1683 |
1680 /* Get the town zone type */ |
1684 /* Get the town zone type of the current tile, as well as the climate. |
|
1685 * This will allow to easily compare with the specs of the new house to build */ |
1681 { |
1686 { |
1682 uint rad = GetTownRadiusGroup(t, tile); |
1687 HouseZonesBits rad = GetTownRadiusGroup(t, tile); |
1683 |
1688 |
1684 int land = _opt.landscape; |
1689 int land = _opt.landscape; |
1685 if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1; |
1690 if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1; |
1686 |
1691 |
1687 bitmask = (1 << rad) + (1 << (land + 12)); |
1692 bitmask = (1 << rad) + (1 << (land + 12)); |
1697 uint probability_max = 0; |
1702 uint probability_max = 0; |
1698 |
1703 |
1699 /* Generate a list of all possible houses that can be built. */ |
1704 /* Generate a list of all possible houses that can be built. */ |
1700 for (i = 0; i < HOUSE_MAX; i++) { |
1705 for (i = 0; i < HOUSE_MAX; i++) { |
1701 hs = GetHouseSpecs(i); |
1706 hs = GetHouseSpecs(i); |
|
1707 /* Verify that the candidate house spec matches the current tile status */ |
1702 if ((~hs->building_availability & bitmask) == 0 && hs->enabled) { |
1708 if ((~hs->building_availability & bitmask) == 0 && hs->enabled) { |
1703 if (_loaded_newgrf_features.has_newhouses) { |
1709 if (_loaded_newgrf_features.has_newhouses) { |
1704 probability_max += hs->probability; |
1710 probability_max += hs->probability; |
1705 cumulative_probs[num] = probability_max; |
1711 cumulative_probs[num] = probability_max; |
1706 } |
1712 } |