From 3a82bae0d3b1010f5ad64606a36416d72b1fc380 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 26 Apr 2015 10:23:55 +0000 Subject: (svn r27252) -Fix [FS#6281]: Invalid infrastructure counting when crossing tram tracks with railroads. (adf88) --- src/rail_cmd.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src') 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); -- cgit v1.2.3-70-g09d2