1090 { |
1090 { |
1091 int32 bridge_len = GetBridgeLength(tile, tmptile); |
1091 int32 bridge_len = GetBridgeLength(tile, tmptile); |
1092 do { |
1092 do { |
1093 byte bridge_type = RandomRange(MAX_BRIDGES - 1); |
1093 byte bridge_type = RandomRange(MAX_BRIDGES - 1); |
1094 if (CheckBridge_Stuff(bridge_type, bridge_len)) { |
1094 if (CheckBridge_Stuff(bridge_type, bridge_len)) { |
1095 if (!CmdFailed(DoCommand(tile, tmptile, 0x8000 + bridge_type, DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE))) |
1095 if (!CmdFailed(DoCommand(tile, tmptile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE))) |
1096 _grow_town_result = -1; |
1096 _grow_town_result = -1; |
1097 |
1097 |
1098 /* obviously, if building any bridge would fail, there is no need to try other bridge-types */ |
1098 /* obviously, if building any bridge would fail, there is no need to try other bridge-types */ |
1099 return; |
1099 return; |
1100 } |
1100 } |
1663 |
1663 |
1664 /* Generate a list of all possible houses that can be built. */ |
1664 /* Generate a list of all possible houses that can be built. */ |
1665 for (i = 0; i < HOUSE_MAX; i++) { |
1665 for (i = 0; i < HOUSE_MAX; i++) { |
1666 hs = GetHouseSpecs(i); |
1666 hs = GetHouseSpecs(i); |
1667 if ((~hs->building_availability & bitmask) == 0 && hs->enabled) { |
1667 if ((~hs->building_availability & bitmask) == 0 && hs->enabled) { |
1668 if (_have_newhouses) { |
1668 if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) { |
1669 probability_max += hs->probability; |
1669 probability_max += hs->probability; |
1670 cumulative_probs[num] = probability_max; |
1670 cumulative_probs[num] = probability_max; |
1671 } |
1671 } |
1672 houses[num++] = (HouseID)i; |
1672 houses[num++] = (HouseID)i; |
1673 } |
1673 } |
1674 } |
1674 } |
1675 |
1675 |
1676 for (;;) { |
1676 for (;;) { |
1677 if (_have_newhouses) { |
1677 if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) { |
1678 uint r = RandomRange(probability_max); |
1678 uint r = RandomRange(probability_max); |
1679 for (i = 0; i < num; i++) if (cumulative_probs[i] >= r) break; |
1679 for (i = 0; i < num; i++) if (cumulative_probs[i] >= r) break; |
1680 |
1680 |
1681 house = houses[i]; |
1681 house = houses[i]; |
1682 } else { |
1682 } else { |
1683 house = houses[RandomRange(num)]; |
1683 house = houses[RandomRange(num)]; |
1684 } |
1684 } |
1685 |
1685 |
1686 hs = GetHouseSpecs(house); |
1686 hs = GetHouseSpecs(house); |
1687 |
1687 |
1688 if (_have_newhouses) { |
1688 if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) { |
1689 if (hs->override != 0) hs = GetHouseSpecs(hs->override); |
1689 if (hs->override != 0) hs = GetHouseSpecs(hs->override); |
1690 |
1690 |
1691 if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue; |
1691 if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue; |
1692 |
1692 |
1693 if (HASBIT(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) { |
1693 if (HASBIT(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) { |