equal
deleted
inserted
replaced
1459 return dir; |
1459 return dir; |
1460 } |
1460 } |
1461 |
1461 |
1462 /** |
1462 /** |
1463 * Can a tram track build without destruction on the given tile? |
1463 * Can a tram track build without destruction on the given tile? |
|
1464 * @param p the player that would be building the tram tracks |
1464 * @param t the tile to build on. |
1465 * @param t the tile to build on. |
|
1466 * @param r the road bits needed. |
1465 * @return true when a track track can be build on 't' |
1467 * @return true when a track track can be build on 't' |
1466 */ |
1468 */ |
1467 static bool CanBuildTramTrackOnTile(TileIndex t) |
1469 static bool CanBuildTramTrackOnTile(PlayerID p, TileIndex t, RoadBits r) |
1468 { |
1470 { |
1469 switch (GetTileType(t)) { |
1471 /* The 'current' player is not necessarily the owner of the vehicle. */ |
1470 case MP_CLEAR: |
1472 PlayerID original_player = _current_player; |
1471 case MP_TREES: |
1473 _current_player = p; |
1472 return true; |
1474 |
1473 |
1475 CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, 0, CMD_BUILD_ROAD); |
1474 case MP_ROAD: |
1476 |
1475 return GetRoadTileType(t) == ROAD_TILE_NORMAL; |
1477 _current_player = original_player; |
1476 |
1478 return CmdSucceeded(ret); |
1477 case MP_WATER: |
|
1478 return IsCoast(t); |
|
1479 |
|
1480 default: |
|
1481 return false; |
|
1482 } |
|
1483 } |
1479 } |
1484 |
1480 |
1485 static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev) |
1481 static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev) |
1486 { |
1482 { |
1487 Direction new_dir; |
1483 Direction new_dir; |
1591 * doing a reversing turn when the piece of tram track on the next |
1587 * doing a reversing turn when the piece of tram track on the next |
1592 * tile did not exist yet. Do not use the big tram loop as that is |
1588 * tile did not exist yet. Do not use the big tram loop as that is |
1593 * going to cause the tram to split up. |
1589 * going to cause the tram to split up. |
1594 * - Or the front of the tram can drive over the next tile. |
1590 * - Or the front of the tram can drive over the next tile. |
1595 */ |
1591 */ |
1596 } else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(tile)) { |
1592 } else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(v->owner, tile, needed)) { |
1597 /* |
1593 /* |
1598 * Taking the 'small' corner for trams only happens when: |
1594 * Taking the 'small' corner for trams only happens when: |
1599 * - We are not the from vehicle of an articulated tram. |
1595 * - We are not the from vehicle of an articulated tram. |
1600 * - Or when the player cannot build on the next tile. |
1596 * - Or when the player cannot build on the next tile. |
1601 * |
1597 * |