… | |
… | |
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 |
… | |
… | |
44 | |
45 | |
45 | BEGIN { |
46 | BEGIN { |
46 | $SIG{__DIE__} = sub { |
47 | $SIG{__DIE__} = sub { |
47 | return if $^S; # quick reject |
48 | return if $^S; # quick reject |
48 | |
49 | |
49 | # return if there are any eval contexts in the csall stack |
50 | # return if there are any eval contexts in the call stack |
50 | for my $i (0..999) { |
51 | for my $i (0..999) { |
51 | my ($sub, $is_require) = (caller $i)[3, 7] |
52 | my ($sub, $is_require) = (caller $i)[3, 7] |
52 | or last; |
53 | or last; |
53 | return if $sub eq "(eval)" && !$is_require; |
54 | return if $sub eq "(eval)" && !$is_require; |
54 | } |
55 | } |
… | |
… | |
688 | ::message { markup => "Server has no newer version." }; |
689 | ::message { markup => "Server has no newer version." }; |
689 | } |
690 | } |
690 | } else { |
691 | } else { |
691 | ::message { markup => "Server does not support software update." }; |
692 | ::message { markup => "Server does not support software update." }; |
692 | } |
693 | } |
693 | |
|
|
694 | # $self->register_face_handler ($exp_table, sub { |
|
|
695 | # my ($face) = @_; |
|
|
696 | |
|
|
697 | # $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data}); |
|
|
698 | # $_->() for values %{ $self->{on_exp_update} || {} }; |
|
|
699 | # }); |
|
|
700 | |
694 | |
701 | () |
695 | () |
702 | }); |
696 | }); |
703 | } |
697 | } |
704 | |
698 | |
… | |
… | |
2660 | DC::set_theme $CFG->{uitheme}; |
2654 | DC::set_theme $CFG->{uitheme}; |
2661 | |
2655 | |
2662 | DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
2656 | DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
2663 | $SDL_REINIT = 0; |
2657 | $SDL_REINIT = 0; |
2664 | |
2658 | |
2665 | @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 8; |
2659 | @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 2; |
2666 | @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES; |
2660 | @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES; |
2667 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
2661 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
2668 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
2662 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
2669 | |
2663 | |
2670 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
2664 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
… | |
… | |
2952 | EV::unloop; |
2946 | EV::unloop; |
2953 | #d# TODO calling exit here hangs the process in some futex |
2947 | #d# TODO calling exit here hangs the process in some futex |
2954 | }; |
2948 | }; |
2955 | |
2949 | |
2956 | # due to mac os x + sdl combined braindamage, we need this contortion |
2950 | # due to mac os x + sdl combined braindamage, we need this contortion |
2957 | sub DC::Main::main { |
2951 | sub DC::Main::run { |
2958 | { |
2952 | DC::SDL_main_hack { |
|
|
2953 | { |
2959 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2954 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2960 | |
2955 | |
2961 | DC::load_cfg; |
2956 | DC::load_cfg; |
|
|
2957 | DC::upgrade_cfg; |
2962 | |
2958 | |
|
|
2959 | DC::Audio::probe; |
|
|
2960 | |
2963 | DC::DB::Server::run; |
2961 | DC::DB::Server::run; |
2964 | |
2962 | |
2965 | if ($CFG->{db_schema} < 1) { |
2963 | if ($CFG->{db_schema} < 1) { |
2966 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2964 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2967 | DC::DB::nuke_db; |
2965 | DC::DB::nuke_db; |
2968 | $CFG->{db_schema} = 1; |
2966 | $CFG->{db_schema} = 1; |
2969 | DC::save_cfg; |
2967 | 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 | } |
2968 | } |
2996 | } |
|
|
2997 | |
2969 | |
2998 | $CFG->{profile}{$profile} ||= {}; |
2970 | DC::DB::open_db; |
2999 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
3000 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
|
|
3001 | |
2971 | |
3002 | $PROFILE->{host} = $args[0] if @args > 0; |
2972 | DC::UI::set_layout ($::CFG->{layout}); |
3003 | $PROFILE->{user} = $args[1] if @args > 1; |
|
|
3004 | $PROFILE->{password} = $args[2] if @args > 2; |
|
|
3005 | |
2973 | |
3006 | # convert old bindings (only default profile matters) |
2974 | my @args = @ARGV; |
3007 | if (my $bindings = delete $PROFILE->{bindings}) { |
2975 | |
3008 | while (my ($mod, $syms) = each %$bindings) { |
2976 | # OS X passes some process serial number of other shit. they |
3009 | while (my ($sym, $cmds) = each %$syms) { |
2977 | # could have used an env var or any other sane mechanism. but |
3010 | push @{ $PROFILE->{macro} }, { |
2978 | # would it be os x then? no... |
3011 | accelkey => [$mod*1, $sym*1], |
2979 | shift @args if $args[0] =~ /^-psn_/; |
3012 | action => $cmds, |
2980 | |
|
|
2981 | my $profile = 'default'; |
|
|
2982 | |
|
|
2983 | for (my $i = 0; $i < @args; $i++) { |
|
|
2984 | if ($args[$i] =~ /^--?profile$/) { |
|
|
2985 | $profile = $args[$i + 1]; |
|
|
2986 | splice @args, $i, 2, (); |
3013 | }; |
2987 | $i = 0; |
|
|
2988 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2989 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2990 | exit 0; |
3014 | } |
2991 | } |
3015 | } |
2992 | } |
|
|
2993 | |
|
|
2994 | $CFG->{profile}{$profile} ||= {}; |
|
|
2995 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
2996 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
|
|
2997 | |
|
|
2998 | $PROFILE->{host} = $args[0] if @args > 0; |
|
|
2999 | $PROFILE->{user} = $args[1] if @args > 1; |
|
|
3000 | $PROFILE->{password} = $args[2] if @args > 2; |
|
|
3001 | |
|
|
3002 | # convert old bindings (only default profile matters) |
|
|
3003 | if (my $bindings = delete $PROFILE->{bindings}) { |
|
|
3004 | while (my ($mod, $syms) = each %$bindings) { |
|
|
3005 | while (my ($sym, $cmds) = each %$syms) { |
|
|
3006 | push @{ $PROFILE->{macro} }, { |
|
|
3007 | accelkey => [$mod*1, $sym*1], |
|
|
3008 | action => $cmds, |
|
|
3009 | }; |
|
|
3010 | } |
|
|
3011 | } |
3016 | } |
3012 | } |
3017 | |
3013 | |
3018 | # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed |
3014 | # 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 |
3015 | # these are ignored under windows, for some reason, and thus set in the loader |
3020 | $ENV{FONTCONFIG_FILE} = "fonts.conf"; |
3016 | $ENV{FONTCONFIG_FILE} = "fonts.conf"; |
3021 | $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; |
3017 | $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; |
3022 | $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions |
3018 | $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions |
3023 | |
3019 | |
3024 | { |
3020 | { |
3025 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
3021 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
3026 | DejaVuSans.ttf |
3022 | DejaVuSans.ttf |
3027 | DejaVuSansMono.ttf |
3023 | DejaVuSansMono.ttf |
3028 | DejaVuSans-Bold.ttf |
3024 | DejaVuSans-Bold.ttf |
3029 | DejaVuSansMono-Bold.ttf |
3025 | DejaVuSansMono-Bold.ttf |
3030 | DejaVuSans-Oblique.ttf |
3026 | DejaVuSans-Oblique.ttf |
3031 | DejaVuSansMono-Oblique.ttf |
3027 | DejaVuSansMono-Oblique.ttf |
3032 | DejaVuSans-BoldOblique.ttf |
3028 | DejaVuSans-BoldOblique.ttf |
3033 | DejaVuSansMono-BoldOblique.ttf |
3029 | DejaVuSansMono-BoldOblique.ttf |
3034 | mona.ttf |
3030 | mona.ttf |
3035 | ); |
3031 | ); |
3036 | |
3032 | |
3037 | DC::add_font $_ for @fonts; |
3033 | DC::add_font $_ for @fonts; |
3038 | |
3034 | |
3039 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
3035 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
3040 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
3036 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
3041 | |
3037 | |
3042 | $FONT_PROP->make_default; |
3038 | $FONT_PROP->make_default; |
3043 | |
3039 | |
3044 | DC::pango_init; |
3040 | DC::pango_init; |
3045 | } |
3041 | } |
3046 | |
3042 | |
3047 | # compare mono (ft) vs. rgba (cairo) |
3043 | # compare mono (ft) vs. rgba (cairo) |
3048 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
3044 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
3049 | # for my $rgba (0..1) { |
3045 | # for my $rgba (0..1) { |
3050 | # my $t1 = Time::HiRes::time; |
3046 | # my $t1 = Time::HiRes::time; |
… | |
… | |
3055 | # } |
3051 | # } |
3056 | # my $t2 = Time::HiRes::time; |
3052 | # my $t2 = Time::HiRes::time; |
3057 | # warn $t2-$t1; |
3053 | # warn $t2-$t1; |
3058 | # } |
3054 | # } |
3059 | |
3055 | |
|
|
3056 | } |
|
|
3057 | |
|
|
3058 | DC::SDL_Init 0; |
3060 | DC::IMG_Init; video_init; |
3059 | DC::IMG_Init; video_init; |
3061 | DC::Mix_Init; audio_init; |
3060 | DC::Mix_Init; audio_init; |
3062 | } |
|
|
3063 | |
3061 | |
3064 | show_tip_of_the_day if $CFG->{show_tips}; |
3062 | show_tip_of_the_day if $CFG->{show_tips}; |
3065 | |
3063 | |
3066 | my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { |
3064 | my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { |
3067 | undef $STARTUP_CANCEL; |
3065 | undef $STARTUP_CANCEL; |
3068 | (pop @::STARTUP_DONE)->() |
3066 | (pop @::STARTUP_DONE)->() |
3069 | while @::STARTUP_DONE; |
3067 | while @::STARTUP_DONE; |
|
|
3068 | }; |
|
|
3069 | |
|
|
3070 | debug_toggle 0; |
|
|
3071 | |
|
|
3072 | delete $SIG{__DIE__}; |
|
|
3073 | EV::loop; |
|
|
3074 | |
|
|
3075 | DC::save_cfg if $CFG->{config_autosave}; |
|
|
3076 | |
|
|
3077 | #video_shutdown; |
|
|
3078 | #audio_shutdown; |
|
|
3079 | |
|
|
3080 | DC::OpenGL::quit; |
|
|
3081 | DC::SDL_Quit; |
|
|
3082 | DC::DB::Server::stop; |
3070 | }; |
3083 | }; |
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 | } |
3084 | } |
3086 | |
|
|
3087 | *DC::Main::run = \&DC::SDL_braino; # see sub above |
|
|
3088 | |
3085 | |
3089 | 1 |
3086 | 1 |