summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ship_cmd.c13
-rw-r--r--station_map.h19
2 files changed, 20 insertions, 12 deletions
diff --git a/ship_cmd.c b/ship_cmd.c
index 6ad48e263..b5c5dba4c 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -190,17 +190,6 @@ static void PlayShipSound(Vehicle *v)
SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
}
-static const TileIndexDiffC _dock_offs[] = {
- { 2, 0},
- {-2, 0},
- { 0, 2},
- { 2, 0},
- { 0, -2},
- { 0, 0},
- { 0, 0},
- { 0, 0}
-};
-
static void ProcessShipOrder(Vehicle *v)
{
const Order *order;
@@ -245,7 +234,7 @@ static void ProcessShipOrder(Vehicle *v)
st = GetStation(order->station);
if (st->dock_tile != 0) {
- v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(_dock_offs[_m[st->dock_tile].m5-0x4B]));
+ v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
}
} else if (order->type == OT_GOTO_DEPOT) {
v->dest_tile = GetDepot(order->station)->xy;
diff --git a/station_map.h b/station_map.h
index 9ebf7803f..9c608af9b 100644
--- a/station_map.h
+++ b/station_map.h
@@ -184,6 +184,25 @@ static inline DiagDirection GetDockDirection(TileIndex t)
return (DiagDirection)(_m[t].m5 - DOCK_BASE);
}
+static inline TileIndexDiffC GetDockOffset(TileIndex t)
+{
+ static const TileIndexDiffC buoy_offset = {0, 0};
+ static const TileIndexDiffC oilrig_offset = {2, 0};
+ static const TileIndexDiffC dock_offset[DIAGDIR_END] = {
+ {-2, 0},
+ { 0, 2},
+ { 2, 0},
+ { 0, -2},
+ };
+ assert(IsTileType(t, MP_STATION));
+
+ if (IsBuoy_(t)) return buoy_offset;
+ if (IsOilRig(t)) return oilrig_offset;
+
+ assert(IsDock(t));
+
+ return dock_offset[GetDockDirection(t)];
+}
static inline bool IsCustomStationSprite(TileIndex t)
{