X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=SCX%2FReader.pm;h=ff5894d459f115dcac243179bc483e730201ade2;hb=972687391b212153ee34a6ecf616fd1c1a53d01b;hp=7498e0a179c430aa082ff0da3cf37f6e4b9ecc0a;hpb=041b40ba9d04693394c1472224cbb4285a0280c3;p=slotcarman.git diff --git a/SCX/Reader.pm b/SCX/Reader.pm index 7498e0a..ff5894d 100644 --- a/SCX/Reader.pm +++ b/SCX/Reader.pm @@ -276,9 +276,9 @@ sub race_setup_packet { $self->track->race_setup($bytes[0] == 0x00 ? 0 - : $bytes[1] & 0x0F * 256 - + $bytes[2] & 0x0F * 16 - + $bytes[3] & 0x0F); + : ($bytes[1] & 0x0F) * 256 + + ($bytes[2] & 0x0F) * 16 + + ($bytes[3] & 0x0F)); return $msg; } @@ -409,16 +409,11 @@ sub finish_line_packet { push @cars_finished, $i if $byte == 0xE7; } - my $processed; - for my $car (@cars_finished) { - $processed ||= $self->track->car($car)->finish_line( - $self->{last_read_time}, $regular - ); - } - - if ($processed) { - $self->track->recalc_order; - } + $self->track->finish_line( + $self->{last_read_time}, + $regular, + @cars_finished + ); return $msg; } @@ -455,7 +450,8 @@ sub controller_status_packet { my $backbutton = !($byte & 0x10); my $throttle = $byte & 0x0f; - $self->track->car($car)->set_throttle($throttle); + $self->track->car($car)->set_throttle($throttle, + $self->{last_read_time}); $self->track->car($car)->set_light($light); $self->track->car($car)->set_backbutton($backbutton); }