--- deliantra/server/ext/player-env.ext 2007/07/11 17:09:06 1.3 +++ deliantra/server/ext/player-env.ext 2007/07/23 16:53:15 1.8 @@ -9,8 +9,13 @@ return undef unless defined $list; - #TODO - [sort grep $_, map +(cf::face::find "$prefix$_"), split /\s*,\s*/, $list] + #TODO, sort by size (smallest first...) + [ + sort { (cf::face::get_data_size $a) <=> (cf::face::get_data_size $b) } + grep $_, + map +(cf::face::find "$prefix$_" or ((warn "unable to find music file $_"), undef)), + split /\s*,\s*/, $list + ] } our %MUSIC_QUEUE; @@ -19,13 +24,16 @@ while () { for (keys %MUSIC_QUEUE) { delete $MUSIC_QUEUE{$_}; - my $pl = cf::player::find_active $_ - or next; - my $faces; + cf::get_slot 0.01, -10; - my $map = $pl->ob->map - or next; + my $pl = cf::player::find_active $_ or next; + $pl->ob->active or next; + my $ns = $pl->ns or next; + $ns->extcmd or next; + my $map = $pl->ob->map or next; + + my $faces; # 1. update map-specific music info unless (exists $map->{music_faces}) { @@ -53,10 +61,24 @@ $faces = $rgn->{music_faces}; } - warn "music for $pl is @$faces\n" - if $faces; + $faces + or next; + + my $facestr = join ",", @$faces; + $ns->{current_music_faces} ne $facestr + or next; + + $ns->{current_music_faces} = $facestr; + + my $msg = { + play => $faces, + }; + + my $pri = 0; + push @{$msg->{faces}}, [$_, $pri++, cf::face::get_chksum $_] + for grep $ns->must_send_face ($_), @$faces; - cf::cede_to_tick; + $ns->ext_event (music => %$msg); } Coro::schedule unless %MUSIC_QUEUE; }