… | |
… | |
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 | my $pl = cf::player::find_active $_ |
|
|
28 | or next; |
|
|
29 | |
27 | |
|
|
28 | my $pl = cf::player::find_active $_ or next; |
|
|
29 | $pl->ob->active or next; |
30 | my $ns = $pl->ns |
30 | my $ns = $pl->ns or next; |
31 | or next; |
|
|
32 | |
|
|
33 | $ns->extcmd |
31 | $ns->extcmd or next; |
34 | or next; |
32 | my $map = $pl->ob->map or next; |
35 | |
33 | |
36 | my $faces; |
34 | my $faces; |
37 | |
|
|
38 | my $map = $pl->ob->map |
|
|
39 | or next; |
|
|
40 | |
35 | |
41 | # 1. update map-specific music info |
36 | # 1. update map-specific music info |
42 | unless (exists $map->{music_faces}) { |
37 | unless (exists $map->{music_faces}) { |
43 | $map->{music_faces} = parse_facelist "music/", $map->{music}; |
38 | $map->{music_faces} = parse_facelist "music/", $map->{music}; |
44 | } |
39 | } |
… | |
… | |
69 | |
64 | |
70 | my $facestr = join ",", @$faces; |
65 | my $facestr = join ",", @$faces; |
71 | $ns->{current_music_faces} ne $facestr |
66 | $ns->{current_music_faces} ne $facestr |
72 | or next; |
67 | or next; |
73 | |
68 | |
|
|
69 | warn "MUSIC CHANGE <$ns->{current_music_faces}> <$facestr>\n";#d# |
|
|
70 | |
74 | $ns->{current_music_faces} = $facestr; |
71 | $ns->{current_music_faces} = $facestr; |
75 | |
72 | |
76 | my $msg = { |
73 | my $msg = { |
77 | faces => $faces, |
74 | play => $faces, |
78 | }; |
75 | }; |
79 | |
76 | |
80 | $msg->{chksum}{$_} = cf::face::get_chksum $_ |
77 | my $pri = 0; |
|
|
78 | push @{$msg->{faces}}, [$_, $pri++, cf::face::get_chksum $_] |
81 | for grep $ns->must_send_face ($_), @$faces; |
79 | for grep $ns->must_send_face ($_), @$faces; |
82 | |
80 | |
83 | $ns->ext_event (music => %$msg); |
81 | $ns->ext_event (music => %$msg); |
84 | |
82 | |
85 | cf::cede_to_tick; |
83 | cf::cede_to_tick; |