equal
deleted
inserted
replaced
188 static void PlayShipSound(Vehicle *v) |
188 static void PlayShipSound(Vehicle *v) |
189 { |
189 { |
190 SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v); |
190 SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v); |
191 } |
191 } |
192 |
192 |
193 static const TileIndexDiff _dock_offs[] = { |
193 static const TileIndexDiffC _dock_offs[] = { |
194 TILE_XY(2, 0), |
194 { 2, 0}, |
195 TILE_XY(-2, 0), |
195 {-2, 0}, |
196 TILE_XY(0, 2), |
196 { 0, 2}, |
197 TILE_XY(2, 0), |
197 { 2, 0}, |
198 TILE_XY(0, -2), |
198 { 0, -2}, |
199 TILE_XY(0,0), |
199 { 0, 0}, |
200 TILE_XY(0,0), |
200 { 0, 0}, |
201 TILE_XY(0,0), |
201 { 0, 0} |
202 }; |
202 }; |
203 |
203 |
204 static void ProcessShipOrder(Vehicle *v) |
204 static void ProcessShipOrder(Vehicle *v) |
205 { |
205 { |
206 Order order; |
206 Order order; |
243 if (order.station == v->last_station_visited) |
243 if (order.station == v->last_station_visited) |
244 v->last_station_visited = 0xFFFF; |
244 v->last_station_visited = 0xFFFF; |
245 |
245 |
246 st = DEREF_STATION(order.station); |
246 st = DEREF_STATION(order.station); |
247 if (st->dock_tile != 0) { |
247 if (st->dock_tile != 0) { |
248 v->dest_tile = TILE_ADD(st->dock_tile, _dock_offs[_map5[st->dock_tile]-0x4B]); |
248 v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(_dock_offs[_map5[st->dock_tile]-0x4B])); |
249 } |
249 } |
250 } else if (order.type == OT_GOTO_DEPOT) { |
250 } else if (order.type == OT_GOTO_DEPOT) { |
251 v->dest_tile = _depots[order.station].xy; |
251 v->dest_tile = _depots[order.station].xy; |
252 } else { |
252 } else { |
253 v->dest_tile = 0; |
253 v->dest_tile = 0; |
317 v->cur_image = GetShipImage(v, v->direction); |
317 v->cur_image = GetShipImage(v, v->direction); |
318 MarkShipDirty(v); |
318 MarkShipDirty(v); |
319 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
319 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
320 } |
320 } |
321 |
321 |
322 static const TileIndexDiff _ship_leave_depot_offs[] = { |
322 static const TileIndexDiffC _ship_leave_depot_offs[] = { |
323 TILE_XY(-1,0), |
323 {-1, 0}, |
324 TILE_XY(0,-1), |
324 { 0, -1} |
325 }; |
325 }; |
326 |
326 |
327 static void CheckShipLeaveDepot(Vehicle *v) |
327 static void CheckShipLeaveDepot(Vehicle *v) |
328 { |
328 { |
329 uint tile; |
329 uint tile; |
335 |
335 |
336 tile = v->tile; |
336 tile = v->tile; |
337 d = (_map5[tile]&2) ? 1 : 0; |
337 d = (_map5[tile]&2) ? 1 : 0; |
338 |
338 |
339 // Check first side |
339 // Check first side |
340 if (_ship_sometracks[d] & GetTileShipTrackStatus(TILE_ADD(tile,_ship_leave_depot_offs[d]))) { |
340 if (_ship_sometracks[d] & GetTileShipTrackStatus(TILE_ADD(tile, ToTileIndexDiff(_ship_leave_depot_offs[d])))) { |
341 m = (d==0) ? 0x101 : 0x207; |
341 m = (d==0) ? 0x101 : 0x207; |
342 // Check second side |
342 // Check second side |
343 } else if (_ship_sometracks[d+2] & GetTileShipTrackStatus(TILE_ADD(tile, -2*_ship_leave_depot_offs[d]))) { |
343 } else if (_ship_sometracks[d+2] & GetTileShipTrackStatus(TILE_ADD(tile, -2 * ToTileIndexDiff(_ship_leave_depot_offs[d])))) { |
344 m = (d==0) ? 0x105 : 0x203; |
344 m = (d==0) ? 0x105 : 0x203; |
345 } else { |
345 } else { |
346 return; |
346 return; |
347 } |
347 } |
348 v->direction = (byte)m; |
348 v->direction = (byte)m; |