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

Comparing deliantra/Deliantra-Client/DC/Main.pm (file contents):
Revision 1.9 by root, Thu Jan 5 05:37:02 2012 UTC vs.
Revision 1.16 by root, Wed Jan 18 00:51:41 2012 UTC

57 DC::fatal Carp::longmess "$_[0]"; 57 DC::fatal Carp::longmess "$_[0]";
58 } 58 }
59} 59}
60 60
61use DC::OpenGL (); 61use DC::OpenGL ();
62use DC::Audio ();
62use DC::Protocol; 63use DC::Protocol;
63use DC::DB; 64use DC::DB;
64use DC::UI; 65use DC::UI;
65use DC::UI::Canvas; 66use DC::UI::Canvas;
66use DC::UI::Inventory; 67use DC::UI::Inventory;
196 AnyEvent::Util::fh_nonblocking $fh, 1; 197 AnyEvent::Util::fh_nonblocking $fh, 1;
197 198
198 $msg =~ s/\s+$//; 199 $msg =~ s/\s+$//;
199 200
200 # backtrace as second step, in case it crashes, too 201 # backtrace as second step, in case it crashes, too
201 crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" 202 crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION$Urlader::EXE_VER, generated"
202 if $backtrace; 203 if $backtrace;
203}; 204};
204 205
205sub clienterror($;$) { 206sub clienterror($;$) {
206 my ($msg, $backtrace) = @_; 207 my ($msg, $backtrace) = @_;
208 warn $msg; 209 warn $msg;
209 210
210 return unless $CONN; 211 return unless $CONN;
211 212
212 $CONN->send_exti_msg (clientlog => $msg); 213 $CONN->send_exti_msg (clientlog => $msg);
213 $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; 214 $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION$Urlader::EXE_VER, generated") if $backtrace;
214} 215}
215 216
216############################################################################# 217#############################################################################
217 218
218sub status { 219sub status {
473 audio_music_push; 474 audio_music_push;
474} 475}
475 476
476sub audio_init { 477sub audio_init {
477 if ($CFG->{audio_enable}) { 478 if ($CFG->{audio_enable}) {
478 if (length $CFG->{audio_driver}) { 479 DC::Audio::init $CFG->{audio_driver};
479 local $ENV{SDL_AUDIODRIVER} = $CFG->{audio_driver};
480 DC::SDL_Init DC::SDL_INIT_AUDIO
481 and die "SDL::Init failed!\n";
482 } else {
483 DC::SDL_Init DC::SDL_INIT_AUDIO
484 and die "SDL::Init failed!\n";
485 }
486
487 $ENV{MIX_EFFECTSMAXSPEED} = 1;
488 $SDL_MIXER = !DC::Mix_OpenAudio
489 $CFG->{audio_hw_frequency},
490 DC::MIX_DEFAULT_FORMAT,
491 $CFG->{audio_hw_channels},
492 $CFG->{audio_hw_chunksize};
493 480
494 if ($SDL_MIXER) { 481 if ($SDL_MIXER) {
495 DC::Mix_AllocateChannels $CFG->{audio_mix_channels};
496
497 audio_music_finished; 482 audio_music_finished;
498 } else { 483 } else {
499 status "Unable to open sound device: there will be no sound"; 484 status "Unable to open sound device: there will be no sound";
500 } 485 }
501 } else { 486 } else {
597 my $fh = Coro::AIO::aio_open "$override.tmp", IO::AIO::O_RDONLY, 0; 582 my $fh = Coro::AIO::aio_open "$override.tmp", IO::AIO::O_RDONLY, 0;
598 583
599 if ($fh) { 584 if ($fh) {
600 $error ||= Coro::AIO::aio_stat "$override.tmp"; 585 $error ||= Coro::AIO::aio_stat "$override.tmp";
601 $error ||= -s _ != $size; 586 $error ||= -s _ != $size;
602 $error ||= Coro::AIO::aio_readahead $fh, 0, $size; 587 Coro::AIO::aio_readahead $fh, 0, $size;
603 588
604 my $f_md5 = new Digest::MD5; 589 my $f_md5 = new Digest::MD5;
590 binmode $fh; # ugh :(
605 $f_md5->addfile ($fh); 591 $f_md5->addfile ($fh);
606 $f_md5 = $f_md5->hexdigest; 592 $f_md5 = $f_md5->hexdigest;
607 $error ||= $md5 ne $f_md5; 593 $error ||= $md5 ne $f_md5;
608 } 594 }
609 } 595 }
964 mapw => $mapw, 950 mapw => $mapw,
965 maph => $maph, 951 maph => $maph,
966 952
967 c_version => { 953 c_version => {
968 client => "deliantra", 954 client => "deliantra",
969 clientver => $DC::VERSION, 955 clientver => "$DC::VERSION$Urlader::EXE_VER",
970 gl_vendor => DC::OpenGL::gl_vendor, 956 gl_vendor => DC::OpenGL::gl_vendor,
971 gl_version => DC::OpenGL::gl_version, 957 gl_version => DC::OpenGL::gl_version,
972 }, 958 },
973 959
974 map_widget => $MAPWIDGET, 960 map_widget => $MAPWIDGET,
2697 my ($old_w, $old_h) = ($WIDTH, $HEIGHT); 2683 my ($old_w, $old_h) = ($WIDTH, $HEIGHT);
2698 2684
2699 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 2685 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
2700 $FULLSCREEN = $CFG->{fullscreen}; 2686 $FULLSCREEN = $CFG->{fullscreen};
2701 $FAST = $CFG->{fast}; 2687 $FAST = $CFG->{fast};
2688
2689 DC::SDL_WM_SetCaption "Deliantra MORPG Client $DC::VERSION$Urlader::EXE_VER", "Deliantra"; # must be after SDL_Init
2702 2690
2703 # due to mac os x braindamage, we simply retry with !fullscreen in case of an error 2691 # due to mac os x braindamage, we simply retry with !fullscreen in case of an error
2704 DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN 2692 DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN
2705 or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN 2693 or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN
2706 or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; 2694 or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n";
2985 DC::DB::nuke_db; 2973 DC::DB::nuke_db;
2986 $CFG->{db_schema} = 1; 2974 $CFG->{db_schema} = 1;
2987 DC::write_cfg; 2975 DC::write_cfg;
2988 } 2976 }
2989 2977
2978 DC::upgrade_cfg;
2979
2990 DC::DB::open_db; 2980 DC::DB::open_db;
2991 2981
2992 DC::UI::set_layout ($::CFG->{layout}); 2982 DC::UI::set_layout ($::CFG->{layout});
2993
2994 my %DEF_CFG = (
2995 config_autosave => 1,
2996 sdl_mode => undef,
2997 fullscreen => 1,
2998 fast => 0,
2999 force_opengl11 => undef,
3000 disable_alpha => 0,
3001 smooth_movement => 1,
3002 smooth_transitions => 1,
3003 texture_compression => 1,
3004 map_scale => 1,
3005 fow_enable => 1,
3006 fow_intensity => 0,
3007 fow_texture => 0,
3008 map_smoothing => 1,
3009 gui_fontsize => 1,
3010 log_fontsize => 0.7,
3011 gauge_fontsize => 1,
3012 gauge_size => 0.35,
3013 stat_fontsize => 0.7,
3014 mapsize => 100,
3015 audio_enable => 1,
3016 audio_hw_channels => 0,
3017 audio_hw_frequency => 0,
3018 audio_hw_chunksize => 0,
3019 audio_mix_channels => 8,
3020 effects_enable => 1,
3021 effects_volume => 1,
3022 bgm_enable => 1,
3023 bgm_volume => 0.5,
3024 output_rate => "",
3025 pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES,
3026 inv_sort => "mtime",
3027 default => "profile", # default profile
3028 show_tips => 1,
3029 logview_max_par => 1000,
3030 shift_fire_stop => 0,
3031 uitheme => "wood",
3032 map_shift_x => -24, # arbitrary
3033 map_shift_y => +24, # arbitrary
3034 );
3035
3036 while (my ($k, $v) = each %DEF_CFG) {
3037 $CFG->{$k} = $v unless exists $CFG->{$k};
3038 }
3039 2983
3040 my @args = @ARGV; 2984 my @args = @ARGV;
3041 2985
3042 # OS X passes some process serial number of other shit. they 2986 # OS X passes some process serial number of other shit. they
3043 # could have used an env var or any other sane mechanism. but 2987 # could have used an env var or any other sane mechanism. but

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines