… | |
… | |
344 | return unless $SDL_MIXER; |
344 | return unless $SDL_MIXER; |
345 | |
345 | |
346 | my $fade_out; |
346 | my $fade_out; |
347 | |
347 | |
348 | if (@MUSIC_JINGLE) { |
348 | if (@MUSIC_JINGLE) { |
|
|
349 | $fade_out = 333; |
349 | @MUSIC_HAVE = $MUSIC_JINGLE[0]; |
350 | @MUSIC_HAVE = $MUSIC_JINGLE[0]; |
350 | $fade_out = 333; |
351 | |
351 | } else { |
352 | } else { |
352 | return unless $CFG->{bgm_enable}; |
353 | return unless $CFG->{bgm_enable}; |
353 | |
354 | |
354 | my @have = |
355 | $fade_out = 700; |
|
|
356 | |
|
|
357 | @MUSIC_HAVE = |
355 | grep $_ && $_->{data}, |
358 | grep $_ && $_->{data}, |
356 | map $CONN->{face}[$_], |
359 | map $CONN->{face}[$_], |
357 | @$MUSIC_WANT; |
360 | @$MUSIC_WANT; |
358 | |
361 | |
359 | # 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 |
360 | $_->{stop_time} ||= rand for @have; |
363 | $_->{stop_time} ||= rand for @MUSIC_HAVE; |
361 | |
|
|
362 | @MUSIC_HAVE = @have |
|
|
363 | if @have; |
|
|
364 | |
364 | |
365 | # default MUSIC_HAVE == MUSIC_DEFAULT |
365 | # default MUSIC_HAVE == MUSIC_DEFAULT |
366 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
366 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } |
367 | $fade_out = 700; |
367 | unless @MUSIC_HAVE; |
368 | } |
368 | } |
369 | |
369 | |
370 | # if the currently playing song is acceptable, let it continue |
370 | # if the currently playing song is acceptable, let it continue |
371 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
371 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
372 | |
372 | |
… | |
… | |
469 | my ($conn, $flags, $prompt) = @_; |
469 | my ($conn, $flags, $prompt) = @_; |
470 | |
470 | |
471 | # FIXME: a very ugly hack to wait for stat update #d# |
471 | # FIXME: a very ugly hack to wait for stat update #d# |
472 | if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { |
472 | if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { |
473 | unless ($QUERY_TIMER) { |
473 | unless ($QUERY_TIMER) { |
474 | $QUERY_TIMER = |
|
|
475 | EV::timer 1, 0, sub { |
474 | $QUERY_TIMER = EV::timer 1, 0, sub { |
476 | server_query ($conn, $flags, $prompt, 1); |
475 | server_query ($conn, $flags, $prompt, 1); |
477 | $QUERY_TIMER = undef |
476 | $QUERY_TIMER = undef |
478 | }; |
477 | }; |
|
|
478 | |
479 | return; |
479 | return; |
480 | } |
480 | } |
481 | } |
481 | } |
482 | |
482 | |
483 | $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel |
483 | $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel |
… | |
… | |
2348 | }, |
2348 | }, |
2349 | ); |
2349 | ); |
2350 | |
2350 | |
2351 | ############################################################################# |
2351 | ############################################################################# |
2352 | |
2352 | |
2353 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
2353 | $SIG{INT} = $SIG{TERM} = sub { |
|
|
2354 | EV::unloop; |
|
|
2355 | #d# TODO calling exit here hangs the process in some futex |
|
|
2356 | }; |
2354 | |
2357 | |
2355 | { |
2358 | { |
2356 | CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; |
2359 | CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; |
2357 | CFPlus::DB::Server::run; |
2360 | CFPlus::DB::Server::run; |
2358 | |
2361 | |