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.3 by root, Wed Jul 11 17:09:06 2007 UTC vs.
Revision 1.6 by root, Thu Jul 12 19:10:48 2007 UTC

7 my ($prefix, $list) = @_; 7 my ($prefix, $list) = @_;
8 8
9 return undef 9 return undef
10 unless defined $list; 10 unless defined $list;
11 11
12 #TODO 12 #TODO, sort by size (smallest first...)
13 [sort grep $_, map +(cf::face::find "$prefix$_"), split /\s*,\s*/, $list] 13 [
14 sort { (cf::face::get_data_size $a) <=> (cf::face::get_data_size $b) }
15 grep $_,
16 map +(cf::face::find "$prefix$_" or ((warn "unable to find music file $_"), undef)),
17 split /\s*,\s*/, $list
18 ]
14} 19}
15 20
16our %MUSIC_QUEUE; 21our %MUSIC_QUEUE;
17 22
18our $MUSIC_SCHEDULER = cf::async_ext { 23our $MUSIC_SCHEDULER = cf::async_ext {
19 while () { 24 while () {
20 for (keys %MUSIC_QUEUE) { 25 for (keys %MUSIC_QUEUE) {
21 delete $MUSIC_QUEUE{$_}; 26 delete $MUSIC_QUEUE{$_};
27
22 my $pl = cf::player::find_active $_ 28 my $pl = cf::player::find_active $_ or next;
23 or next; 29 $pl->ob->active or next;
30 my $ns = $pl->ns or next;
31 $ns->extcmd or next;
32 my $map = $pl->ob->map or next;
24 33
25 my $faces; 34 my $faces;
26
27 my $map = $pl->ob->map
28 or next;
29 35
30 # 1. update map-specific music info 36 # 1. update map-specific music info
31 unless (exists $map->{music_faces}) { 37 unless (exists $map->{music_faces}) {
32 $map->{music_faces} = parse_facelist "music/", $map->{music}; 38 $map->{music_faces} = parse_facelist "music/", $map->{music};
33 } 39 }
51 } 57 }
52 58
53 $faces = $rgn->{music_faces}; 59 $faces = $rgn->{music_faces};
54 } 60 }
55 61
56 warn "music for $pl is @$faces\n"
57 if $faces; 62 $faces
63 or next;
64
65 my $facestr = join ",", @$faces;
66 $ns->{current_music_faces} ne $facestr
67 or next;
68
69 warn "MUSIC CHANGE <$ns->{current_music_faces}> <$facestr>\n";#d#
70
71 $ns->{current_music_faces} = $facestr;
72
73 my $msg = {
74 play => $faces,
75 };
76
77 my $pri = 0;
78 push @{$msg->{faces}}, [$_, $pri++, cf::face::get_chksum $_]
79 for grep $ns->must_send_face ($_), @$faces;
80
81 $ns->ext_event (music => %$msg);
58 82
59 cf::cede_to_tick; 83 cf::cede_to_tick;
60 } 84 }
61 Coro::schedule unless %MUSIC_QUEUE; 85 Coro::schedule unless %MUSIC_QUEUE;
62 } 86 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines