148
148
if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_EXTRACTIVE) == 0) return false;
150
150
for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
151
/* The industry extracts something non-liquid, i.e. no oil or plastic, so it is a mine */
152
if (ind->produced_cargo[i] != CT_INVALID && (GetCargo(ind->produced_cargo[i])->classes & CC_LIQUID) == 0) return true;
151
/* The industry extracts something non-liquid, i.e. no oil or plastic, so it is a mine.
152
* Also the production of passengers and mail is ignored. */
153
if (ind->produced_cargo[i] != CT_INVALID &&
154
(GetCargo(ind->produced_cargo[i])->classes & (CC_LIQUID | CC_PASSENGERS | CC_MAIL)) == 0) {
537
static inline void MergePoint(Rect *rect, TileIndex tile)
542
if (rect->left > x) rect->left = x;
543
if (rect->bottom > y) rect->bottom = y;
544
if (rect->right < x) rect->right = x;
545
if (rect->top < y) rect->top = y;
548
541
/** Update the acceptance for a station.
549
542
* @param st Station to update
550
543
* @param show_msg controls whether to display a message that acceptance was changed.
554
547
/* Don't update acceptance for a buoy */
555
548
if (st->IsBuoy()) return;
558
rect.left = MapSizeX();
559
rect.bottom = MapSizeY();
563
550
/* old accepted goods types */
564
551
uint old_acc = GetAcceptanceMask(st);
566
/* Put all the tiles that span an area in the table. */
567
if (st->train_tile != INVALID_TILE) {
568
MergePoint(&rect, st->train_tile);
569
MergePoint(&rect, st->train_tile + TileDiffXY(st->trainst_w - 1, st->trainst_h - 1));
572
if (st->airport_tile != INVALID_TILE) {
573
const AirportFTAClass *afc = st->Airport();
575
MergePoint(&rect, st->airport_tile);
576
MergePoint(&rect, st->airport_tile + TileDiffXY(afc->size_x - 1, afc->size_y - 1));
579
if (st->dock_tile != INVALID_TILE) {
580
MergePoint(&rect, st->dock_tile);
581
if (IsDockTile(st->dock_tile)) {
582
MergePoint(&rect, st->dock_tile + TileOffsByDiagDir(GetDockDirection(st->dock_tile)));
586
for (const RoadStop *rs = st->bus_stops; rs != NULL; rs = rs->next) {
587
MergePoint(&rect, rs->xy);
590
for (const RoadStop *rs = st->truck_stops; rs != NULL; rs = rs->next) {
591
MergePoint(&rect, rs->xy);
594
553
/* And retrieve the acceptance. */
595
554
AcceptedCargo accepts;
596
assert((rect.right >= rect.left) == !st->rect.IsEmpty());
597
if (rect.right >= rect.left) {
598
assert(rect.left == st->rect.left);
599
assert(rect.top == st->rect.bottom);
600
assert(rect.right == st->rect.right);
601
assert(rect.bottom == st->rect.top);
555
if (!st->rect.IsEmpty()) {
602
556
GetAcceptanceAroundTiles(
604
TileXY(rect.left, rect.bottom),
605
rect.right - rect.left + 1,
606
rect.top - rect.bottom + 1,
558
TileXY(st->rect.left, st->rect.top),
559
st->rect.right - st->rect.left + 1,
560
st->rect.bottom - st->rect.top + 1,
607
561
st->GetCatchmentRadius()
924
878
StationID station_to_join = GB(p2, 16, 16);
879
bool reuse = (station_to_join != NEW_STATION);
880
if (!reuse) station_to_join = INVALID_STATION;
925
881
bool distant_join = (station_to_join != INVALID_STATION);
927
883
if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
1403
1359
bool build_over_road = is_drive_through && IsNormalRoadTile(tile);
1404
1360
RoadTypes rts = (RoadTypes)GB(p2, 2, 2);
1405
1361
StationID station_to_join = GB(p2, 16, 16);
1362
bool reuse = (station_to_join != NEW_STATION);
1363
if (!reuse) station_to_join = INVALID_STATION;
1406
1364
bool distant_join = (station_to_join != INVALID_STATION);
1407
1365
Owner tram_owner = _current_company;
1408
1366
Owner road_owner = _current_company;
1470
1428
if (st == NULL && distant_join) st = GetStation(station_to_join);
1472
1430
/* Find a deleted station close to us */
1473
if (st == NULL) st = GetClosestDeletedStation(tile);
1431
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
1475
1433
/* give us a road stop in the list, and check if something went wrong */
1476
1434
if (!RoadStop::CanAllocateItem()) return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
1856
1814
bool airport_upgrade = true;
1857
1815
StationID station_to_join = GB(p2, 16, 16);
1816
bool reuse = (station_to_join != NEW_STATION);
1817
if (!reuse) station_to_join = INVALID_STATION;
1858
1818
bool distant_join = (station_to_join != INVALID_STATION);
1860
1820
if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
1862
1822
/* Check if a valid, buildable airport was chosen for construction */
1863
if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
1823
if (p1 >= lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
1865
1825
if (!CheckIfAuthorityAllowsNewStation(tile, flags)) {
1866
1826
return CMD_ERROR;
2127
2087
static CommandCost RemoveBuoy(Station *st, DoCommandFlag flags)
2129
/* XXX: strange stuff */
2130
if (!IsValidCompanyID(_current_company)) return_cmd_error(INVALID_STRING_ID);
2089
/* XXX: strange stuff, allow clearing as invalid company when clearing landscape */
2090
if (!IsValidCompanyID(_current_company) && !(flags & DC_BANKRUPT)) return_cmd_error(INVALID_STRING_ID);
2132
2092
TileIndex tile = st->dock_tile;
2175
2135
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
2177
2137
StationID station_to_join = GB(p2, 16, 16);
2138
bool reuse = (station_to_join != NEW_STATION);
2139
if (!reuse) station_to_join = INVALID_STATION;
2178
2140
bool distant_join = (station_to_join != INVALID_STATION);
2180
2142
if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
2727
2689
return VETSB_CONTINUE;
2730
/* this function is called for one station each tick */
2693
* This function is called for each station once every 250 ticks.
2694
* Not all stations will get the tick at the same time.
2695
* @param st the station receiving the tick.
2731
2697
static void StationHandleBigTick(Station *st)
2733
2699
UpdateStationAcceptance(st, true);
3002
2964
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount)
2966
/* Return if nothing to do. Also the rounding below fails for 0. */
2967
if (amount == 0) return 0;
3004
2969
Station *st1 = NULL; // Station with best rating
3005
2970
Station *st2 = NULL; // Second best station
3006
2971
uint best_rating1 = 0; // rating of st1
3236
3201
/* Clean the roadstop pool and create 1 block in it */
3237
3202
_RoadStop_pool.CleanPool();
3238
3203
_RoadStop_pool.AddBlockToPool();
3240
_station_tick_ctr = 0;
3243
3206
static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)