From: Rudolf Polzer Date: Tue, 27 Sep 2011 04:51:02 +0000 (+0200) Subject: assign percussion bots round-robin, looks better X-Git-Tag: xonotic-v0.6.0~79 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8d8a931ec0622f3ed516e625e431db7caacce493;p=xonotic%2Fxonotic.git assign percussion bots round-robin, looks better --- diff --git a/misc/tools/midi2cfg-ng.pl b/misc/tools/midi2cfg-ng.pl index fad3a4e1..d8db264e 100755 --- a/misc/tools/midi2cfg-ng.pl +++ b/misc/tools/midi2cfg-ng.pl @@ -297,6 +297,8 @@ sub busybot_cmd_bot_execute($$@) { my ($bot, $time, @commands) = @_; + $bot->{lastuse} = $time; + for(@commands) { if($_->[0] eq 'time') @@ -340,7 +342,7 @@ sub busybot_cmd_bot_execute($$@) elsif($_->[0] eq 'barrier') { $commands .= sprintf "sv_cmd bot_cmd %d barrier\n", $bot->{id}; - $bot->{timer} = $bot->{busytimer} = 0; + $bot->{lastuse} = $bot->{timer} = $bot->{busytimer} = 0; } elsif($_->[0] eq 'raw') { @@ -514,7 +516,7 @@ sub busybot_note_on($$$$) my @epicfailbots = (); - for(unsort @busybots_allocated) + for(map { $_->[1] } sort { $a->[1]->{lastuse} <=> $b->[1]->{lastuse} or $a->[0] <=> $b->[0] } map { [rand, $_] } @busybots_allocated) { my $canplay = busybot_note_on_bot $_, $time, $channel, $program, $note, 0, 0; if($canplay > 0)