summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-04-26 10:23:55 +0000
committerfrosch <frosch@openttd.org>2015-04-26 10:23:55 +0000
commit3a82bae0d3b1010f5ad64606a36416d72b1fc380 (patch)
treec36205d499cdc280dc3c6e5edbbcc47b87aa4cc5
parent0ea4127837d56f68f377b930de5f1d558861505f (diff)
downloadopenttd-3a82bae0d3b1010f5ad64606a36416d72b1fc380.tar.xz
(svn r27252) -Fix [FS#6281]: Invalid infrastructure counting when crossing tram tracks with railroads. (adf88)
-rw-r--r--src/rail_cmd.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index f27aa877b..8a15808c2 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -485,31 +485,31 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
RoadTypes roadtypes = GetRoadTypes(tile);
RoadBits road = GetRoadBits(tile, ROADTYPE_ROAD);
RoadBits tram = GetRoadBits(tile, ROADTYPE_TRAM);
- switch (roadtypes) {
- default: break;
- case ROADTYPES_TRAM:
- /* Tram crossings must always have road. */
- if (flags & DC_EXEC) {
- SetRoadOwner(tile, ROADTYPE_ROAD, _current_company);
- Company *c = Company::GetIfValid(_current_company);
- if (c != NULL) {
- /* A full diagonal tile has two road bits. */
- c->infrastructure.road[ROADTYPE_ROAD] += 2;
- DirtyCompanyInfrastructureWindows(c->index);
+ if ((track == TRACK_X && (road | tram) == ROAD_Y) ||
+ (track == TRACK_Y && (road | tram) == ROAD_X)) {
+ switch (roadtypes) {
+ default: break;
+ case ROADTYPES_TRAM:
+ /* Tram crossings must always have road. */
+ if (flags & DC_EXEC) {
+ SetRoadOwner(tile, ROADTYPE_ROAD, _current_company);
+ Company *c = Company::GetIfValid(_current_company);
+ if (c != NULL) {
+ /* A full diagonal tile has two road bits. */
+ c->infrastructure.road[ROADTYPE_ROAD] += 2;
+ DirtyCompanyInfrastructureWindows(c->index);
+ }
}
- }
- roadtypes |= ROADTYPES_ROAD;
- break;
+ roadtypes |= ROADTYPES_ROAD;
+ break;
- case ROADTYPES_ALL:
- if (road != tram) return CMD_ERROR;
- break;
- }
+ case ROADTYPES_ALL:
+ if (road != tram) return CMD_ERROR;
+ break;
+ }
- road |= tram;
+ road |= tram;
- if ((track == TRACK_X && road == ROAD_Y) ||
- (track == TRACK_Y && road == ROAD_X)) {
if (flags & DC_EXEC) {
MakeRoadCrossing(tile, GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), _current_company, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile));
UpdateLevelCrossing(tile, false);