diff options
author | rubidium <rubidium@openttd.org> | 2007-05-20 19:14:08 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-05-20 19:14:08 +0000 |
commit | 51109475a2e90499e19c1c7d1bff03393bdcaf4f (patch) | |
tree | 040143187639f8855d9618bfc8f784f4a42bbaeb /src/rail_cmd.cpp | |
parent | 78243fbd3ddb45a1f0eddaaed534c45ab5518bf2 (diff) | |
download | openttd-51109475a2e90499e19c1c7d1bff03393bdcaf4f.tar.xz |
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r-- | src/rail_cmd.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index be0bbd93a..3280b13cd 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -295,10 +295,25 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); - if ((track == TRACK_X && GetRoadBits(tile) == ROAD_Y) || - (track == TRACK_Y && GetRoadBits(tile) == ROAD_X)) { + RoadTypes roadtypes = GetRoadTypes(tile); + RoadBits road = GetRoadBits(tile, ROADTYPE_ROAD); + RoadBits tram = GetRoadBits(tile, ROADTYPE_TRAM); + switch (roadtypes) { + default: break; + case ROADTYPES_ROADTRAM: if (road == tram) break; + /* FALL THROUGH */ + case ROADTYPES_ROADHWAY: // Road and highway are incompatible in this case + case ROADTYPES_TRAMHWAY: // Tram and highway are incompatible in this case + case ROADTYPES_ALL: // Also incompatible + return CMD_ERROR; + } + + road |= tram | GetRoadBits(tile, ROADTYPE_HWAY); + + if ((track == TRACK_X && road == ROAD_Y) || + (track == TRACK_Y && road == ROAD_X)) { if (flags & DC_EXEC) { - MakeRoadCrossing(tile, GetTileOwner(tile), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, GetTownIndex(tile)); + MakeRoadCrossing(tile, GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile)); } break; } @@ -359,7 +374,7 @@ int32 CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } if (flags & DC_EXEC) { - MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile)); + MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY)); } break; } |