]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/midi2cfg-ng.pl
bugfixes and midi2cfg changes from my secret branch
[xonotic/xonotic.git] / misc / tools / midi2cfg-ng.pl
index 52dbd3a98636fb7f0d5fea2bc8a235b63e8884e0..ad06b746807b931b671d7a59cd148cb38f0cd8dc 100755 (executable)
@@ -473,7 +473,7 @@ sub busybot_note_on_bot($$$$$$$)
        }
        ++$bot->{seen}{$k0}{$k1};
 
-       if($bot->{lastuse} && $channel == $bot->{lastchannel})
+       if(($bot->{lastuse} // -666) >= $time - $time_forgetfulness && $channel == $bot->{lastchannel})
        {
                $bot->{lastchannelsequence} += 1;
        }
@@ -539,16 +539,19 @@ sub botsort($$$$@)
                map
                {
                        my $q = 0;
-                       if(($_->{lastuse} // -666) >= $time - $time_forgetfulness)
+                       if($channel != 10) # percussion just should do round robin
                        {
-                               if($channel == $_->{lastchannel})
+                               if(($_->{lastuse} // -666) >= $time - $time_forgetfulness)
                                {
-                                       $q += $_->{lastchannelsequence};
-                               }
-                               else
-                               {
-                                       # better leave this one alone
-                                       --$q;
+                                       if($channel == $_->{lastchannel})
+                                       {
+                                               $q += $_->{lastchannelsequence};
+                                       }
+                                       else
+                                       {
+                                               # better leave this one alone
+                                               $q -= $_->{lastchannelsequence};
+                                       }
                                }
                        }
                        [$_, $q, rand]
@@ -854,7 +857,7 @@ sub ConvertMIDI($$)
                                        my $votehigh = 0;
                                        my $votelow = 0;
                                        my $votegood = 0;
-                                       for(@busybots_allocated)
+                                       for(@busybots_allocated, grep { $_->{count} > 0 } values %$busybots)
                                        {
                                                next # I won't play on this channel
                                                        if defined $_->{channels} and not $_->{channels}->{$channel};