561 GetAcceptanceAroundTiles( |
561 GetAcceptanceAroundTiles( |
562 accepts, |
562 accepts, |
563 TileXY(rect.left, rect.bottom), |
563 TileXY(rect.left, rect.bottom), |
564 rect.right - rect.left + 1, |
564 rect.right - rect.left + 1, |
565 rect.top - rect.bottom + 1, |
565 rect.top - rect.bottom + 1, |
566 _patches.modified_catchment ? FindCatchmentRadius(st) : (uint)CA_UNMODIFIED |
566 _settings.station.modified_catchment ? FindCatchmentRadius(st) : (uint)CA_UNMODIFIED |
567 ); |
567 ); |
568 } else { |
568 } else { |
569 memset(accepts, 0, sizeof(accepts)); |
569 memset(accepts, 0, sizeof(accepts)); |
570 } |
570 } |
571 |
571 |
690 * a) the player building is an "old-school" AI |
690 * a) the player building is an "old-school" AI |
691 * -OR- |
691 * -OR- |
692 * b) the build_on_slopes switch is disabled |
692 * b) the build_on_slopes switch is disabled |
693 */ |
693 */ |
694 if (IsSteepSlope(tileh) || |
694 if (IsSteepSlope(tileh) || |
695 ((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) { |
695 ((_is_old_ai_player || !_settings.construction.build_on_slopes) && tileh != SLOPE_FLAT)) { |
696 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
696 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
697 } |
697 } |
698 |
698 |
699 int flat_z = z; |
699 int flat_z = z; |
700 if (tileh != SLOPE_FLAT) { |
700 if (tileh != SLOPE_FLAT) { |
748 uint curh = st->trainst_h; |
748 uint curh = st->trainst_h; |
749 TileIndex tile = fin[0]; |
749 TileIndex tile = fin[0]; |
750 uint w = fin[1]; |
750 uint w = fin[1]; |
751 uint h = fin[2]; |
751 uint h = fin[2]; |
752 |
752 |
753 if (_patches.nonuniform_stations) { |
753 if (_settings.station.nonuniform_stations) { |
754 /* determine new size of train station region.. */ |
754 /* determine new size of train station region.. */ |
755 int x = min(TileX(st->train_tile), TileX(tile)); |
755 int x = min(TileX(st->train_tile), TileX(tile)); |
756 int y = min(TileY(st->train_tile), TileY(tile)); |
756 int y = min(TileY(st->train_tile), TileY(tile)); |
757 curw = max(TileX(st->train_tile) + curw, TileX(tile) + w) - x; |
757 curw = max(TileX(st->train_tile) + curw, TileX(tile) + w) - x; |
758 curh = max(TileY(st->train_tile) + curh, TileY(tile) + h) - y; |
758 curh = max(TileY(st->train_tile) + curh, TileY(tile) + h) - y; |
792 _error_message = STR_NONUNIFORM_STATIONS_DISALLOWED; |
792 _error_message = STR_NONUNIFORM_STATIONS_DISALLOWED; |
793 return false; |
793 return false; |
794 } |
794 } |
795 } |
795 } |
796 /* make sure the final size is not too big. */ |
796 /* make sure the final size is not too big. */ |
797 if (curw > _patches.station_spread || curh > _patches.station_spread) { |
797 if (curw > _settings.station.station_spread || curh > _settings.station.station_spread) { |
798 _error_message = STR_306C_STATION_TOO_SPREAD_OUT; |
798 _error_message = STR_306C_STATION_TOO_SPREAD_OUT; |
799 return false; |
799 return false; |
800 } |
800 } |
801 |
801 |
802 /* now tile contains the new value for st->train_tile |
802 /* now tile contains the new value for st->train_tile |
894 /* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */ |
894 /* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */ |
895 StationID est = INVALID_STATION; |
895 StationID est = INVALID_STATION; |
896 /* If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug |
896 /* If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug |
897 * for detail info, see: |
897 * for detail info, see: |
898 * https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 */ |
898 * https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 */ |
899 CommandCost ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL); |
899 CommandCost ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _settings.station.nonuniform_stations ? &est : NULL); |
900 if (CmdFailed(ret)) return ret; |
900 if (CmdFailed(ret)) return ret; |
901 CommandCost cost(EXPENSES_CONSTRUCTION, ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len); |
901 CommandCost cost(EXPENSES_CONSTRUCTION, ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len); |
902 |
902 |
903 Station *st = NULL; |
903 Station *st = NULL; |
904 bool check_surrounding = true; |
904 bool check_surrounding = true; |
905 |
905 |
906 if (_patches.adjacent_stations) { |
906 if (_settings.station.adjacent_stations) { |
907 if (est != INVALID_STATION) { |
907 if (est != INVALID_STATION) { |
908 if (HasBit(p1, 24)) { |
908 if (HasBit(p1, 24)) { |
909 /* You can't build an adjacent station over the top of one that |
909 /* You can't build an adjacent station over the top of one that |
910 * already exists. */ |
910 * already exists. */ |
911 return_cmd_error(STR_MUST_REMOVE_RAILWAY_STATION_FIRST); |
911 return_cmd_error(STR_MUST_REMOVE_RAILWAY_STATION_FIRST); |
936 if (st->owner != _current_player) |
936 if (st->owner != _current_player) |
937 return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); |
937 return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); |
938 |
938 |
939 if (st->train_tile != 0) { |
939 if (st->train_tile != 0) { |
940 /* check if we want to expanding an already existing station? */ |
940 /* check if we want to expanding an already existing station? */ |
941 if (_is_old_ai_player || !_patches.join_stations) |
941 if (_is_old_ai_player || !_settings.station.join_stations) |
942 return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD); |
942 return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD); |
943 if (!CanExpandRailroadStation(st, finalvalues, axis)) |
943 if (!CanExpandRailroadStation(st, finalvalues, axis)) |
944 return CMD_ERROR; |
944 return CMD_ERROR; |
945 } |
945 } |
946 |
946 |
991 Track track; |
991 Track track; |
992 |
992 |
993 /* Now really clear the land below the station |
993 /* Now really clear the land below the station |
994 * It should never return CMD_ERROR.. but you never know ;) |
994 * It should never return CMD_ERROR.. but you never know ;) |
995 * (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags) */ |
995 * (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags) */ |
996 ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL); |
996 ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _settings.station.nonuniform_stations ? &est : NULL); |
997 if (CmdFailed(ret)) return ret; |
997 if (CmdFailed(ret)) return ret; |
998 |
998 |
999 st->train_tile = finalvalues[0]; |
999 st->train_tile = finalvalues[0]; |
1000 st->AddFacility(FACIL_TRAIN, finalvalues[0]); |
1000 st->AddFacility(FACIL_TRAIN, finalvalues[0]); |
1001 |
1001 |
1160 } |
1160 } |
1161 |
1161 |
1162 /* Do not allow removing from stations if non-uniform stations are not enabled |
1162 /* Do not allow removing from stations if non-uniform stations are not enabled |
1163 * The check must be here to give correct error message |
1163 * The check must be here to give correct error message |
1164 */ |
1164 */ |
1165 if (!_patches.nonuniform_stations) return_cmd_error(STR_NONUNIFORM_STATIONS_DISALLOWED); |
1165 if (!_settings.station.nonuniform_stations) return_cmd_error(STR_NONUNIFORM_STATIONS_DISALLOWED); |
1166 |
1166 |
1167 /* If we reached here, the tile is valid so increase the quantity of tiles we will remove */ |
1167 /* If we reached here, the tile is valid so increase the quantity of tiles we will remove */ |
1168 quantity++; |
1168 quantity++; |
1169 |
1169 |
1170 if (flags & DC_EXEC) { |
1170 if (flags & DC_EXEC) { |
1205 |
1205 |
1206 |
1206 |
1207 static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags) |
1207 static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags) |
1208 { |
1208 { |
1209 /* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */ |
1209 /* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */ |
1210 if (_current_player == OWNER_WATER && _patches.nonuniform_stations) { |
1210 if (_current_player == OWNER_WATER && _settings.station.nonuniform_stations) { |
1211 return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION); |
1211 return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION); |
1212 } |
1212 } |
1213 |
1213 |
1214 /* Current player owns the station? */ |
1214 /* Current player owns the station? */ |
1215 if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR; |
1215 if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR; |
1324 /* there is a road, check if we can build road+tram stop over it */ |
1324 /* there is a road, check if we can build road+tram stop over it */ |
1325 if (HasBit(cur_rts, ROADTYPE_ROAD)) { |
1325 if (HasBit(cur_rts, ROADTYPE_ROAD)) { |
1326 Owner road_owner = GetRoadOwner(tile, ROADTYPE_ROAD); |
1326 Owner road_owner = GetRoadOwner(tile, ROADTYPE_ROAD); |
1327 if (road_owner == OWNER_TOWN) { |
1327 if (road_owner == OWNER_TOWN) { |
1328 town_owned_road = true; |
1328 town_owned_road = true; |
1329 if (!_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD); |
1329 if (!_settings.construction.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD); |
1330 } else { |
1330 } else { |
1331 if (road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR; |
1331 if (road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR; |
1332 } |
1332 } |
1333 } |
1333 } |
1334 |
1334 |
1348 CommandCost cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road); |
1348 CommandCost cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road); |
1349 if (CmdFailed(cost)) return cost; |
1349 if (CmdFailed(cost)) return cost; |
1350 |
1350 |
1351 Station *st = NULL; |
1351 Station *st = NULL; |
1352 |
1352 |
1353 if (!_patches.adjacent_stations || !HasBit(p2, 5)) { |
1353 if (!_settings.station.adjacent_stations || !HasBit(p2, 5)) { |
1354 st = GetStationAround(tile, 1, 1, INVALID_STATION); |
1354 st = GetStationAround(tile, 1, 1, INVALID_STATION); |
1355 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
1355 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
1356 } |
1356 } |
1357 |
1357 |
1358 /* Find a station close to us */ |
1358 /* Find a station close to us */ |
1716 const AirportFTAClass *afc = GetAirport(p1); |
1716 const AirportFTAClass *afc = GetAirport(p1); |
1717 int w = afc->size_x; |
1717 int w = afc->size_x; |
1718 int h = afc->size_y; |
1718 int h = afc->size_y; |
1719 Station *st = NULL; |
1719 Station *st = NULL; |
1720 |
1720 |
1721 if (w > _patches.station_spread || h > _patches.station_spread) { |
1721 if (w > _settings.station.station_spread || h > _settings.station.station_spread) { |
1722 _error_message = STR_306C_STATION_TOO_SPREAD_OUT; |
1722 _error_message = STR_306C_STATION_TOO_SPREAD_OUT; |
1723 return CMD_ERROR; |
1723 return CMD_ERROR; |
1724 } |
1724 } |
1725 |
1725 |
1726 CommandCost cost = CheckFlatLandBelow(tile, w, h, flags, 0, NULL); |
1726 CommandCost cost = CheckFlatLandBelow(tile, w, h, flags, 0, NULL); |
1730 uint newnoise_level = GetAirportNoiseLevelForTown(afc, t->xy, tile); |
1730 uint newnoise_level = GetAirportNoiseLevelForTown(afc, t->xy, tile); |
1731 |
1731 |
1732 /* Check if local auth would allow a new airport */ |
1732 /* Check if local auth would allow a new airport */ |
1733 bool autority_refused; |
1733 bool autority_refused; |
1734 |
1734 |
1735 if (_patches.station_noise_level) { |
1735 if (_settings.economy.station_noise_level) { |
1736 /* do not allow to build a new airport if this raise the town noise over the maximum allowed by town */ |
1736 /* do not allow to build a new airport if this raise the town noise over the maximum allowed by town */ |
1737 autority_refused = (t->noise_reached + newnoise_level) > t->MaxTownNoise(); |
1737 autority_refused = (t->noise_reached + newnoise_level) > t->MaxTownNoise(); |
1738 } else { |
1738 } else { |
1739 uint num = 0; |
1739 uint num = 0; |
1740 const Station *st; |
1740 const Station *st; |
1747 if (autority_refused) { |
1747 if (autority_refused) { |
1748 SetDParam(0, t->index); |
1748 SetDParam(0, t->index); |
1749 return_cmd_error(STR_2035_LOCAL_AUTHORITY_REFUSES); |
1749 return_cmd_error(STR_2035_LOCAL_AUTHORITY_REFUSES); |
1750 } |
1750 } |
1751 |
1751 |
1752 if (!_patches.adjacent_stations || !HasBit(p2, 0)) { |
1752 if (!_settings.station.adjacent_stations || !HasBit(p2, 0)) { |
1753 st = GetStationAround(tile, w, h, INVALID_STATION); |
1753 st = GetStationAround(tile, w, h, INVALID_STATION); |
1754 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
1754 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
1755 } else { |
1755 } else { |
1756 st = NULL; |
1756 st = NULL; |
1757 } |
1757 } |
1822 UpdateStationVirtCoordDirty(st); |
1822 UpdateStationVirtCoordDirty(st); |
1823 UpdateStationAcceptance(st, false); |
1823 UpdateStationAcceptance(st, false); |
1824 InvalidateWindowData(WC_STATION_LIST, st->owner, 0); |
1824 InvalidateWindowData(WC_STATION_LIST, st->owner, 0); |
1825 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); |
1825 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); |
1826 |
1826 |
1827 if (_patches.station_noise_level) { |
1827 if (_settings.economy.station_noise_level) { |
1828 InvalidateWindow(WC_TOWN_VIEW, st->town->index); |
1828 InvalidateWindow(WC_TOWN_VIEW, st->town->index); |
1829 } |
1829 } |
1830 } |
1830 } |
1831 |
1831 |
1832 return cost; |
1832 return cost; |
1879 st->airport_tile = 0; |
1879 st->airport_tile = 0; |
1880 st->facilities &= ~FACIL_AIRPORT; |
1880 st->facilities &= ~FACIL_AIRPORT; |
1881 |
1881 |
1882 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); |
1882 InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES); |
1883 |
1883 |
1884 if (_patches.station_noise_level) { |
1884 if (_settings.economy.station_noise_level) { |
1885 InvalidateWindow(WC_TOWN_VIEW, st->town->index); |
1885 InvalidateWindow(WC_TOWN_VIEW, st->town->index); |
1886 } |
1886 } |
1887 |
1887 |
1888 UpdateStationVirtCoordDirty(st); |
1888 UpdateStationVirtCoordDirty(st); |
1889 DeleteStationIfEmpty(st); |
1889 DeleteStationIfEmpty(st); |
2042 } |
2042 } |
2043 |
2043 |
2044 /* middle */ |
2044 /* middle */ |
2045 Station *st = NULL; |
2045 Station *st = NULL; |
2046 |
2046 |
2047 if (!_patches.adjacent_stations || !HasBit(p1, 0)) { |
2047 if (!_settings.station.adjacent_stations || !HasBit(p1, 0)) { |
2048 st = GetStationAround( |
2048 st = GetStationAround( |
2049 tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]), |
2049 tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]), |
2050 _dock_w_chk[direction], _dock_h_chk[direction], INVALID_STATION); |
2050 _dock_w_chk[direction], _dock_h_chk[direction], INVALID_STATION); |
2051 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
2051 if (st == CHECK_STATIONS_ERR) return CMD_ERROR; |
2052 } |
2052 } |
2772 StationSet station_set; |
2772 StationSet station_set; |
2773 |
2773 |
2774 int w_prod; // width and height of the "producer" of the cargo |
2774 int w_prod; // width and height of the "producer" of the cargo |
2775 int h_prod; |
2775 int h_prod; |
2776 int max_rad; |
2776 int max_rad; |
2777 if (_patches.modified_catchment) { |
2777 if (_settings.station.modified_catchment) { |
2778 w_prod = w; |
2778 w_prod = w; |
2779 h_prod = h; |
2779 h_prod = h; |
2780 w += 2 * MAX_CATCHMENT; |
2780 w += 2 * MAX_CATCHMENT; |
2781 h += 2 * MAX_CATCHMENT; |
2781 h += 2 * MAX_CATCHMENT; |
2782 max_rad = MAX_CATCHMENT; |
2782 max_rad = MAX_CATCHMENT; |
2795 Station *st = GetStationByTile(cur_tile); |
2795 Station *st = GetStationByTile(cur_tile); |
2796 |
2796 |
2797 if (st->IsBuoy()) continue; // bouys don't accept cargo |
2797 if (st->IsBuoy()) continue; // bouys don't accept cargo |
2798 |
2798 |
2799 |
2799 |
2800 if (_patches.modified_catchment) { |
2800 if (_settings.station.modified_catchment) { |
2801 /* min and max coordinates of the producer relative */ |
2801 /* min and max coordinates of the producer relative */ |
2802 const int x_min_prod = max_rad + 1; |
2802 const int x_min_prod = max_rad + 1; |
2803 const int x_max_prod = max_rad + w_prod; |
2803 const int x_max_prod = max_rad + w_prod; |
2804 const int y_min_prod = max_rad + 1; |
2804 const int y_min_prod = max_rad + 1; |
2805 const int y_max_prod = max_rad + h_prod; |
2805 const int y_max_prod = max_rad + h_prod; |
2849 /* Is the station reserved exclusively for somebody else? */ |
2849 /* Is the station reserved exclusively for somebody else? */ |
2850 if (st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue; |
2850 if (st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue; |
2851 |
2851 |
2852 if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore |
2852 if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore |
2853 |
2853 |
2854 if (_patches.selectgoods && st->goods[type].last_speed == 0) continue; // Selectively servicing stations, and not this one |
2854 if (_settings.order.selectgoods && st->goods[type].last_speed == 0) continue; // Selectively servicing stations, and not this one |
2855 |
2855 |
2856 if (IsCargoInClass(type, CC_PASSENGERS)) { |
2856 if (IsCargoInClass(type, CC_PASSENGERS)) { |
2857 if (st->facilities == FACIL_TRUCK_STOP) continue; // passengers are never served by just a truck stop |
2857 if (st->facilities == FACIL_TRUCK_STOP) continue; // passengers are never served by just a truck stop |
2858 } else { |
2858 } else { |
2859 if (st->facilities == FACIL_BUS_STOP) continue; // non-passengers are never served by just a bus stop |
2859 if (st->facilities == FACIL_BUS_STOP) continue; // non-passengers are never served by just a bus stop |
3074 } |
3074 } |
3075 } |
3075 } |
3076 |
3076 |
3077 static CommandCost TerraformTile_Station(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
3077 static CommandCost TerraformTile_Station(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
3078 { |
3078 { |
3079 if (_patches.build_on_slopes && AutoslopeEnabled()) { |
3079 if (_settings.construction.build_on_slopes && AutoslopeEnabled()) { |
3080 /* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here. |
3080 /* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here. |
3081 * TTDP does not call it. |
3081 * TTDP does not call it. |
3082 */ |
3082 */ |
3083 if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) { |
3083 if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) { |
3084 switch (GetStationType(tile)) { |
3084 switch (GetStationType(tile)) { |