summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2007-12-19 23:35:14 +0000
committersmatz <smatz@openttd.org>2007-12-19 23:35:14 +0000
commit4a80cf848209962a378019f74a318994370d3fd7 (patch)
tree0ec3573300b058bad88b58f00714b8161888ffd8 /src/station_cmd.cpp
parent5b49e754535d48bb42575bc987e9c8f3251cf595 (diff)
downloadopenttd-4a80cf848209962a378019f74a318994370d3fd7.tar.xz
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 02fc77898..ecaf1707f 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1868,15 +1868,20 @@ CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return CommandCost(_price.build_dock);
}
-/* Checks if any ship is servicing the buoy specified. Returns yes or no */
-static bool CheckShipsOnBuoy(Station *st)
+/**
+ * Tests whether the player's vehicles have this station in orders
+ * When player == INVALID_PLAYER, then check all vehicles
+ * @param station station ID
+ * @param player player ID, INVALID_PLAYER to disable the check
+ */
+bool HasStationInUse(StationID station, PlayerID player)
{
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_SHIP) {
+ if (player == INVALID_PLAYER || v->owner == player) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
- if (order->type == OT_GOTO_STATION && order->dest == st->index) {
+ if (order->type == OT_GOTO_STATION && order->dest == station) {
return true;
}
}
@@ -1892,7 +1897,7 @@ static CommandCost RemoveBuoy(Station *st, uint32 flags)
TileIndex tile = st->dock_tile;
- if (CheckShipsOnBuoy(st)) return_cmd_error(STR_BUOY_IS_IN_USE);
+ if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE);
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (flags & DC_EXEC) {