205 (axis = AXIS_Y, GetTrackBits(tile) != TRACK_BIT_Y) |
205 (axis = AXIS_Y, GetTrackBits(tile) != TRACK_BIT_Y) |
206 )) { |
206 )) { |
207 return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK); |
207 return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK); |
208 } |
208 } |
209 |
209 |
210 if (!CheckTileOwnership(tile)) return CMD_ERROR; |
210 Owner owner = GetTileOwner(tile); |
|
211 if (!CheckOwnership(owner)) return CMD_ERROR; |
211 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
212 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
212 |
213 |
213 tileh = GetTileSlope(tile, NULL); |
214 tileh = GetTileSlope(tile, NULL); |
214 if (tileh != SLOPE_FLAT && |
215 if (tileh != SLOPE_FLAT && |
215 (!_settings_game.construction.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) { |
216 (!_settings_game.construction.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) { |
228 if (wp == NULL) return CMD_ERROR; |
229 if (wp == NULL) return CMD_ERROR; |
229 |
230 |
230 wp->town_index = INVALID_TOWN; |
231 wp->town_index = INVALID_TOWN; |
231 wp->name = NULL; |
232 wp->name = NULL; |
232 wp->town_cn = 0; |
233 wp->town_cn = 0; |
|
234 wp->owner = owner; |
233 } else { |
235 } else { |
234 /* Move existing (recently deleted) waypoint to the new location */ |
236 /* Move existing (recently deleted) waypoint to the new location */ |
235 |
237 |
236 /* First we update the destination for all vehicles that |
238 /* First we update the destination for all vehicles that |
237 * have the old waypoint in their orders. */ |
239 * have the old waypoint in their orders. */ |
250 } |
252 } |
251 |
253 |
252 const StationSpec* statspec; |
254 const StationSpec* statspec; |
253 |
255 |
254 bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(axis)); |
256 bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(axis)); |
255 MakeRailWaypoint(tile, GetTileOwner(tile), axis, GetRailType(tile), wp->index); |
257 MakeRailWaypoint(tile, owner, axis, GetRailType(tile), wp->index); |
256 SetDepotWaypointReservation(tile, reserved); |
258 SetDepotWaypointReservation(tile, reserved); |
257 MarkTileDirtyByTile(tile); |
259 MarkTileDirtyByTile(tile); |
258 |
260 |
259 statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1); |
261 statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1); |
260 |
262 |
314 return CMD_ERROR; |
316 return CMD_ERROR; |
315 } |
317 } |
316 |
318 |
317 if (flags & DC_EXEC) { |
319 if (flags & DC_EXEC) { |
318 Track track = GetRailWaypointTrack(tile); |
320 Track track = GetRailWaypointTrack(tile); |
319 Owner owner = GetTileOwner(tile); // cannot use _current_player because of possible floods |
|
320 wp = GetWaypointByTile(tile); |
321 wp = GetWaypointByTile(tile); |
321 |
322 |
322 wp->deleted = 30; // let it live for this many days before we do the actual deletion. |
323 wp->deleted = 30; // let it live for this many days before we do the actual deletion. |
323 RedrawWaypointSign(wp); |
324 RedrawWaypointSign(wp); |
324 |
325 |
325 Vehicle *v = NULL; |
326 Vehicle *v = NULL; |
326 if (justremove) { |
327 if (justremove) { |
327 TrackBits tracks = GetRailWaypointBits(tile); |
328 TrackBits tracks = GetRailWaypointBits(tile); |
328 bool reserved = GetDepotWaypointReservation(tile); |
329 bool reserved = GetDepotWaypointReservation(tile); |
329 MakeRailNormal(tile, GetTileOwner(tile), tracks, GetRailType(tile)); |
330 MakeRailNormal(tile, wp->owner, tracks, GetRailType(tile)); |
330 if (reserved) SetTrackReservation(tile, tracks); |
331 if (reserved) SetTrackReservation(tile, tracks); |
331 MarkTileDirtyByTile(tile); |
332 MarkTileDirtyByTile(tile); |
332 } else { |
333 } else { |
333 if (GetDepotWaypointReservation(tile)) { |
334 if (GetDepotWaypointReservation(tile)) { |
334 v = GetTrainForReservation(tile, track); |
335 v = GetTrainForReservation(tile, track); |
335 if (v != NULL) FreeTrainTrackReservation(v); |
336 if (v != NULL) FreeTrainTrackReservation(v); |
336 } |
337 } |
337 DoClearSquare(tile); |
338 DoClearSquare(tile); |
338 AddTrackToSignalBuffer(tile, track, owner); |
339 AddTrackToSignalBuffer(tile, track, wp->owner); |
339 } |
340 } |
340 YapfNotifyTrackLayoutChange(tile, track); |
341 YapfNotifyTrackLayoutChange(tile, track); |
341 if (v != NULL) TryPathReserve(v, true); |
342 if (v != NULL) TryPathReserve(v, true); |
342 } |
343 } |
343 |
344 |
503 |
504 |
504 SLE_CONDVAR(Waypoint, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30), |
505 SLE_CONDVAR(Waypoint, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30), |
505 SLE_CONDVAR(Waypoint, build_date, SLE_INT32, 31, SL_MAX_VERSION), |
506 SLE_CONDVAR(Waypoint, build_date, SLE_INT32, 31, SL_MAX_VERSION), |
506 SLE_CONDVAR(Waypoint, localidx, SLE_UINT8, 3, SL_MAX_VERSION), |
507 SLE_CONDVAR(Waypoint, localidx, SLE_UINT8, 3, SL_MAX_VERSION), |
507 SLE_CONDVAR(Waypoint, grfid, SLE_UINT32, 17, SL_MAX_VERSION), |
508 SLE_CONDVAR(Waypoint, grfid, SLE_UINT32, 17, SL_MAX_VERSION), |
|
509 SLE_CONDVAR(Waypoint, owner, SLE_UINT8, 101, SL_MAX_VERSION), |
508 |
510 |
509 SLE_END() |
511 SLE_END() |
510 }; |
512 }; |
511 |
513 |
512 static void Save_WAYP() |
514 static void Save_WAYP() |