}
++$bot->{seen}{$k0}{$k1};
+ if(($bot->{lastuse} // -666) >= $time - $time_forgetfulness && $channel == $bot->{lastchannel})
+ {
+ $bot->{lastchannelsequence} += 1;
+ }
+ else
+ {
+ $bot->{lastchannelsequence} = 1;
+ }
$bot->{lastuse} = $time;
$bot->{lastchannel} = $channel;
- $bot->{lastprogram} = $program;
- $bot->{lastnote} = $note;
+
+# print STDERR "$time $bot->{id} $channel:$note\n"
+# if $channel == 11;
return 1;
}
}
sort
{
- $a->[1] <=> $b->[1]
+ $b->[1] <=> $a->[1]
or
($a->[0]->{lastuse} // -666) <=> ($b->[0]->{lastuse} // -666)
or
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;
- if($program == $_->{lastprogram})
+ if($channel == $_->{lastchannel})
{
- ++$q;
- if($note == $_->{lastnote})
- {
- ++$q;
- }
+ $q += $_->{lastchannelsequence};
+ }
+ else
+ {
+ # better leave this one alone
+ $q -= $_->{lastchannelsequence};
}
}
}
if($midinotes{$chan}{$_->[5]})
{
--$notes_stuck;
- busybot_note_off($t - SYS_TICRATE, $chan, $_->[5]);
+ busybot_note_off($t - SYS_TICRATE - 0.001, $chan, $_->[5]);
}
busybot_note_on($t, $chan, $programs{$chan} || 1, $_->[5]);
++$notes_stuck;
if($midinotes{$chan}{$_->[5]})
{
--$notes_stuck;
- busybot_note_off($t - SYS_TICRATE, $chan, $_->[5]);
+ busybot_note_off($t - SYS_TICRATE - 0.001, $chan, $_->[5]);
}
$midinotes{$chan}{$_->[5]} = 0;
}
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};
my @preallocate_new = map { $_->{classname} } @busybots_allocated;
if(@preallocate_new == @preallocate)
{
+ print "sv_cmd bot_cmd reset\n";
+ print "sv_cmd bot_cmd setbots @{[scalar @preallocate_new]}\n";
print "$precommands$commands";
exit 0;
}