]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
assign percussion bots round-robin, looks better
authorRudolf Polzer <divverent@xonotic.org>
Tue, 27 Sep 2011 04:51:02 +0000 (06:51 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 27 Sep 2011 04:51:02 +0000 (06:51 +0200)
misc/tools/midi2cfg-ng.pl

index fad3a4e1028a5ff92d10bfb35da0fb1130dcbd45..d8db264ec1ff5fdac8768a2eee3e7bf54046b194 100755 (executable)
@@ -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)