@@ -176,49 +176,62 @@ CommandCost CmdBuildTrainWaypoint(TileIn
if (!CheckTileOwnership(tile)) return CMD_ERROR;
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
tileh = GetTileSlope(tile, NULL);
if (tileh != SLOPE_FLAT &&
(!_patches.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
/* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */
wp = FindDeletedWaypointCloseTo(tile);
if (wp == NULL) {
wp = new Waypoint(tile);
if (wp == NULL) return CMD_ERROR;
wp_auto_delete = wp;
wp->town_index = 0;
wp->string = STR_NULL;
wp->town_cn = 0;
} else if (flags & DC_EXEC) {
/* move existing (recently deleted) waypoint to the new location */
/* 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;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN &&
v->First() == v &&
v->current_order.type == OT_GOTO_WAYPOINT &&
v->dest_tile == wp->xy) {
v->dest_tile = tile;
RedrawWaypointSign(wp);
wp->xy = tile;
if (flags & DC_EXEC) {
const StationSpec* statspec;
MakeRailWaypoint(tile, GetTileOwner(tile), axis, GetRailType(tile), wp->index);
MarkTileDirtyByTile(tile);
statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1);
if (statspec != NULL) {
wp->stat_id = p1;
wp->grfid = statspec->grffile->grfid;
wp->localidx = statspec->localidx;
} else {
/* Specified custom graphics do not exist, so use default. */
wp->stat_id = 0;
wp->grfid = 0;
wp->localidx = 0;
wp->deleted = 0;
Status change: