mirror of https://github.com/OpenTTD/OpenTTD
(svn r20579) -Change (r1579): Allow removing of buoys if they are only used by own vehicles.
parent
de973a4d60
commit
03ab158935
|
@ -3548,7 +3548,7 @@ STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME :{WHITE}Can't ch
|
|||
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...
|
||||
|
|
|
@ -2331,15 +2331,15 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
|
|
|
@ -34,7 +34,7 @@ void UpdateStationAcceptance(Station *st, bool show_msg);
|
|||
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);
|
||||
|
|
|
@ -234,7 +234,7 @@ protected:
|
|||
|
||||
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++) {
|
||||
|
|
|
@ -333,7 +333,7 @@ CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue