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