… | |
… | |
22 | |
22 | |
23 | our $MUSIC_SCHEDULER = cf::async_ext { |
23 | our $MUSIC_SCHEDULER = cf::async_ext { |
24 | while () { |
24 | while () { |
25 | for (keys %MUSIC_QUEUE) { |
25 | for (keys %MUSIC_QUEUE) { |
26 | delete $MUSIC_QUEUE{$_}; |
26 | delete $MUSIC_QUEUE{$_}; |
|
|
27 | |
|
|
28 | cf::get_slot 0.01, -10; |
27 | |
29 | |
28 | my $pl = cf::player::find_active $_ or next; |
30 | my $pl = cf::player::find_active $_ or next; |
29 | $pl->ob->active or next; |
31 | $pl->ob->active or next; |
30 | my $ns = $pl->ns or next; |
32 | my $ns = $pl->ns or next; |
31 | $ns->extcmd or next; |
33 | $ns->extcmd or next; |
… | |
… | |
64 | |
66 | |
65 | my $facestr = join ",", @$faces; |
67 | my $facestr = join ",", @$faces; |
66 | $ns->{current_music_faces} ne $facestr |
68 | $ns->{current_music_faces} ne $facestr |
67 | or next; |
69 | or next; |
68 | |
70 | |
69 | warn "MUSIC CHANGE <$ns->{current_music_faces}> <$facestr>\n";#d# |
|
|
70 | |
|
|
71 | $ns->{current_music_faces} = $facestr; |
71 | $ns->{current_music_faces} = $facestr; |
72 | |
72 | |
73 | my $msg = { |
73 | my $msg = { |
74 | play => $faces, |
74 | play => $faces, |
75 | }; |
75 | }; |
… | |
… | |
77 | my $pri = 0; |
77 | my $pri = 0; |
78 | push @{$msg->{faces}}, [$_, $pri++, cf::face::get_chksum $_] |
78 | push @{$msg->{faces}}, [$_, $pri++, cf::face::get_chksum $_] |
79 | for grep $ns->must_send_face ($_), @$faces; |
79 | for grep $ns->must_send_face ($_), @$faces; |
80 | |
80 | |
81 | $ns->ext_event (music => %$msg); |
81 | $ns->ext_event (music => %$msg); |
82 | |
|
|
83 | cf::cede_to_tick; |
|
|
84 | } |
82 | } |
85 | Coro::schedule unless %MUSIC_QUEUE; |
83 | Coro::schedule unless %MUSIC_QUEUE; |
86 | } |
84 | } |
87 | }; |
85 | }; |
88 | |
86 | |