--- deliantra/Deliantra-Client/DC/Main.pm 2012/01/18 13:42:19 1.17 +++ deliantra/Deliantra-Client/DC/Main.pm 2012/01/18 15:31:51 1.18 @@ -2954,95 +2954,97 @@ }; # due to mac os x + sdl combined braindamage, we need this contortion -sub DC::Main::main { - { - DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; - - DC::load_cfg; - - DC::DB::Server::run; - - if ($CFG->{db_schema} < 1) { - warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; - DC::DB::nuke_db; - $CFG->{db_schema} = 1; - DC::save_cfg; - } +sub DC::Main::run { + DC::SDL_main_hack { + { + DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; - DC::upgrade_cfg; + DC::load_cfg; + DC::upgrade_cfg; - DC::DB::open_db; + DC::Audio::probe; - DC::UI::set_layout ($::CFG->{layout}); + DC::DB::Server::run; - my @args = @ARGV; + if ($CFG->{db_schema} < 1) { + warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; + DC::DB::nuke_db; + $CFG->{db_schema} = 1; + DC::save_cfg; + } - # OS X passes some process serial number of other shit. they - # could have used an env var or any other sane mechanism. but - # would it be os x then? no... - shift @args if $args[0] =~ /^-psn_/; + DC::DB::open_db; - my $profile = 'default'; + DC::UI::set_layout ($::CFG->{layout}); - for (my $i = 0; $i < @args; $i++) { - if ($args[$i] =~ /^--?profile$/) { - $profile = $args[$i + 1]; - splice @args, $i, 2, (); - $i = 0; - } elsif ($args[$i] =~ /^--?h/) { - print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; - exit 0; - } - } + my @args = @ARGV; - $CFG->{profile}{$profile} ||= {}; - $PROFILE = $CFG->{profile}{$profile}; - $PROFILE->{host} ||= "gameserver.deliantra.net"; - - $PROFILE->{host} = $args[0] if @args > 0; - $PROFILE->{user} = $args[1] if @args > 1; - $PROFILE->{password} = $args[2] if @args > 2; - - # convert old bindings (only default profile matters) - if (my $bindings = delete $PROFILE->{bindings}) { - while (my ($mod, $syms) = each %$bindings) { - while (my ($sym, $cmds) = each %$syms) { - push @{ $PROFILE->{macro} }, { - accelkey => [$mod*1, $sym*1], - action => $cmds, - }; + # OS X passes some process serial number of other shit. they + # could have used an env var or any other sane mechanism. but + # would it be os x then? no... + shift @args if $args[0] =~ /^-psn_/; + + my $profile = 'default'; + + for (my $i = 0; $i < @args; $i++) { + if ($args[$i] =~ /^--?profile$/) { + $profile = $args[$i + 1]; + splice @args, $i, 2, (); + $i = 0; + } elsif ($args[$i] =~ /^--?h/) { + print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; + exit 0; } } - } - # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed - # these are ignored under windows, for some reason, and thus set in the loader - $ENV{FONTCONFIG_FILE} = "fonts.conf"; - $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; - $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions + $CFG->{profile}{$profile} ||= {}; + $PROFILE = $CFG->{profile}{$profile}; + $PROFILE->{host} ||= "gameserver.deliantra.net"; + + $PROFILE->{host} = $args[0] if @args > 0; + $PROFILE->{user} = $args[1] if @args > 1; + $PROFILE->{password} = $args[2] if @args > 2; + + # convert old bindings (only default profile matters) + if (my $bindings = delete $PROFILE->{bindings}) { + while (my ($mod, $syms) = each %$bindings) { + while (my ($sym, $cmds) = each %$syms) { + push @{ $PROFILE->{macro} }, { + accelkey => [$mod*1, $sym*1], + action => $cmds, + }; + } + } + } - { - my @fonts = map DC::find_rcfile "fonts/$_", qw( - DejaVuSans.ttf - DejaVuSansMono.ttf - DejaVuSans-Bold.ttf - DejaVuSansMono-Bold.ttf - DejaVuSans-Oblique.ttf - DejaVuSansMono-Oblique.ttf - DejaVuSans-BoldOblique.ttf - DejaVuSansMono-BoldOblique.ttf - mona.ttf - ); + # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed + # these are ignored under windows, for some reason, and thus set in the loader + $ENV{FONTCONFIG_FILE} = "fonts.conf"; + $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; + $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions + + { + my @fonts = map DC::find_rcfile "fonts/$_", qw( + DejaVuSans.ttf + DejaVuSansMono.ttf + DejaVuSans-Bold.ttf + DejaVuSansMono-Bold.ttf + DejaVuSans-Oblique.ttf + DejaVuSansMono-Oblique.ttf + DejaVuSans-BoldOblique.ttf + DejaVuSansMono-BoldOblique.ttf + mona.ttf + ); - DC::add_font $_ for @fonts; + DC::add_font $_ for @fonts; - $FONT_PROP = new_from_file DC::Font $fonts[0]; - $FONT_FIXED = new_from_file DC::Font $fonts[1]; + $FONT_PROP = new_from_file DC::Font $fonts[0]; + $FONT_FIXED = new_from_file DC::Font $fonts[1]; - $FONT_PROP->make_default; + $FONT_PROP->make_default; - DC::pango_init; - } + DC::pango_init; + } # compare mono (ft) vs. rgba (cairo) # ft - 1.8s, cairo 3s, even in alpha-only mode @@ -3057,33 +3059,34 @@ # warn $t2-$t1; # } + } + + DC::SDL_Init 0; DC::IMG_Init; video_init; DC::Mix_Init; audio_init; - } - show_tip_of_the_day if $CFG->{show_tips}; + show_tip_of_the_day if $CFG->{show_tips}; - my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { - undef $STARTUP_CANCEL; - (pop @::STARTUP_DONE)->() - while @::STARTUP_DONE; - }; + my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { + undef $STARTUP_CANCEL; + (pop @::STARTUP_DONE)->() + while @::STARTUP_DONE; + }; - debug_toggle 0; + debug_toggle 0; - delete $SIG{__DIE__}; - EV::loop; + delete $SIG{__DIE__}; + EV::loop; - DC::save_cfg if $CFG->{config_autosave}; + DC::save_cfg if $CFG->{config_autosave}; - #video_shutdown; - #audio_shutdown; + #video_shutdown; + #audio_shutdown; - DC::OpenGL::quit; - DC::SDL_Quit; - DC::DB::Server::stop; + DC::OpenGL::quit; + DC::SDL_Quit; + DC::DB::Server::stop; + }; } -*DC::Main::run = \&DC::SDL_braino; # see sub above - 1