From 42e9b67f1667022d3eafb33f44d5c7e6f16246cf Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Mon, 26 Aug 2024 06:02:38 +0200 Subject: Allow setting mot bitmasks directly --- lib/Travel/Routing/DE/HAFAS.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Travel/Routing/DE/HAFAS.pm b/lib/Travel/Routing/DE/HAFAS.pm index 584a3a3..62ec34c 100644 --- a/lib/Travel/Routing/DE/HAFAS.pm +++ b/lib/Travel/Routing/DE/HAFAS.pm @@ -237,13 +237,23 @@ sub mot_mask { if ( my @mots = @{ $self->{exclusive_mots} // [] } ) { $mot_mask = 0; for my $mot (@mots) { - $mot_mask |= 1 << $mot_pos{$mot}; + if ( exists $mot_pos{$mot} ) { + $mot_mask |= 1 << $mot_pos{$mot}; + } + elsif ( $mot =~ m{ ^ \d+ $ }x ) { + $mot_mask |= 1 << $mot; + } } } if ( my @mots = @{ $self->{excluded_mots} // [] } ) { for my $mot (@mots) { - $mot_mask &= ~( 1 << $mot_pos{$mot} ); + if ( exists $mot_pos{$mot} ) { + $mot_mask &= ~( 1 << $mot_pos{$mot} ); + } + elsif ( $mot =~ m{ ^ \d+ $ }x ) { + $mot_mask &= ~( 1 << $mot ); + } } } -- cgit v1.2.3