summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-12-11 20:28:53 +0000
committerrubidium <rubidium@openttd.org>2007-12-11 20:28:53 +0000
commita5bcce4fc878b678f03c7090c776d6934eb738a1 (patch)
treeca4412f877c0baf28c228568022a8e41d21c9a8f
parenta85c832919d9f429e93cd57fdcc4f3eda8d12245 (diff)
downloadopenttd-a5bcce4fc878b678f03c7090c776d6934eb738a1.tar.xz
(svn r11621) -Fix [FS#1525]: there were still some cases where one could not build a tram track, but the tram could become blocked.
-rw-r--r--src/roadveh_cmd.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index cb9fa2adb..78ca24de9 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1461,25 +1461,21 @@ static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev,
/**
* Can a tram track build without destruction on the given tile?
+ * @param p the player that would be building the tram tracks
* @param t the tile to build on.
+ * @param r the road bits needed.
* @return true when a track track can be build on 't'
*/
-static bool CanBuildTramTrackOnTile(TileIndex t)
+static bool CanBuildTramTrackOnTile(PlayerID p, TileIndex t, RoadBits r)
{
- switch (GetTileType(t)) {
- case MP_CLEAR:
- case MP_TREES:
- return true;
-
- case MP_ROAD:
- return GetRoadTileType(t) == ROAD_TILE_NORMAL;
+ /* The 'current' player is not necessarily the owner of the vehicle. */
+ PlayerID original_player = _current_player;
+ _current_player = p;
- case MP_WATER:
- return IsCoast(t);
+ CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, 0, CMD_BUILD_ROAD);
- default:
- return false;
- }
+ _current_player = original_player;
+ return CmdSucceeded(ret);
}
static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev)
@@ -1593,7 +1589,7 @@ again:
* going to cause the tram to split up.
* - Or the front of the tram can drive over the next tile.
*/
- } else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(tile)) {
+ } else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(v->owner, tile, needed)) {
/*
* Taking the 'small' corner for trams only happens when:
* - We are not the from vehicle of an articulated tram.