@@ -224,24 +224,25 @@ RoadStop *Station::GetPrimaryRoadStop(co
* Called when new facility is built on the station. If it is the first facility
* it initializes also 'xy' and 'random_bits' members
*/
void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
{
if (this->facilities == FACIL_NONE) {
this->MoveSign(facil_xy);
this->random_bits = Random();
}
this->facilities |= new_facility_bit;
this->owner = _current_company;
this->build_date = TimerGameCalendar::date;
SetWindowClassesDirty(WC_VEHICLE_ORDERS);
/**
* Marks the tiles of the station as dirty.
*
* @ingroup dirty
void Station::MarkTilesDirty(bool cargo_change) const
TileIndex tile = this->train_station.tile;
int w, h;
@@ -1686,24 +1686,25 @@ CommandCost RemoveFromRailBaseStation(Ti
for (T *st : affected_stations) {
/* now we need to make the "spanned" area of the railway station smaller
* if we deleted something at the edges.
* we also need to adjust train_tile. */
MakeRailStationAreaSmaller(st);
UpdateStationSignCoord(st);
/* if we deleted the whole station, delete the train facility. */
if (st->train_station.tile == INVALID_TILE) {
st->facilities &= ~FACIL_TRAIN;
SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_TRAINS);
MarkCatchmentTilesDirty();
st->UpdateVirtCoord();
DeleteStationIfEmpty(st);
total_cost.AddCost(quantity * removal_cost);
return total_cost;
@@ -2133,24 +2134,25 @@ static CommandCost RemoveRoadStop(TileIn
if (ret.Failed()) return ret;
const RoadStopSpec *spec = GetRoadStopSpec(tile);
if (flags & DC_EXEC) {
if (*primary_stop == cur_stop) {
/* removed the first stop in the list */
*primary_stop = cur_stop->next;
/* removed the only stop? */
if (*primary_stop == nullptr) {
st->facilities &= (is_truck ? ~FACIL_TRUCK_STOP : ~FACIL_BUS_STOP);
} else {
/* tell the predecessor in the list to skip this stop */
RoadStop *pred = *primary_stop;
while (pred->next != cur_stop) pred = pred->next;
pred->next = cur_stop->next;
/* Update company infrastructure counts. */
for (RoadTramType rtt : _roadtramtypes) {
RoadType rt = GetRoadType(tile, rtt);
UpdateCompanyRoadInfrastructure(rt, GetRoadOwner(tile, rtt), -static_cast<int>(ROAD_STOP_TRACKBIT_FACTOR));
@@ -2565,24 +2567,25 @@ static CommandCost RemoveAirport(TileInd
DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur.base());
/* Clear the persistent storage. */
delete st->airport.psa;
st->rect.AfterRemoveRect(st, st->airport);
st->airport.Clear();
st->facilities &= ~FACIL_AIRPORT;
InvalidateWindowData(WC_STATION_VIEW, st->index, -1);
Company::Get(st->owner)->infrastructure.airport--;
st->AfterStationTileSetChange(false, STATION_AIRPORT);
DeleteNewGRFInspectWindow(GSF_AIRPORTS, st->index);
return cost;
@@ -2818,24 +2821,25 @@ static CommandCost RemoveDock(TileIndex
DoClearSquare(tile1);
MarkTileDirtyByTile(tile1);
MakeWaterKeepingClass(tile2, st->owner);
st->rect.AfterRemoveTile(st, tile1);
st->rect.AfterRemoveTile(st, tile2);
MakeShipStationAreaSmaller(st);
if (st->ship_station.tile == INVALID_TILE) {
st->ship_station.Clear();
st->docking_station.Clear();
st->facilities &= ~FACIL_DOCK;
Company::Get(st->owner)->infrastructure.station -= 2;
st->AfterStationTileSetChange(false, STATION_DOCK);
ClearDockingTilesCheckingNeighbours(tile1);
ClearDockingTilesCheckingNeighbours(tile2);
for (Ship *s : Ship::Iterate()) {
/* Find all ships going to our dock. */
if (s->current_order.GetDestination() != st->index) {
Status change: