Index: src/station_cmd.cpp =================================================================== --- src/station_cmd.cpp (wersja 27179) +++ src/station_cmd.cpp (kopia robocza) @@ -1623,11 +1623,12 @@ * Remove a rail station/waypoint * @param st The station/waypoint to remove the rail part from * @param flags operation to perform + * @param removal_cost the cost for removing a tile * @tparam T the type of station to remove * @return cost or failure of operation */ template -CommandCost RemoveRailStation(T *st, DoCommandFlag flags) +CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost) { /* Current company owns the station? */ if (_current_company != OWNER_WATER) { @@ -1644,49 +1645,14 @@ /* clear all areas of the station */ TILE_AREA_LOOP(tile, ta) { /* only remove tiles that are actually train station tiles */ - if (!st->TileBelongsToRailStation(tile)) continue; - - CommandCost ret = EnsureNoVehicleOnGround(tile); - if (ret.Failed()) return ret; - - cost.AddCost(_price[PR_CLEAR_STATION_RAIL]); - if (flags & DC_EXEC) { - /* read variables before the station tile is removed */ - Track track = GetRailStationTrack(tile); - Owner owner = GetTileOwner(tile); // _current_company can be OWNER_WATER - Train *v = NULL; - if (HasStationReservation(tile)) { - v = GetTrainForReservation(tile, track); - if (v != NULL) FreeTrainTrackReservation(v); - } - if (!IsStationTileBlocked(tile)) Company::Get(owner)->infrastructure.rail[GetRailType(tile)]--; - Company::Get(owner)->infrastructure.station--; - DoClearSquare(tile); - DeleteNewGRFInspectWindow(GSF_STATIONS, tile); - AddTrackToSignalBuffer(tile, track, owner); - YapfNotifyTrackLayoutChange(tile, track); - if (v != NULL) TryPathReserve(v, true); + if (st->TileBelongsToRailStation(tile)) { + SmallVector affected_stations; // dummy + CommandCost ret = RemoveFromRailBaseStation(TileArea(tile, 1, 1), affected_stations, flags, removal_cost, false); + if (ret.Failed()) return ret; + cost.AddCost(ret); } } - if (flags & DC_EXEC) { - st->rect.AfterRemoveRect(st, st->train_station); - - st->train_station.Clear(); - - st->facilities &= ~FACIL_TRAIN; - - free(st->speclist); - st->num_specs = 0; - st->speclist = NULL; - st->cached_anim_triggers = 0; - - DirtyCompanyInfrastructureWindows(st->owner); - SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_TRAINS); - st->UpdateVirtCoord(); - DeleteStationIfEmpty(st); - } - return cost; } @@ -1704,7 +1670,7 @@ } Station *st = Station::GetByTile(tile); - CommandCost cost = RemoveRailStation(st, flags); + CommandCost cost = RemoveRailStation(st, flags, _price[PR_CLEAR_STATION_RAIL]); if (flags & DC_EXEC) st->RecomputeIndustriesNear(); @@ -1724,7 +1690,7 @@ return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAIL_WAYPOINT); } - return RemoveRailStation(Waypoint::GetByTile(tile), flags); + return RemoveRailStation(Waypoint::GetByTile(tile), flags, _price[PR_CLEAR_WAYPOINT_RAIL]); }