diff options
author | rubidium <rubidium@openttd.org> | 2008-08-02 22:48:27 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-02 22:48:27 +0000 |
commit | f1666c7062cb21c1697cc90a2c6ed13735000e82 (patch) | |
tree | 95d5ae6b9610b2acea4d00c7cec01a2946c24411 | |
parent | 063208a56f4cafe17b33ba13b5737b407a5d7aea (diff) | |
download | openttd-f1666c7062cb21c1697cc90a2c6ed13735000e82.tar.xz |
(svn r13931) -Codechange [YAPP]: Retain the reservation state when building/removing waypoints or level crossings. (michi_cc)
-rw-r--r-- | src/road_cmd.cpp | 7 | ||||
-rw-r--r-- | src/waypoint.cpp | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 07c327494..ba068172e 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -344,7 +344,10 @@ static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, Roa if (flags & DC_EXEC) { RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt)); if (rts == ROADTYPES_NONE) { - MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile)); + TrackBits tracks = GetCrossingRailBits(tile); + bool reserved = GetCrossingReservation(tile); + MakeRailNormal(tile, GetTileOwner(tile), tracks, GetRailType(tile)); + if (reserved) SetTrackReservation(tile, tracks); } else { SetRoadTypes(tile, rts); } @@ -562,7 +565,9 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) { YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile))); /* Always add road to the roadtypes (can't draw without it) */ + bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(OtherAxis(roaddir))); MakeRoadCrossing(tile, _current_player, _current_player, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2); + SetCrossingReservation(tile, reserved); UpdateLevelCrossing(tile, false); MarkTileDirtyByTile(tile); } diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 6dd30cf3c..ad86a6690 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -249,7 +249,9 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint3 const StationSpec* statspec; + bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(axis)); MakeRailWaypoint(tile, GetTileOwner(tile), axis, GetRailType(tile), wp->index); + SetDepotWaypointReservation(tile, reserved); MarkTileDirtyByTile(tile); statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1); @@ -319,7 +321,10 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) RedrawWaypointSign(wp); if (justremove) { - MakeRailNormal(tile, GetTileOwner(tile), GetRailWaypointBits(tile), GetRailType(tile)); + TrackBits tracks = GetRailWaypointBits(tile); + bool reserved = GetDepotWaypointReservation(tile); + MakeRailNormal(tile, GetTileOwner(tile), tracks, GetRailType(tile)); + if (reserved) SetTrackReservation(tile, tracks); MarkTileDirtyByTile(tile); } else { DoClearSquare(tile); |