]> www.fi.muni.cz Git - slotcarman.git/commitdiff
Another attempt at pit lane handling.
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 6 Dec 2010 23:27:10 +0000 (00:27 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 6 Dec 2010 23:27:10 +0000 (00:27 +0100)
SCX/Car.pm
SCX/GUI.pm
SCX/Reader.pm

index f4a38a0436b258016b5e38e68db07e05f9dde1dc..23caad6c4abfb8fd03bf8cd7d353e72d6812b7b4 100644 (file)
@@ -34,11 +34,6 @@ sub set_throttle {
                || (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);
 }
@@ -90,9 +85,9 @@ sub set_laptime {
 
        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;
@@ -102,7 +97,6 @@ sub set_laptime {
                        $self->gui->set_best_lap($self->{order}, $lap_time,
                                $global);
                }
-               
        } else {
                $self->gui->set_best_lap($self->{order}, '--');
                $self->{best_lap} = undef;
@@ -132,10 +126,21 @@ sub set_driver {
 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) = @_;
 
index 2148f93f77bfb4380a33cf2b977e435c8a035083..93e76b74761baf51d441fc6c17d0d27561f31013 100755 (executable)
@@ -186,7 +186,7 @@ sub enter_pit_lane {
 
 sub leave_pit_lane {
        my ($self, $row) = @_;
-       $self->set_laptime($row, '--');
+       $self->set_laptime($row, 'GO!');
 }
 
 sub show_semaphore {
index db88e3416519f969287032196f8f3b0e2a616b28..72dcb2542e3993c9b2cfcb348b2ffe312aed6e98 100644 (file)
@@ -392,11 +392,14 @@ sub finish_line_packet {
                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;
        }
 
@@ -404,6 +407,10 @@ sub finish_line_packet {
                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