|| (defined $self->{throttle} && defined $val
&& $self->{throttle} == $val);
- if ($self->{in_pit_lane} && defined $val && $val > 3) {
- delete $self->{in_pit_lane};
- $self->gui->leave_pit_lane;
- }
-
$self->{throttle} = $val;
$self->gui->set_throttle($self->{order}, $val);
}
if (defined $lap_time) {
$lap_time = sprintf("%.2f", $lap_time);
- if ($lap_time > 1.0 && (
- !$self->{in_pit_lane} && !defined $self->{best_lap}
- || $self->{best_lap} > $lap_time
+ if ($lap_time > 1.0 && !$self->{in_pit_lane}
+ && (!defined $self->{best_lap}
+ || $self->{best_lap} > $lap_time
)) {
$self->{best_lap} = $lap_time;
$self->gui->set_best_lap($self->{order}, $lap_time,
$global);
}
-
} else {
$self->gui->set_best_lap($self->{order}, '--');
$self->{best_lap} = undef;
sub enter_pit_lane {
my ($self) = @_;
+ return if $self->{in_pit_lane};
+
$self->{in_pit_lane} = 1;
$self->gui->enter_pit_lane;
}
+sub leave_pit_lane {
+ my ($self) = @_;
+
+ return if !$self->{in_pit_lane};
+
+ $self->{in_pit_lane} = 0;
+ $self->gui->leave_pit_lane;
+}
+
sub set_order {
my ($self, $pos) = @_;
if $fail;
my $pit_lane_entry;
+ my $too_fast;
my @cars_finished;
for my $i (0..5) {
my $byte = $bytes[$i];
$pit_lane_entry = 1 if $byte == 0xF0;
+ $too_fast = 1 if $byte == 0xFF;
+
push @cars_finished, $i if $byte == 0xE7;
}
for my $car (@cars_finished) {
$self->track->car($car)->enter_pit_lane;
}
+ } else {
+ for my $car (@cars_finished) {
+ $self->track->car($car)->leave_pit_lane;
+ }
}
return $msg; # FIXME - to be implemented