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.12 by root, Sat Jan 7 19:29:58 2012 UTC vs.
Revision 1.17 by root, Wed Jan 18 13:42:19 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;
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;
605 binmode $f_md5; # ugh :( 590 binmode $fh; # ugh :(
606 $f_md5->addfile ($fh); 591 $f_md5->addfile ($fh);
607 $f_md5 = $f_md5->hexdigest; 592 $f_md5 = $f_md5->hexdigest;
608 $error ||= $md5 ne $f_md5; 593 $error ||= $md5 ne $f_md5;
609 } 594 }
610 } 595 }
2029 $table->add_at (2, $row++, new DC::UI::Button 2014 $table->add_at (2, $row++, new DC::UI::Button
2030 text => "Save Now", 2015 text => "Save Now",
2031 tooltip => "Use this to manually save configuration and UI layout when " 2016 tooltip => "Use this to manually save configuration and UI layout when "
2032 . "autosave is disabled.", 2017 . "autosave is disabled.",
2033 on_activate => sub { 2018 on_activate => sub {
2034 DC::write_cfg; 2019 DC::save_cfg;
2035 0 2020 0
2036 } 2021 }
2037 ); 2022 );
2038 } 2023 }
2039 2024
2971# due to mac os x + sdl combined braindamage, we need this contortion 2956# due to mac os x + sdl combined braindamage, we need this contortion
2972sub DC::Main::main { 2957sub DC::Main::main {
2973 { 2958 {
2974 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; 2959 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst";
2975 2960
2976 if (-e "$Deliantra::VARDIR/client.cf") { 2961 DC::load_cfg;
2977 DC::read_cfg "$Deliantra::VARDIR/client.cf";
2978 } else {
2979 #TODO: compatibility cruft
2980 DC::read_cfg "$Deliantra::OLDDIR/cfplusrc";
2981 print STDERR "INFO: used old configuration file\n";
2982 }
2983 2962
2984 DC::DB::Server::run; 2963 DC::DB::Server::run;
2985 2964
2986 if ($CFG->{db_schema} < 1) { 2965 if ($CFG->{db_schema} < 1) {
2987 warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; 2966 warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n";
2988 DC::DB::nuke_db; 2967 DC::DB::nuke_db;
2989 $CFG->{db_schema} = 1; 2968 $CFG->{db_schema} = 1;
2990 DC::write_cfg; 2969 DC::save_cfg;
2991 } 2970 }
2971
2972 DC::upgrade_cfg;
2992 2973
2993 DC::DB::open_db; 2974 DC::DB::open_db;
2994 2975
2995 DC::UI::set_layout ($::CFG->{layout}); 2976 DC::UI::set_layout ($::CFG->{layout});
2996
2997 my %DEF_CFG = (
2998 config_autosave => 1,
2999 sdl_mode => undef,
3000 fullscreen => 1,
3001 fast => 0,
3002 force_opengl11 => undef,
3003 disable_alpha => 0,
3004 smooth_movement => 1,
3005 smooth_transitions => 1,
3006 texture_compression => 1,
3007 map_scale => 1,
3008 fow_enable => 1,
3009 fow_intensity => 0,
3010 fow_texture => 0,
3011 map_smoothing => 1,
3012 gui_fontsize => 1,
3013 log_fontsize => 0.7,
3014 gauge_fontsize => 1,
3015 gauge_size => 0.35,
3016 stat_fontsize => 0.7,
3017 mapsize => 100,
3018 audio_enable => 1,
3019 audio_hw_channels => 0,
3020 audio_hw_frequency => 0,
3021 audio_hw_chunksize => 0,
3022 audio_mix_channels => 8,
3023 effects_enable => 1,
3024 effects_volume => 1,
3025 bgm_enable => 1,
3026 bgm_volume => 0.5,
3027 output_rate => "",
3028 pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES,
3029 inv_sort => "mtime",
3030 default => "profile", # default profile
3031 show_tips => 1,
3032 logview_max_par => 1000,
3033 shift_fire_stop => 0,
3034 uitheme => "wood",
3035 map_shift_x => -24, # arbitrary
3036 map_shift_y => +24, # arbitrary
3037 );
3038
3039 while (my ($k, $v) = each %DEF_CFG) {
3040 $CFG->{$k} = $v unless exists $CFG->{$k};
3041 }
3042 2977
3043 my @args = @ARGV; 2978 my @args = @ARGV;
3044 2979
3045 # OS X passes some process serial number of other shit. they 2980 # OS X passes some process serial number of other shit. they
3046 # could have used an env var or any other sane mechanism. but 2981 # could have used an env var or any other sane mechanism. but
3137 debug_toggle 0; 3072 debug_toggle 0;
3138 3073
3139 delete $SIG{__DIE__}; 3074 delete $SIG{__DIE__};
3140 EV::loop; 3075 EV::loop;
3141 3076
3142 DC::write_cfg if $CFG->{config_autosave}; 3077 DC::save_cfg if $CFG->{config_autosave};
3143 3078
3144 #video_shutdown; 3079 #video_shutdown;
3145 #audio_shutdown; 3080 #audio_shutdown;
3146 3081
3147 DC::OpenGL::quit; 3082 DC::OpenGL::quit;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines