--- deliantra/server/ext/player-env.ext 2007/07/11 17:09:06 1.3 +++ deliantra/server/ext/player-env.ext 2007/07/12 08:40:13 1.4 @@ -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$_"), + split /\s*,\s*/, $list + ] } our %MUSIC_QUEUE; @@ -22,6 +27,12 @@ my $pl = cf::player::find_active $_ or next; + my $ns = $pl->ns + or next; + + $ns->extcmd + or next; + my $faces; my $map = $pl->ob->map @@ -53,8 +64,23 @@ $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 = { + faces => $faces, + }; + + $msg->{chksum}{$_} = cf::face::get_chksum $_ + for grep $ns->must_send_face ($_), @$faces; + + $ns->ext_event (music => %$msg); cf::cede_to_tick; }