From ad4fdb76fc51d6af87d79c734a94407dca501de3 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 2 Aug 2008 22:48:27 +0000 Subject: (svn r13931) -Codechange [YAPP]: Retain the reservation state when building/removing waypoints or level crossings. (michi_cc) --- src/road_cmd.cpp | 7 ++++++- 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); -- cgit v1.2.3-70-g09d2