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.6 by root, Thu Jul 12 19:10:48 2007 UTC vs.
Revision 1.14 by root, Thu Aug 30 08:34:40 2007 UTC

17 split /\s*,\s*/, $list 17 split /\s*,\s*/, $list
18 ] 18 ]
19} 19}
20 20
21our %MUSIC_QUEUE; 21our %MUSIC_QUEUE;
22our %MUSIC_FACE_CACHE; # cleared by reload_facedata
22 23
23our $MUSIC_SCHEDULER = cf::async_ext { 24our $MUSIC_SCHEDULER = cf::async_ext {
24 while () { 25 while () {
25 for (keys %MUSIC_QUEUE) { 26 for (keys %MUSIC_QUEUE) {
26 delete $MUSIC_QUEUE{$_}; 27 delete $MUSIC_QUEUE{$_};
28
29 cf::get_slot 0.01, -10, "music scheduler";
27 30
28 my $pl = cf::player::find_active $_ or next; 31 my $pl = cf::player::find_active $_ or next;
29 $pl->ob->active or next; 32 $pl->ob->active or next;
30 my $ns = $pl->ns or next; 33 my $ns = $pl->ns or next;
31 $ns->extcmd or next; 34 $ns->extcmd or next;
32 my $map = $pl->ob->map or next; 35 my $map = $pl->ob->map or next;
33 36
34 my $faces; 37 my $faces = $MUSIC_FACE_CACHE{$map} ||= do {
38 # 1. map-specific music info
39 parse_facelist "music/", $map->{music}
40 or do {
41 # 2. fall back to region if no map-specific music
42 my $rgn = $pl->ob->region
43 or next;
35 44
36 # 1. update map-specific music info 45 my $par = $rgn;
37 unless (exists $map->{music_faces}) { 46 while () {
38 $map->{music_faces} = parse_facelist "music/", $map->{music}; 47 last if exists $par->{music};
39 } 48 $par = $par->parent
49 or last;
50 }
40 51
41 my $faces = $map->{music_faces}; 52 parse_facelist "music/", $par->{music}
42
43 # 2. fall back to region if no map-specific music
44 unless ($faces) {
45 my $rgn = $pl->ob->region
46 or next;
47
48 unless (exists $rgn->{music_faces}) {
49 my $par = $rgn;
50 while () {
51 last if exists $par->{music};
52 $par = $par->parent
53 or last;
54 } 53 }
55
56 $rgn->{music_faces} = parse_facelist "music/", $par->{music};
57 } 54 ;
58
59 $faces = $rgn->{music_faces};
60 } 55 };
61 56
62 $faces 57 $faces
63 or next; 58 or next;
64 59
65 my $facestr = join ",", @$faces; 60 my $facestr = join ",", @$faces;
66 $ns->{current_music_faces} ne $facestr 61 $ns->{current_music_faces} ne $facestr
67 or next; 62 or next;
68 63
69 warn "MUSIC CHANGE <$ns->{current_music_faces}> <$facestr>\n";#d#
70
71 $ns->{current_music_faces} = $facestr; 64 $ns->{current_music_faces} = $facestr;
72 65
73 my $msg = { 66 my $pri = 0;
74 play => $faces, 67 $ns->send_face ($_, --$pri - 110)
75 }; 68 for @$faces;
69 $ns->flush_fx;
76 70
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); 71 $ns->ext_msg (ambient_music => $faces);
82
83 cf::cede_to_tick;
84 } 72 }
85 Coro::schedule unless %MUSIC_QUEUE; 73 Coro::schedule unless %MUSIC_QUEUE;
86 } 74 }
87}; 75};
88 76

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines