@@ -188,25 +188,38 @@ CommandCost CmdBuildTrainWaypoint(TileIn
/* 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);
Status change: