ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/deliantra
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/deliantra (file contents):
Revision 1.5 by root, Wed Nov 14 23:50:29 2007 UTC vs.
Revision 1.12 by root, Wed Dec 26 13:35:06 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3if ($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
4my $startup_done = sub { }; 13my $startup_done = sub { };
5BEGIN { 14BEGIN {
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
460 my ($conn, $flags, $prompt) = @_; 469 my ($conn, $flags, $prompt) = @_;
461 470
462 # FIXME: a very ugly hack to wait for stat update #d# 471 # FIXME: a very ugly hack to wait for stat update #d#
463 if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { 472 if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) {
464 unless ($QUERY_TIMER) { 473 unless ($QUERY_TIMER) {
465 $QUERY_TIMER =
466 EV::timer 1, 0, sub { 474 $QUERY_TIMER = EV::timer 1, 0, sub {
467 server_query ($conn, $flags, $prompt, 1); 475 server_query ($conn, $flags, $prompt, 1);
468 $QUERY_TIMER = undef 476 $QUERY_TIMER = undef
469 }; 477 };
478
470 return; 479 return;
471 } 480 }
472 } 481 }
473 482
474 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel 483 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel
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
2261my $animate_timer; 2270my $animate_timer;
2262 2271
2263my $fps = 9; 2272my $fps = 9;
2264 2273
2265sub force_refresh { 2274sub force_refresh {
2266 $WANT_REFRESH->stop;
2267
2268 if ($ENV{CFPLUS_DEBUG} & 4) { 2275 if ($ENV{CFPLUS_DEBUG} & 4) {
2269 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; 2276 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
2270 debug sprintf "%3.2f", $fps; 2277 debug sprintf "%3.2f", $fps;
2271 } 2278 }
2279
2280 $WANT_REFRESH->stop;
2272 2281
2273 $CFPlus::UI::ROOT->draw; 2282 $CFPlus::UI::ROOT->draw;
2274 CFPlus::SDL_GL_SwapBuffers; 2283 CFPlus::SDL_GL_SwapBuffers;
2275 $LAST_REFRESH = $NOW; 2284 $LAST_REFRESH = $NOW;
2276} 2285}
2307 }, 2316 },
2308 CFPlus::SDL_VIDEOEXPOSE => sub { 2317 CFPlus::SDL_VIDEOEXPOSE => sub {
2309 CFPlus::UI::full_refresh; 2318 CFPlus::UI::full_refresh;
2310 }, 2319 },
2311 CFPlus::SDL_ACTIVEEVENT => sub { 2320 CFPlus::SDL_ACTIVEEVENT => sub {
2312# not useful, as APPACTIVE include sonly iconified state, not unmapped 2321# not useful, as APPACTIVE includes only iconified state, not unmapped
2313# printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, CFPlus::SDL_GetAppState;#d# 2322# printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, CFPlus::SDL_GetAppState;#d#
2314# printf "a %x\n", CFPlus::SDL_GetAppState & CFPlus::SDL_APPACTIVE;#d# 2323# printf "a %x\n", CFPlus::SDL_GetAppState & CFPlus::SDL_APPACTIVE;#d#
2315# printf "A\n" if $_[0]{state} & CFPlus::SDL_APPACTIVE; 2324# printf "A\n" if $_[0]{state} & CFPlus::SDL_APPACTIVE;
2316# printf "K\n" if $_[0]{state} & CFPlus::SDL_APPINPUTFOCUS; 2325# printf "K\n" if $_[0]{state} & CFPlus::SDL_APPINPUTFOCUS;
2317# printf "M\n" if $_[0]{state} & CFPlus::SDL_APPMOUSEFOCUS; 2326# printf "M\n" if $_[0]{state} & CFPlus::SDL_APPMOUSEFOCUS;
2339 }, 2348 },
2340); 2349);
2341 2350
2342############################################################################# 2351#############################################################################
2343 2352
2344$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};
2345 2357
2346{ 2358{
2347 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; 2359 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc";
2348 CFPlus::DB::Server::run; 2360 CFPlus::DB::Server::run;
2349 2361

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines