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.1 by root, Wed Jul 11 15:57:30 2007 UTC vs.
Revision 1.2 by root, Wed Jul 11 16:26:26 2007 UTC

1#! perl # mandatory 1#! perl # mandatory
2 2
3# this extension provides "environmental effects", 3# this extension provides "environmental effects",
4# meaning mostly background music and region messages right now. 4# meaning mostly background music and region messages right now.
5
6our %MUSIC_QUEUE;
7
8our $MUSIC_SCHEDULER = cf::async_ext {
9 while () {
10 for (keys %MUSIC_QUEUE) {
11 delete $MUSIC_QUEUE{$_};
12 my $pl = cf::player::find_active $_
13 or next;
14
15 my $map = $pl->ob->map
16 or next;
17
18 # 1. update map-specific music info
19 unless (exists $map->{music}) {
20
21 }
22
23 # 2. fall back to region if no map-specific music
24 unless ($map->{music}) {
25 }
26
27 cf::cede_to_tick;
28 }
29 Coro::schedule unless %MUSIC_QUEUE;
30 }
31};
5 32
6cf::player->attach ( 33cf::player->attach (
7 on_region_change => sub { 34 on_region_change => sub {
8 my ($pl, $new, $old) = @_; 35 my ($pl, $new, $old) = @_;
9 36
10 $pl->ob->message ("You are now " . $new->longname . ". H<Use whereami for more details.>", $new->longname); 37 $pl->ob->message ("You are now " . $new->longname . ". H<Use whereami for more details.>", $new->longname);
38
39 $MUSIC_QUEUE{$pl->ob->name} = undef;
40 $MUSIC_SCHEDULER->ready;
41 },
42 on_map_change => sub {
43 my ($pl, $new) = @_;
44
45 $MUSIC_QUEUE{$pl->ob->name} = undef;
46 $MUSIC_SCHEDULER->ready;
11 }, 47 },
12); 48);
13 49
14 50

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines