summaryrefslogtreecommitdiff
path: root/station_cmd.c
diff options
context:
space:
mode:
authordominik <dominik@openttd.org>2005-01-20 22:19:34 +0000
committerdominik <dominik@openttd.org>2005-01-20 22:19:34 +0000
commitef93fcfe485f90809f07eaab17d9d8e4afc2abe7 (patch)
treef84eb7628139785edf140c2c572701cefa01d8c7 /station_cmd.c
parentc245d93e7d37854ab9410c0e1652fe890d8edfe6 (diff)
downloadopenttd-ef93fcfe485f90809f07eaab17d9d8e4afc2abe7.tar.xz
(svn r1579) Fix: [ 1105963 ] Buoys can now only be removed if no ship has it in their schedule.
This makes buoys more useable in multiplayer games again, as buoys can't be deleted by other players if they are used.
Diffstat (limited to 'station_cmd.c')
-rw-r--r--station_cmd.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/station_cmd.c b/station_cmd.c
index fe990857a..091205e0e 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -1751,6 +1751,23 @@ int32 CmdBuildBuoy(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return _price.build_dock;
}
+/* Checks if any ship is servicing the buoy specified. Returns yes or no */
+static bool CheckShipsOnBuoy(Station *st)
+{
+ const Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == VEH_Ship) {
+ const Order *order;
+ FOR_VEHICLE_ORDERS(v, order) {
+ if (order->type == OT_GOTO_STATION && order->station == st->index) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
static int32 RemoveBuoy(Station *st, uint32 flags)
{
uint tile;
@@ -1762,6 +1779,9 @@ static int32 RemoveBuoy(Station *st, uint32 flags)
tile = st->dock_tile;
+ if (CheckShipsOnBuoy(st))
+ return_cmd_error(STR_BUOY_IS_IN_USE);
+
if (!EnsureNoVehicle(tile))
return CMD_ERROR;