Commit 78970922 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Fix direction

parent 8a0f122a
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -89,18 +89,7 @@ sub error {
sub direction {
	my ($self) = @_;

	my @wagons = $self->wagons;

	if ( not @wagons ) {
		return undef;
	}

	if ( $wagons[0]->{position}{start_percent}
		> $wagons[-1]{position}{start_percent} )
	{
		return 0;
	}
	return 100;
	return $self->{direction};
}

sub sections {
@@ -142,6 +131,16 @@ sub wagons {
			);
		}
	}
	if ( @{ $self->{wagons} } > 1 ) {
		if ( $self->{wagons}[0]->{position}{start_percent}
			> $self->{wagons}[-1]->{position}{start_percent} )
		{
			$self->{direction} = 100;
		}
		else {
			$self->{direction} = 0;
		}
	}
	@{ $self->{wagons} } = sort {
		$a->{position}->{start_percent} <=> $b->{position}->{start_percent}
	} @{ $self->{wagons} };