|
@@ -204,13 +204,14 @@ CommandCost CmdBuildTrainWaypoint(TileIn
|
|
|
(axis = AXIS_X, GetTrackBits(tile) != TRACK_BIT_X) &&
|
|
|
(axis = AXIS_Y, GetTrackBits(tile) != TRACK_BIT_Y)
|
|
|
)) {
|
|
|
return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK);
|
|
|
}
|
|
|
|
|
|
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
|
|
Owner owner = GetTileOwner(tile);
|
|
|
if (!CheckOwnership(owner)) return CMD_ERROR;
|
|
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
|
|
|
|
|
tileh = GetTileSlope(tile, NULL);
|
|
|
if (tileh != SLOPE_FLAT &&
|
|
|
(!_settings_game.construction.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) {
|
|
|
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
|
@@ -227,12 +228,13 @@ CommandCost CmdBuildTrainWaypoint(TileIn
|
|
|
wp = new Waypoint(tile);
|
|
|
if (wp == NULL) return CMD_ERROR;
|
|
|
|
|
|
wp->town_index = INVALID_TOWN;
|
|
|
wp->name = NULL;
|
|
|
wp->town_cn = 0;
|
|
|
wp->owner = owner;
|
|
|
} else {
|
|
|
/* Move existing (recently deleted) waypoint to the new location */
|
|
|
|
|
|
/* First we update the destination for all vehicles that
|
|
|
* have the old waypoint in their orders. */
|
|
|
Vehicle *v;
|
|
@@ -249,13 +251,13 @@ CommandCost CmdBuildTrainWaypoint(TileIn
|
|
|
wp->xy = tile;
|
|
|
}
|
|
|
|
|
|
const StationSpec* statspec;
|
|
|
|
|
|
bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(axis));
|
|
|
MakeRailWaypoint(tile, GetTileOwner(tile), axis, GetRailType(tile), wp->index);
|
|
|
MakeRailWaypoint(tile, owner, axis, GetRailType(tile), wp->index);
|
|
|
SetDepotWaypointReservation(tile, reserved);
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
|
|
statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1);
|
|
|
|
|
|
if (statspec != NULL) {
|
|
@@ -313,32 +315,31 @@ CommandCost RemoveTrainWaypoint(TileInde
|
|
|
!EnsureNoVehicleOnGround(tile)) {
|
|
|
return CMD_ERROR;
|
|
|
}
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
Track track = GetRailWaypointTrack(tile);
|
|
|
Owner owner = GetTileOwner(tile); // cannot use _current_player because of possible floods
|
|
|
wp = GetWaypointByTile(tile);
|
|
|
|
|
|
wp->deleted = 30; // let it live for this many days before we do the actual deletion.
|
|
|
RedrawWaypointSign(wp);
|
|
|
|
|
|
Vehicle *v = NULL;
|
|
|
if (justremove) {
|
|
|
TrackBits tracks = GetRailWaypointBits(tile);
|
|
|
bool reserved = GetDepotWaypointReservation(tile);
|
|
|
MakeRailNormal(tile, GetTileOwner(tile), tracks, GetRailType(tile));
|
|
|
MakeRailNormal(tile, wp->owner, tracks, GetRailType(tile));
|
|
|
if (reserved) SetTrackReservation(tile, tracks);
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
} else {
|
|
|
if (GetDepotWaypointReservation(tile)) {
|
|
|
v = GetTrainForReservation(tile, track);
|
|
|
if (v != NULL) FreeTrainTrackReservation(v);
|
|
|
}
|
|
|
DoClearSquare(tile);
|
|
|
AddTrackToSignalBuffer(tile, track, owner);
|
|
|
AddTrackToSignalBuffer(tile, track, wp->owner);
|
|
|
}
|
|
|
YapfNotifyTrackLayoutChange(tile, track);
|
|
|
if (v != NULL) TryPathReserve(v, true);
|
|
|
}
|
|
|
|
|
|
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot);
|
|
@@ -502,12 +503,13 @@ static const SaveLoad _waypoint_desc[] =
|
|
|
SLE_VAR(Waypoint, deleted, SLE_UINT8),
|
|
|
|
|
|
SLE_CONDVAR(Waypoint, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30),
|
|
|
SLE_CONDVAR(Waypoint, build_date, SLE_INT32, 31, SL_MAX_VERSION),
|
|
|
SLE_CONDVAR(Waypoint, localidx, SLE_UINT8, 3, SL_MAX_VERSION),
|
|
|
SLE_CONDVAR(Waypoint, grfid, SLE_UINT32, 17, SL_MAX_VERSION),
|
|
|
SLE_CONDVAR(Waypoint, owner, SLE_UINT8, 101, SL_MAX_VERSION),
|
|
|
|
|
|
SLE_END()
|
|
|
};
|
|
|
|
|
|
static void Save_WAYP()
|
|
|
{
|