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.109 by root, Thu Apr 8 19:11:21 2010 UTC vs.
Revision 1.117 by root, Tue Aug 31 14:31:50 2010 UTC

17 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); 17 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp");
18 } 18 }
19 19
20 require Win32::GUI::SplashScreen; 20 require Win32::GUI::SplashScreen;
21 21
22 # initialise the resolver now, as vista forces us back to the desktop
23 # when doing this.
24 use AnyEvent::DNS ();
25 AnyEvent::DNS::resolver;
26
27 Win32::GUI::SplashScreen::Show ( 22 Win32::GUI::SplashScreen::Show (
28 -file => "$ENV{PAR_TEMP}/SPLASH.bmp", 23 -file => "$ENV{PAR_TEMP}/SPLASH.bmp",
29 ); 24 );
25
26 # initialise the resolver now, as vista forces us back to the desktop
27 # when doing this later.
28 require AnyEvent::DNS;
29 AnyEvent::DNS::resolver ();
30 30
31 $startup_done = sub { 31 $startup_done = sub {
32 Win32::GUI::SplashScreen::Done (1); 32 Win32::GUI::SplashScreen::Done (1);
33 }; 33 };
34 } 34 }
143our $NOW; 143our $NOW;
144 144
145our $CFG; 145our $CFG;
146our $PROFILE; # current profile 146our $PROFILE; # current profile
147our $FAST; # fast, low-quality mode, possibly useful for software-rendering 147our $FAST; # fast, low-quality mode, possibly useful for software-rendering
148our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1;
148 149
149our $WANT_REFRESH; 150our $WANT_REFRESH;
150 151
151our $MODE_SLIDER; 152our $MODE_SLIDER;
152our $CAVEAT_LABEL; 153our $CAVEAT_LABEL;
517 audio_music_push; 518 audio_music_push;
518} 519}
519 520
520sub audio_init { 521sub audio_init {
521 if ($CFG->{audio_enable}) { 522 if ($CFG->{audio_enable}) {
523 if (length $CFG->{audio_driver}) {
524 local $ENV{SDL_AUDIODRIVER} = $CFG->{audio_driver};
525 DC::SDL_Init DC::SDL_INIT_AUDIO
526 and die "SDL::Init failed!\n";
527 } else {
528 DC::SDL_Init DC::SDL_INIT_AUDIO
529 and die "SDL::Init failed!\n";
530 }
531
522 $ENV{MIX_EFFECTSMAXSPEED} = 1; 532 $ENV{MIX_EFFECTSMAXSPEED} = 1;
523 $SDL_MIXER = !DC::Mix_OpenAudio 533 $SDL_MIXER = !DC::Mix_OpenAudio
524 $CFG->{audio_hw_frequency}, 534 $CFG->{audio_hw_frequency},
525 DC::MIX_DEFAULT_FORMAT, 535 DC::MIX_DEFAULT_FORMAT,
526 $CFG->{audio_hw_channels}, 536 $CFG->{audio_hw_channels},
556 %AUDIO_PLAY = (); 566 %AUDIO_PLAY = ();
557 %AUDIO_CHUNK = (); 567 %AUDIO_CHUNK = ();
558 568
559 DC::Mix_CloseAudio if $SDL_MIXER; 569 DC::Mix_CloseAudio if $SDL_MIXER;
560 undef $SDL_MIXER; 570 undef $SDL_MIXER;
571
572 DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO;
561} 573}
562 574
563############################################################################# 575#############################################################################
564 576
565sub destroy_query_dialog { 577sub destroy_query_dialog {
853 865
854 # hack to make SURE we find the IP address all right 866 # hack to make SURE we find the IP address all right
855 # can be removed once AnyEvent::DNS is proven stable. 867 # can be removed once AnyEvent::DNS is proven stable.
856 if ($host eq "gameserver.deliantra.net") { 868 if ($host eq "gameserver.deliantra.net") {
857 AnyEvent::DNS::a "dnstest.deliantra.net", sub { 869 AnyEvent::DNS::a "dnstest.deliantra.net", sub {
858 if ($_[0] ne "80.101.114.108") { # Perl 870 if ($_[0] ne "80.101.114.108") { # P-e-r-l
859 status "dns failure, trying differently"; 871 status "dns failure, trying differently";
860 $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; 872 $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" };
861 unless (defined $host) { 873 unless (defined $host) {
862 status "dns failure, using hardcoded address"; 874 status "dns failure, using hardcoded address";
863 $host = "129.13.162.95"; 875 $host = "194.126.175.154";
864 } 876 }
865 } 877 }
866 878
867 dc_connect $host, $port; 879 dc_connect $host, $port;
868 }; 880 };
1144 ]); 1156 ]);
1145 1157
1146 my $text = !$freq 1158 my $text = !$freq
1147 ? "audio is off" 1159 ? "audio is off"
1148 : "audio is enabled\n" 1160 : "audio is enabled\n"
1161 . "driver: " . DC::SDL_AudioDriverName . "\n"
1149 . "frequency (Hz): $freq\n" 1162 . "frequency (Hz): $freq\n"
1150 . "channels: $chans\n" 1163 . "channels: $chans\n"
1151 . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n" 1164 . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n"
1152 . "music decoders available: " . (join ", ", DC::MixMusic::decoders); 1165 . "music decoders available: " . (join ", ", DC::MixMusic::decoders);
1153 1166
1154 $AUDIO_INFO->set_text ($text); 1167 $AUDIO_INFO->set_text ($text);
1155} 1168}
1156 1169
1157sub audio_setup { 1170sub audio_setup {
1160 $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]); 1173 $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]);
1161 1174
1162 my $row = 0; 1175 my $row = 0;
1163 1176
1164 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable"); 1177 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable");
1165 $table->add_at (1, $row++, new DC::UI::CheckBox 1178 $table->add_at (1, $row, new DC::UI::CheckBox
1166 state => $CFG->{audio_enable}, 1179 state => $CFG->{audio_enable},
1167 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", 1180 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
1168 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } 1181 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 }
1182 );
1183 $table->add_at (2, $row++, my $driver = new DC::UI::HBox expand => 1);
1184
1185 $driver->add (new DC::UI::Label align => 1, text => " Audio driver override");
1186 $driver->add (new DC::UI::Entry
1187 text => $CFG->{audio_driver},
1188 template => "dsound1234",
1189 tooltip => "You can override the audio driver to use here. Leaving it empty will result "
1190 . "in Deliantra picking one automatically. GNU/Linux users often prefer specific "
1191 . "drivers though, and can experiment with <b>alsa</b>, <b>dsp</b>, <b>esd</b>, <b>pulse</b>, <b>arts</b>, <b>nas</b> "
1192 . "or other system-specific drivers. Selecting the wrong driver here will simply result"
1193 . "in no sound.",
1194 on_changed => sub { my ($self, $value) = @_; $CFG->{audio_driver} = $value; 1 }
1169 ); 1195 );
1170 1196
1171 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); 1197 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects");
1172 $table->add_at (1, $row, new DC::UI::CheckBox 1198 $table->add_at (1, $row, new DC::UI::CheckBox
1173 expand => 1, state => $CFG->{effects_enable}, 1199 expand => 1, state => $CFG->{effects_enable},
1186 ); 1212 );
1187 1213
1188 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); 1214 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music");
1189 $table->add_at (1, $row, new DC::UI::CheckBox 1215 $table->add_at (1, $row, new DC::UI::CheckBox
1190 expand => 1, state => $CFG->{bgm_enable}, 1216 expand => 1, state => $CFG->{bgm_enable},
1191 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 1217 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played. Needs server reconnect to take effect.",
1192 on_changed => sub { 1218 on_changed => sub {
1193 $CFG->{bgm_enable} = $_[1]; 1219 $CFG->{bgm_enable} = $_[1];
1194 $CONN->update_fx_want if $CONN; 1220 $CONN->update_fx_want if $CONN;
1195 audio_music_push; 1221 audio_music_push;
1196 1 1222 1
1207 c_colspan => 2, expand => 1, 1233 c_colspan => 2, expand => 1,
1208 value => $CFG->{audio_hw_frequency}, 1234 value => $CFG->{audio_hw_frequency},
1209 options => [ 1235 options => [
1210 [ 0, "default" , "Use System Default"], 1236 [ 0, "default" , "Use System Default"],
1211 [11025, "11 kHz" , "11kHz (low quality)"], 1237 [11025, "11 kHz" , "11kHz (low quality)"],
1212 [22050, "22 kHz" , "22kHz (reduced quality)"], 1238 [22050, "22 kHz" , "22kHz (reduced quality, recommended)"],
1213 [44100, "44.1 kHz", "44.1kHz (cd quality)"], 1239 [44100, "44.1 kHz", "44.1kHz (cd quality)"],
1214 [48000, "48 kHz" , "48kHz (studio quality)"], 1240 [48000, "48 kHz" , "48kHz (studio quality, not recommended)"],
1215 ], 1241 ],
1216 tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", 1242 tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
1217 on_changed => sub { 1243 on_changed => sub {
1218 $CFG->{audio_hw_frequency} = $_[1]; 1244 $CFG->{audio_hw_frequency} = $_[1];
1219 audio_tab_update; 1245 audio_tab_update;
1243 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency"); 1269 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency");
1244 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector 1270 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector
1245 c_colspan => 2, expand => 1, 1271 c_colspan => 2, expand => 1,
1246 value => $CFG->{audio_hw_chunksize}, 1272 value => $CFG->{audio_hw_chunksize},
1247 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " 1273 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback "
1248 . "is stuttering, increase this value. Values of 50-100ms are optimal.", 1274 . "is stuttering, increase this value. Values of 50-150ms are optimal.",
1249 on_changed => sub { 1275 on_changed => sub {
1250 $CFG->{audio_hw_chunksize} = $_[1]; 1276 $CFG->{audio_hw_chunksize} = $_[1];
1251 audio_tab_update; 1277 audio_tab_update;
1252 1 1278 1
1253 } 1279 }
1333 &set_gauge_window_fontsize; 1359 &set_gauge_window_fontsize;
1334 1360
1335 $win 1361 $win
1336} 1362}
1337 1363
1364our $BW_WATCHER;
1365
1366sub debug_toggle($) {
1367 $DELIANTRA_DEBUG ^= $_[0];
1368
1369 if ($DELIANTRA_DEBUG & 16) {
1370 $BW_WATCHER = EV::periodic 0, 1, 0, sub {
1371 return unless $CONN;
1372 debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3;
1373 $CONN->{octets_in} = 0;
1374 };
1375 } else {
1376 undef $BW_WATCHER;
1377 }
1378
1379}
1380
1338sub debug_setup { 1381sub debug_setup {
1339 my $table = new DC::UI::Table; 1382 my $table = new DC::UI::Table;
1340 1383
1341 $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); 1384 $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders");
1342 $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); 1385 $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { debug_toggle 1; 0 });
1343 $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); 1386 $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info");
1344 $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); 1387 $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { debug_toggle 2; 0 });
1345 $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); 1388 $table->add_at (0, 2, new DC::UI::Label text => "Show FPS");
1346 $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); 1389 $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { debug_toggle 4; 0 });
1347 $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); 1390 $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips");
1348 $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); 1391 $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { debug_toggle 8; 0 });
1392 $table->add_at (0, 4, new DC::UI::Label text => "Show Bandwidth");
1393 $table->add_at (1, 4, new DC::UI::CheckBox on_changed => sub { debug_toggle 16; 0 });
1394
1349 $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); 1395 $table->add_at (0, 6, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } );
1350
1351 $table->add_at (0, 5, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# 1396 $table->add_at (0, 7, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d#
1352 1397
1353 $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); 1398 $table->add_at (7,7, my $t = new DC::UI::Table expand => 0);
1354 $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); 1399 $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2);
1355 $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); 1400 $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 );
1356 $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); 1401 $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2);
1477 para => ["Paralysation", 1522 para => ["Paralysation",
1478 "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"], 1523 "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"],
1479 deat => ["Death", 1524 deat => ["Death",
1480 "<b>Death</b> (resistance against death spells)"], 1525 "<b>Death</b> (resistance against death spells)"],
1481 phys => ["Physical", 1526 phys => ["Physical",
1482 "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)"], 1527 "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed as the 'Arm' secondary stat.)"],
1483 blind => ["Blind", 1528 blind => ["Blind",
1484 "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"], 1529 "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"],
1485 fear => ["Fear", 1530 fear => ["Fear",
1486 "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"], 1531 "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"],
1487 tund => ["Turn undead", 1532 tund => ["Turn undead",
2418 2463
2419 $dialog->show; 2464 $dialog->show;
2420 }; 2465 };
2421} 2466}
2422 2467
2423sub sdl_init {
2424 DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE
2425 and die "SDL::Init failed!\n";
2426}
2427
2428sub video_init { 2468sub video_init {
2429 DC::set_theme $CFG->{uitheme}; 2469 DC::set_theme $CFG->{uitheme};
2430 2470
2431 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; 2471 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT;
2432 $SDL_REINIT = 0; 2472 $SDL_REINIT = 0;
2491 2531
2492 $DEBUG_STATUS = new DC::UI::Label 2532 $DEBUG_STATUS = new DC::UI::Label
2493 padding => 0, 2533 padding => 0,
2494 z => 100, 2534 z => 100,
2495 force_x => "max", 2535 force_x => "max",
2496 force_y => 0; 2536 force_y => 20;
2497 $DEBUG_STATUS->show; 2537 $DEBUG_STATUS->show;
2498 2538
2499 $STATUSBOX = new DC::UI::Statusbox; 2539 $STATUSBOX = new DC::UI::Statusbox;
2500 2540
2501 $MODBOX = new DC::UI::Label 2541 $MODBOX = new DC::UI::Label
2629my $animate_timer; 2669my $animate_timer;
2630 2670
2631my $fps = 9; 2671my $fps = 9;
2632 2672
2633sub force_refresh { 2673sub force_refresh {
2634 if ($ENV{CFPLUS_DEBUG} & 4) { 2674 if ($DELIANTRA_DEBUG & 4) {
2635 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; 2675 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
2636 debug sprintf "%3.2f", $fps; 2676 debug sprintf "%3.2f", $fps;
2637 } 2677 }
2638 2678
2639 undef $WANT_REFRESH; 2679 undef $WANT_REFRESH;
2792 $CFG->{$k} = $v unless exists $CFG->{$k}; 2832 $CFG->{$k} = $v unless exists $CFG->{$k};
2793 } 2833 }
2794 2834
2795 my @args = @ARGV; 2835 my @args = @ARGV;
2796 2836
2837 # OS X passes some process serial number of other shit. they
2838 # could have used an env var or any other sane mechanism. but
2839 # would it be os x then? no...
2840 shift @args if $args[0] =~ /^-psn_/;
2841
2797 my $profile = 'default'; 2842 my $profile = 'default';
2798 2843
2799 for (my $i = 0; $i < @args; $i++) { 2844 for (my $i = 0; $i < @args; $i++) {
2800 if ($args[$i] =~ /^--?profile$/) { 2845 if ($args[$i] =~ /^--?profile$/) {
2801 $profile = $args[$i + 1]; 2846 $profile = $args[$i + 1];
2824 action => $cmds, 2869 action => $cmds,
2825 }; 2870 };
2826 } 2871 }
2827 } 2872 }
2828 } 2873 }
2829
2830 sdl_init;
2831 2874
2832 $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; 2875 $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf";
2833 $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; 2876 $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts";
2834 2877
2835 { 2878 {
2866# } 2909# }
2867# my $t2 = Time::HiRes::time; 2910# my $t2 = Time::HiRes::time;
2868# warn $t2-$t1; 2911# warn $t2-$t1;
2869# } 2912# }
2870 2913
2914 DC::IMG_Init;
2871 video_init; 2915 video_init;
2872 audio_init; 2916 audio_init;
2873 } 2917 }
2874 2918
2875 show_tip_of_the_day if $CFG->{show_tips}; 2919 show_tip_of_the_day if $CFG->{show_tips};
2877 our $STARTUP_CANCEL = EV::idle sub { 2921 our $STARTUP_CANCEL = EV::idle sub {
2878 undef $::STARTUP_CANCEL; 2922 undef $::STARTUP_CANCEL;
2879 $startup_done->(); 2923 $startup_done->();
2880 }; 2924 };
2881 2925
2926 debug_toggle 0;
2927
2882 delete $SIG{__DIE__}; 2928 delete $SIG{__DIE__};
2883 EV::loop; 2929 EV::loop;
2884 2930
2885 DC::write_cfg if $CFG->{config_autosave}; 2931 DC::write_cfg if $CFG->{config_autosave};
2886 2932
2908The deliantra client utilises OpenGL for all UI elements and the game. It 2954The deliantra client utilises OpenGL for all UI elements and the game. It
2909is supposed to be used in fullscreen mode and interactively. 2955is supposed to be used in fullscreen mode and interactively.
2910 2956
2911=head1 DEBUGGING 2957=head1 DEBUGGING
2912 2958
2913CFPLUS_DEBUG - environment variable 2959DELIANTRA_DEBUG - environment variable
2914 2960
2915 1 draw borders around widgets 2961 1 draw borders around widgets
2916 2 add low-level widget info to tooltips 2962 2 add low-level widget info to tooltips
2917 4 show fps 2963 4 show fps
2918 8 suppress tooltips 2964 8 suppress tooltips
2965 16 show bandwidth downstream
2919 2966
2920=head1 AUTHOR 2967=head1 AUTHOR
2921 2968
2922Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 2969Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
2923 2970

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines