ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/player-env.ext
(Generate patch)

Comparing deliantra/server/ext/player-env.ext (file contents):
Revision 1.4 by root, Thu Jul 12 08:40:13 2007 UTC vs.
Revision 1.10 by root, Mon Jul 23 21:02:50 2007 UTC

11 11
12 #TODO, sort by size (smallest first...) 12 #TODO, sort by size (smallest first...)
13 [ 13 [
14 sort { (cf::face::get_data_size $a) <=> (cf::face::get_data_size $b) } 14 sort { (cf::face::get_data_size $a) <=> (cf::face::get_data_size $b) }
15 grep $_, 15 grep $_,
16 map +(cf::face::find "$prefix$_"), 16 map +(cf::face::find "$prefix$_" or ((warn "unable to find music file $_"), undef)),
17 split /\s*,\s*/, $list 17 split /\s*,\s*/, $list
18 ] 18 ]
19} 19}
20 20
21our %MUSIC_QUEUE; 21our %MUSIC_QUEUE;
22 22
23our $MUSIC_SCHEDULER = cf::async_ext { 23our $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
30 my $ns = $pl->ns 28 cf::get_slot 0.01, -10, "music scheduler";
31 or next;
32 29
30 my $pl = cf::player::find_active $_ or next;
31 $pl->ob->active or next;
32 my $ns = $pl->ns or next;
33 $ns->extcmd 33 $ns->extcmd or next;
34 or next; 34 my $map = $pl->ob->map or next;
35 35
36 my $faces; 36 my $faces;
37
38 my $map = $pl->ob->map
39 or next;
40 37
41 # 1. update map-specific music info 38 # 1. update map-specific music info
42 unless (exists $map->{music_faces}) { 39 unless (exists $map->{music_faces}) {
43 $map->{music_faces} = parse_facelist "music/", $map->{music}; 40 $map->{music_faces} = parse_facelist "music/", $map->{music};
44 } 41 }
72 or next; 69 or next;
73 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_msg (music => %$msg);
84
85 cf::cede_to_tick;
86 } 82 }
87 Coro::schedule unless %MUSIC_QUEUE; 83 Coro::schedule unless %MUSIC_QUEUE;
88 } 84 }
89}; 85};
90 86

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines