1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
|
|
2 | |
|
|
3 | if ($ENV{DELIANTRA_CORO_DEBUG}) { |
|
|
4 | eval ' |
|
|
5 | use Coro; |
|
|
6 | use Coro::EV; |
|
|
7 | use Coro::Debug; |
|
|
8 | our $debug = new_unix_server Coro::Debug "/tmp/dc"; |
|
|
9 | '; |
|
|
10 | } |
2 | |
11 | |
3 | # do splash-screen thingy on win32 |
12 | # do splash-screen thingy on win32 |
4 | my $startup_done = sub { }; |
13 | my $startup_done = sub { }; |
5 | BEGIN { |
14 | BEGIN { |
6 | if (%PAR::LibCache && $^O eq "MSWin32") { |
15 | if (%PAR::LibCache && $^O eq "MSWin32") { |
… | |
… | |
249 | } else { |
258 | } else { |
250 | # fetch from database |
259 | # fetch from database |
251 | CFPlus::DB::get res_data => $meta->{name}, sub { |
260 | CFPlus::DB::get res_data => $meta->{name}, sub { |
252 | my $rwops = new CFPlus::RW $_[0]; |
261 | my $rwops = new CFPlus::RW $_[0]; |
253 | my $chunk = new CFPlus::MixChunk $rwops |
262 | my $chunk = new CFPlus::MixChunk $rwops |
254 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
263 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
255 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
264 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
256 | $AUDIO_CHUNK{$face} = $chunk; |
265 | $AUDIO_CHUNK{$face} = $chunk; |
257 | |
266 | |
258 | audio_sound_push ($face); |
267 | audio_sound_push ($face); |
259 | }; |
268 | }; |
… | |
… | |
335 | return unless $SDL_MIXER; |
344 | return unless $SDL_MIXER; |
336 | |
345 | |
337 | my $fade_out; |
346 | my $fade_out; |
338 | |
347 | |
339 | if (@MUSIC_JINGLE) { |
348 | if (@MUSIC_JINGLE) { |
|
|
349 | $fade_out = 333; |
340 | @MUSIC_HAVE = $MUSIC_JINGLE[0]; |
350 | @MUSIC_HAVE = $MUSIC_JINGLE[0]; |
341 | $fade_out = 333; |
351 | |
342 | } else { |
352 | } else { |
343 | return unless $CFG->{bgm_enable}; |
353 | return unless $CFG->{bgm_enable}; |
344 | |
354 | |
345 | my @have = |
355 | $fade_out = 700; |
|
|
356 | |
|
|
357 | @MUSIC_HAVE = |
346 | grep $_ && $_->{data}, |
358 | grep $_ && $_->{data}, |
347 | map $CONN->{face}[$_], |
359 | map $CONN->{face}[$_], |
348 | @$MUSIC_WANT; |
360 | @$MUSIC_WANT; |
349 | |
361 | |
350 | # randomize music a bit so that the order is not always the same |
362 | # randomize music a bit so that the order is not always the same |
351 | $_->{stop_time} ||= rand for @have; |
363 | $_->{stop_time} ||= rand for @MUSIC_HAVE; |
352 | |
|
|
353 | @MUSIC_HAVE = @have |
|
|
354 | if @have; |
|
|
355 | |
364 | |
356 | # default MUSIC_HAVE == MUSIC_DEFAULT |
365 | # default MUSIC_HAVE == MUSIC_DEFAULT |
357 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
366 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } |
358 | $fade_out = 700; |
367 | unless @MUSIC_HAVE; |
359 | } |
368 | } |
360 | |
369 | |
361 | # if the currently playing song is acceptable, let it continue |
370 | # if the currently playing song is acceptable, let it continue |
362 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
371 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
363 | |
372 | |
… | |
… | |
990 | c_colspan => 2, expand => 1, |
999 | c_colspan => 2, expand => 1, |
991 | value => $CFG->{audio_hw_channels}, |
1000 | value => $CFG->{audio_hw_channels}, |
992 | options => [ |
1001 | options => [ |
993 | [0, "default" , "Use System Default"], |
1002 | [0, "default" , "Use System Default"], |
994 | [1, "Mono" , "Mono (single channel, low quality)"], |
1003 | [1, "Mono" , "Mono (single channel, low quality)"], |
995 | [2, "Stereo" , "Stereo (dual channe, standard quality)"], |
1004 | [2, "Stereo" , "Stereo (dual channel, standard quality)"], |
996 | [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"], |
1005 | [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"], |
997 | [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"], |
1006 | [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"], |
998 | ], |
1007 | ], |
999 | tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
1008 | tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
1000 | on_changed => sub { |
1009 | on_changed => sub { |
… | |
… | |
1341 | my $ok = 0; |
1350 | my $ok = 0; |
1342 | |
1351 | |
1343 | CFPlus::background { |
1352 | CFPlus::background { |
1344 | my $ua = CFPlus::lwp_useragent; |
1353 | my $ua = CFPlus::lwp_useragent; |
1345 | |
1354 | |
1346 | CFPlus::background_msg CFPlus::from_json +(CFPlus::lwp_check $ua->get ($META_SERVER))->decoded_content; |
1355 | CFPlus::background_msg CFPlus::decode_json +(CFPlus::lwp_check $ua->get ($META_SERVER))->decoded_content; |
1347 | } sub { |
1356 | } sub { |
1348 | my ($msg) = @_; |
1357 | my ($msg) = @_; |
1349 | if ($msg) { |
1358 | if ($msg) { |
1350 | $table->clear; |
1359 | $table->clear; |
1351 | |
1360 | |