* Updates some variables after swapping the vehicle. * @param v swapped vehicle */
| 1610 | * @param v swapped vehicle |
| 1611 | */ |
| 1612 | static void UpdateStatusAfterSwap(Train *v) |
| 1613 | { |
| 1614 | /* Reverse the direction. */ |
| 1615 | if (v->track != TRACK_BIT_DEPOT) v->direction = ReverseDir(v->direction); |
| 1616 | |
| 1617 | /* Call the proper EnterTile function unless we are in a wormhole. */ |
| 1618 | if (v->track != TRACK_BIT_WORMHOLE) { |
| 1619 | VehicleEnterTile(v, v->tile, v->x_pos, v->y_pos); |
| 1620 | } else { |
| 1621 | /* VehicleEnter_TunnelBridge() sets TRACK_BIT_WORMHOLE when the vehicle |
| 1622 | * is on the last bit of the bridge head (frame == TILE_SIZE - 1). |
| 1623 | * If we were swapped with such a vehicle, we have set TRACK_BIT_WORMHOLE, |
| 1624 | * when we shouldn't have. Check if this is the case. */ |
| 1625 | TileIndex vt = TileVirtXY(v->x_pos, v->y_pos); |
| 1626 | if (IsTileType(vt, MP_TUNNELBRIDGE)) { |
| 1627 | VehicleEnterTile(v, vt, v->x_pos, v->y_pos); |
| 1628 | if (v->track != TRACK_BIT_WORMHOLE && IsBridgeTile(v->tile)) { |
| 1629 | /* We have just left the wormhole, possibly set the |
| 1630 | * "goingdown" bit. UpdateInclination() can be used |
| 1631 | * because we are at the border of the tile. */ |
| 1632 | v->UpdatePosition(); |
| 1633 | v->UpdateInclination(true, true); |
| 1634 | return; |
| 1635 | } |
| 1636 | } |
| 1637 | } |
| 1638 | |
| 1639 | v->UpdatePosition(); |
| 1640 | v->UpdateViewport(true, true); |
| 1641 | } |
| 1642 | |
| 1643 | /** |
| 1644 | * Swap vehicles \a l and \a r in consist \a v, and reverse their direction. |
no test coverage detected