Mercurial > hg > openttd
changeset 15896:2338e84ca812 draft
(svn r20579) -Change (r1579): Allow removing of buoys if they are only used by own vehicles.
author | frosch <frosch@openttd.org> |
---|---|
date | Fri, 20 Aug 2010 12:50:59 +0000 |
parents | ca6b6c494ae8 |
children | d613f94dd4ab |
files | src/lang/english.txt src/station_cmd.cpp src/station_func.h src/station_gui.cpp src/waypoint_cmd.cpp |
diffstat | 5 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3548,7 +3548,7 @@ STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT :{WHITE}Can't remove train waypoint here... STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST :{WHITE}Must remove rail waypoint first STR_ERROR_BUOY_IN_THE_WAY :{WHITE}... buoy in the way -STR_ERROR_BUOY_IS_IN_USE :{WHITE}... buoy is in use! +STR_ERROR_BUOY_IS_IN_USE :{WHITE}... buoy is in use by another company! # Depot related errors STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT :{WHITE}Can't build train depot here...
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2331,15 +2331,15 @@ /** * Tests whether the company's vehicles have this station in orders - * When company == INVALID_COMPANY, then check all vehicles * @param station station ID - * @param company company ID, INVALID_COMPANY to disable the check + * @param include_company If true only check vehicles of \a company, if false only check vehicles of other companies + * @param company company ID */ -bool HasStationInUse(StationID station, CompanyID company) +bool HasStationInUse(StationID station, bool include_company, CompanyID company) { const Vehicle *v; FOR_ALL_VEHICLES(v) { - if (company == INVALID_COMPANY || v->owner == company) { + if ((v->owner == company) == include_company) { const Order *order; FOR_VEHICLE_ORDERS(v, order) { if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
--- a/src/station_func.h +++ b/src/station_func.h @@ -34,7 +34,7 @@ const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx); void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image); -bool HasStationInUse(StationID station, CompanyID company); +bool HasStationInUse(StationID station, bool include_company, CompanyID company); RoadStop *GetRoadStopByTile(TileIndex tile, RoadStopType type); uint GetNumRoadStops(const Station *st, RoadStopType type);
--- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -234,7 +234,7 @@ const Station *st; FOR_ALL_STATIONS(st) { - if (st->owner == owner || (st->owner == OWNER_NONE && HasStationInUse(st->index, owner))) { + if (st->owner == owner || (st->owner == OWNER_NONE && HasStationInUse(st->index, true, owner))) { if (this->facilities & st->facilities) { // only stations with selected facilities int num_waiting_cargo = 0; for (CargoID j = 0; j < NUM_CARGO; j++) {
--- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -333,7 +333,7 @@ Waypoint *wp = Waypoint::GetByTile(tile); - if (HasStationInUse(wp->index, INVALID_COMPANY)) return_cmd_error(STR_ERROR_BUOY_IS_IN_USE); + if (HasStationInUse(wp->index, false, _current_company)) return_cmd_error(STR_ERROR_BUOY_IS_IN_USE); /* remove the buoy if there is a ship on tile when company goes bankrupt... */ if (!(flags & DC_BANKRUPT)) { CommandCost ret = EnsureNoVehicleOnGround(tile);