… | |
… | |
2952 | EV::unloop; |
2952 | EV::unloop; |
2953 | #d# TODO calling exit here hangs the process in some futex |
2953 | #d# TODO calling exit here hangs the process in some futex |
2954 | }; |
2954 | }; |
2955 | |
2955 | |
2956 | # 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 |
2957 | sub DC::Main::main { |
2957 | sub DC::Main::run { |
2958 | { |
2958 | DC::SDL_main_hack { |
|
|
2959 | { |
2959 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2960 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2960 | |
2961 | |
2961 | DC::load_cfg; |
2962 | DC::load_cfg; |
|
|
2963 | DC::upgrade_cfg; |
2962 | |
2964 | |
|
|
2965 | DC::Audio::probe; |
|
|
2966 | |
2963 | DC::DB::Server::run; |
2967 | DC::DB::Server::run; |
2964 | |
2968 | |
2965 | if ($CFG->{db_schema} < 1) { |
2969 | if ($CFG->{db_schema} < 1) { |
2966 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2970 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2967 | DC::DB::nuke_db; |
2971 | DC::DB::nuke_db; |
2968 | $CFG->{db_schema} = 1; |
2972 | $CFG->{db_schema} = 1; |
2969 | DC::save_cfg; |
2973 | DC::save_cfg; |
2970 | } |
|
|
2971 | |
|
|
2972 | DC::upgrade_cfg; |
|
|
2973 | |
|
|
2974 | DC::DB::open_db; |
|
|
2975 | |
|
|
2976 | DC::UI::set_layout ($::CFG->{layout}); |
|
|
2977 | |
|
|
2978 | my @args = @ARGV; |
|
|
2979 | |
|
|
2980 | # OS X passes some process serial number of other shit. they |
|
|
2981 | # could have used an env var or any other sane mechanism. but |
|
|
2982 | # would it be os x then? no... |
|
|
2983 | shift @args if $args[0] =~ /^-psn_/; |
|
|
2984 | |
|
|
2985 | my $profile = 'default'; |
|
|
2986 | |
|
|
2987 | for (my $i = 0; $i < @args; $i++) { |
|
|
2988 | if ($args[$i] =~ /^--?profile$/) { |
|
|
2989 | $profile = $args[$i + 1]; |
|
|
2990 | splice @args, $i, 2, (); |
|
|
2991 | $i = 0; |
|
|
2992 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2993 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2994 | exit 0; |
|
|
2995 | } |
2974 | } |
2996 | } |
|
|
2997 | |
2975 | |
2998 | $CFG->{profile}{$profile} ||= {}; |
2976 | DC::DB::open_db; |
2999 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
3000 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
|
|
3001 | |
2977 | |
3002 | $PROFILE->{host} = $args[0] if @args > 0; |
2978 | DC::UI::set_layout ($::CFG->{layout}); |
3003 | $PROFILE->{user} = $args[1] if @args > 1; |
|
|
3004 | $PROFILE->{password} = $args[2] if @args > 2; |
|
|
3005 | |
2979 | |
3006 | # convert old bindings (only default profile matters) |
2980 | my @args = @ARGV; |
3007 | if (my $bindings = delete $PROFILE->{bindings}) { |
2981 | |
3008 | while (my ($mod, $syms) = each %$bindings) { |
2982 | # OS X passes some process serial number of other shit. they |
3009 | while (my ($sym, $cmds) = each %$syms) { |
2983 | # could have used an env var or any other sane mechanism. but |
3010 | push @{ $PROFILE->{macro} }, { |
2984 | # would it be os x then? no... |
3011 | accelkey => [$mod*1, $sym*1], |
2985 | shift @args if $args[0] =~ /^-psn_/; |
3012 | action => $cmds, |
2986 | |
|
|
2987 | my $profile = 'default'; |
|
|
2988 | |
|
|
2989 | for (my $i = 0; $i < @args; $i++) { |
|
|
2990 | if ($args[$i] =~ /^--?profile$/) { |
|
|
2991 | $profile = $args[$i + 1]; |
|
|
2992 | splice @args, $i, 2, (); |
3013 | }; |
2993 | $i = 0; |
|
|
2994 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2995 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2996 | exit 0; |
3014 | } |
2997 | } |
3015 | } |
2998 | } |
|
|
2999 | |
|
|
3000 | $CFG->{profile}{$profile} ||= {}; |
|
|
3001 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
3002 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
|
|
3003 | |
|
|
3004 | $PROFILE->{host} = $args[0] if @args > 0; |
|
|
3005 | $PROFILE->{user} = $args[1] if @args > 1; |
|
|
3006 | $PROFILE->{password} = $args[2] if @args > 2; |
|
|
3007 | |
|
|
3008 | # convert old bindings (only default profile matters) |
|
|
3009 | if (my $bindings = delete $PROFILE->{bindings}) { |
|
|
3010 | while (my ($mod, $syms) = each %$bindings) { |
|
|
3011 | while (my ($sym, $cmds) = each %$syms) { |
|
|
3012 | push @{ $PROFILE->{macro} }, { |
|
|
3013 | accelkey => [$mod*1, $sym*1], |
|
|
3014 | action => $cmds, |
|
|
3015 | }; |
|
|
3016 | } |
|
|
3017 | } |
3016 | } |
3018 | } |
3017 | |
3019 | |
3018 | # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed |
3020 | # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed |
3019 | # these are ignored under windows, for some reason, and thus set in the loader |
3021 | # these are ignored under windows, for some reason, and thus set in the loader |
3020 | $ENV{FONTCONFIG_FILE} = "fonts.conf"; |
3022 | $ENV{FONTCONFIG_FILE} = "fonts.conf"; |
3021 | $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; |
3023 | $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; |
3022 | $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions |
3024 | $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions |
3023 | |
3025 | |
3024 | { |
3026 | { |
3025 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
3027 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
3026 | DejaVuSans.ttf |
3028 | DejaVuSans.ttf |
3027 | DejaVuSansMono.ttf |
3029 | DejaVuSansMono.ttf |
3028 | DejaVuSans-Bold.ttf |
3030 | DejaVuSans-Bold.ttf |
3029 | DejaVuSansMono-Bold.ttf |
3031 | DejaVuSansMono-Bold.ttf |
3030 | DejaVuSans-Oblique.ttf |
3032 | DejaVuSans-Oblique.ttf |
3031 | DejaVuSansMono-Oblique.ttf |
3033 | DejaVuSansMono-Oblique.ttf |
3032 | DejaVuSans-BoldOblique.ttf |
3034 | DejaVuSans-BoldOblique.ttf |
3033 | DejaVuSansMono-BoldOblique.ttf |
3035 | DejaVuSansMono-BoldOblique.ttf |
3034 | mona.ttf |
3036 | mona.ttf |
3035 | ); |
3037 | ); |
3036 | |
3038 | |
3037 | DC::add_font $_ for @fonts; |
3039 | DC::add_font $_ for @fonts; |
3038 | |
3040 | |
3039 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
3041 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
3040 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
3042 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
3041 | |
3043 | |
3042 | $FONT_PROP->make_default; |
3044 | $FONT_PROP->make_default; |
3043 | |
3045 | |
3044 | DC::pango_init; |
3046 | DC::pango_init; |
3045 | } |
3047 | } |
3046 | |
3048 | |
3047 | # compare mono (ft) vs. rgba (cairo) |
3049 | # compare mono (ft) vs. rgba (cairo) |
3048 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
3050 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
3049 | # for my $rgba (0..1) { |
3051 | # for my $rgba (0..1) { |
3050 | # my $t1 = Time::HiRes::time; |
3052 | # my $t1 = Time::HiRes::time; |
… | |
… | |
3055 | # } |
3057 | # } |
3056 | # my $t2 = Time::HiRes::time; |
3058 | # my $t2 = Time::HiRes::time; |
3057 | # warn $t2-$t1; |
3059 | # warn $t2-$t1; |
3058 | # } |
3060 | # } |
3059 | |
3061 | |
|
|
3062 | } |
|
|
3063 | |
|
|
3064 | DC::SDL_Init 0; |
3060 | DC::IMG_Init; video_init; |
3065 | DC::IMG_Init; video_init; |
3061 | DC::Mix_Init; audio_init; |
3066 | DC::Mix_Init; audio_init; |
3062 | } |
|
|
3063 | |
3067 | |
3064 | show_tip_of_the_day if $CFG->{show_tips}; |
3068 | show_tip_of_the_day if $CFG->{show_tips}; |
3065 | |
3069 | |
3066 | my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { |
3070 | my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { |
3067 | undef $STARTUP_CANCEL; |
3071 | undef $STARTUP_CANCEL; |
3068 | (pop @::STARTUP_DONE)->() |
3072 | (pop @::STARTUP_DONE)->() |
3069 | while @::STARTUP_DONE; |
3073 | while @::STARTUP_DONE; |
|
|
3074 | }; |
|
|
3075 | |
|
|
3076 | debug_toggle 0; |
|
|
3077 | |
|
|
3078 | delete $SIG{__DIE__}; |
|
|
3079 | EV::loop; |
|
|
3080 | |
|
|
3081 | DC::save_cfg if $CFG->{config_autosave}; |
|
|
3082 | |
|
|
3083 | #video_shutdown; |
|
|
3084 | #audio_shutdown; |
|
|
3085 | |
|
|
3086 | DC::OpenGL::quit; |
|
|
3087 | DC::SDL_Quit; |
|
|
3088 | DC::DB::Server::stop; |
3070 | }; |
3089 | }; |
3071 | |
|
|
3072 | debug_toggle 0; |
|
|
3073 | |
|
|
3074 | delete $SIG{__DIE__}; |
|
|
3075 | EV::loop; |
|
|
3076 | |
|
|
3077 | DC::save_cfg if $CFG->{config_autosave}; |
|
|
3078 | |
|
|
3079 | #video_shutdown; |
|
|
3080 | #audio_shutdown; |
|
|
3081 | |
|
|
3082 | DC::OpenGL::quit; |
|
|
3083 | DC::SDL_Quit; |
|
|
3084 | DC::DB::Server::stop; |
|
|
3085 | } |
3090 | } |
3086 | |
|
|
3087 | *DC::Main::run = \&DC::SDL_braino; # see sub above |
|
|
3088 | |
3091 | |
3089 | 1 |
3092 | 1 |