X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=misc%2Ftools%2Fmidi2cfg-ng.pl;h=58b4097065280f6bdd0648be09e93502ac3eb494;hb=26e02eb7d0cc8be0f72fbf282c5f06c223ecdd33;hp=70a37517b26536eafea744c9f67a897c69003b8b;hpb=9b9cf0d6e1b76e5e10a3d2d22a5db8e29bd48229;p=xonotic%2Fxonotic.git diff --git a/misc/tools/midi2cfg-ng.pl b/misc/tools/midi2cfg-ng.pl index 70a37517..58b40970 100755 --- a/misc/tools/midi2cfg-ng.pl +++ b/misc/tools/midi2cfg-ng.pl @@ -344,7 +344,7 @@ sub busybot_cmd_bot_execute($$@) } elsif($_->[0] eq 'aim_random') { - $commands .= sprintf "sv_cmd bot_cmd %d aim %f 0 %f\n", $_->[1] + rand($_->[2] - $_->[1]), $_->[3]; + $commands .= sprintf "sv_cmd bot_cmd %d aim \"%f 0 %f\"\n", $bot->{id}, $_->[1] + rand($_->[2] - $_->[1]), $_->[3]; } elsif($_->[0] eq 'barrier') { @@ -800,8 +800,20 @@ sub ConvertMIDI($$) } } + # sort events @allmidievents = sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @allmidievents; + # find the first interesting event + my $shift = [grep { $_->[0] eq 'note_on' } @allmidievents]->[0][1]; + die "No notes!" + unless defined $shift; + + # shift times by first event, no boring waiting + $_->[0] = ($_->[0] < $shift ? 0 : $_->[0] - $shift) for @tempi; + $_->[1] = ($_->[1] < $shift ? 0 : $_->[1] - $shift) for @allmidievents; + + # fix event list + my %midinotes = (); my $notes_stuck = 0; my %notes_seen = ();