… | |
… | |
2215 | |
2215 | |
2216 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2216 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2217 | $FULLSCREEN = $CFG->{fullscreen}; |
2217 | $FULLSCREEN = $CFG->{fullscreen}; |
2218 | $FAST = $CFG->{fast}; |
2218 | $FAST = $CFG->{fast}; |
2219 | |
2219 | |
|
|
2220 | # due to mac os x braindamage, we simply retry with !fullscreen in case of an error |
2220 | DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
2221 | DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
|
|
2222 | or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN |
2221 | or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; |
2223 | or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; |
2222 | |
2224 | |
2223 | $SDL_ACTIVE = 1; |
2225 | $SDL_ACTIVE = 1; |
2224 | $LAST_REFRESH = time - 0.01; |
2226 | $LAST_REFRESH = time - 0.01; |
2225 | |
2227 | |
… | |
… | |
2515 | $SIG{INT} = $SIG{TERM} = sub { |
2517 | $SIG{INT} = $SIG{TERM} = sub { |
2516 | EV::unloop; |
2518 | EV::unloop; |
2517 | #d# TODO calling exit here hangs the process in some futex |
2519 | #d# TODO calling exit here hangs the process in some futex |
2518 | }; |
2520 | }; |
2519 | |
2521 | |
2520 | { |
2522 | # due to mac os x + sdl combined briandamage, we need this contortion |
|
|
2523 | sub main { |
|
|
2524 | { |
2521 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2525 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2522 | |
2526 | |
2523 | if (-e "$Deliantra::VARDIR/client.cf") { |
2527 | if (-e "$Deliantra::VARDIR/client.cf") { |
2524 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2528 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2525 | } else { |
2529 | } else { |
2526 | #TODO: compatibility cruft |
2530 | #TODO: compatibility cruft |
2527 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2531 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2528 | print STDERR "INFO: used old configuration file\n"; |
2532 | print STDERR "INFO: used old configuration file\n"; |
2529 | } |
2533 | } |
2530 | |
2534 | |
2531 | DC::DB::Server::run; |
2535 | DC::DB::Server::run; |
2532 | |
2536 | |
2533 | if ($CFG->{db_schema} < 1) { |
2537 | if ($CFG->{db_schema} < 1) { |
2534 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2538 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2535 | DC::DB::nuke_db; |
2539 | DC::DB::nuke_db; |
2536 | $CFG->{db_schema} = 1; |
2540 | $CFG->{db_schema} = 1; |
2537 | DC::write_cfg; |
2541 | DC::write_cfg; |
2538 | } |
2542 | } |
2539 | |
2543 | |
2540 | DC::DB::open_db; |
2544 | DC::DB::open_db; |
2541 | |
2545 | |
2542 | DC::UI::set_layout ($::CFG->{layout}); |
2546 | DC::UI::set_layout ($::CFG->{layout}); |
2543 | |
2547 | |
2544 | my %DEF_CFG = ( |
2548 | my %DEF_CFG = ( |
2545 | sdl_mode => 0, |
2549 | sdl_mode => 0, |
2546 | fullscreen => 1, |
2550 | fullscreen => 1, |
2547 | fast => 0, |
2551 | fast => 0, |
2548 | force_opengl11 => undef, |
2552 | force_opengl11 => undef, |
2549 | disable_alpha => 0, |
2553 | disable_alpha => 0, |
2550 | smooth_movement => 1, |
2554 | smooth_movement => 1, |
2551 | texture_compression => 1, |
2555 | texture_compression => 1, |
2552 | map_scale => 1, |
2556 | map_scale => 1, |
2553 | fow_enable => 1, |
2557 | fow_enable => 1, |
2554 | fow_intensity => 0, |
2558 | fow_intensity => 0, |
2555 | map_smoothing => 1, |
2559 | map_smoothing => 1, |
2556 | gui_fontsize => 1, |
2560 | gui_fontsize => 1, |
2557 | log_fontsize => 0.7, |
2561 | log_fontsize => 0.7, |
2558 | gauge_fontsize => 1, |
2562 | gauge_fontsize => 1, |
2559 | gauge_size => 0.35, |
2563 | gauge_size => 0.35, |
2560 | stat_fontsize => 0.7, |
2564 | stat_fontsize => 0.7, |
2561 | mapsize => 100, |
2565 | mapsize => 100, |
2562 | audio_enable => 1, |
2566 | audio_enable => 1, |
2563 | audio_hw_channels => 0, |
2567 | audio_hw_channels => 0, |
2564 | audio_hw_frequency => 0, |
2568 | audio_hw_frequency => 0, |
2565 | audio_hw_chunksize => 0, |
2569 | audio_hw_chunksize => 0, |
2566 | audio_mix_channels => 8, |
2570 | audio_mix_channels => 8, |
2567 | effects_enable => 1, |
2571 | effects_enable => 1, |
2568 | effects_volume => 1, |
2572 | effects_volume => 1, |
2569 | bgm_enable => 1, |
2573 | bgm_enable => 1, |
2570 | bgm_volume => 0.5, |
2574 | bgm_volume => 0.5, |
2571 | output_rate => "", |
2575 | output_rate => "", |
2572 | pickup => 0, |
2576 | pickup => 0, |
2573 | inv_sort => "mtime", |
2577 | inv_sort => "mtime", |
2574 | default => "profile", # default profile |
2578 | default => "profile", # default profile |
2575 | show_tips => 1, |
2579 | show_tips => 1, |
2576 | logview_max_par => 1000, |
2580 | logview_max_par => 1000, |
2577 | shift_fire_stop => 0, |
2581 | shift_fire_stop => 0, |
2578 | ); |
2582 | ); |
2579 | |
2583 | |
2580 | while (my ($k, $v) = each %DEF_CFG) { |
2584 | while (my ($k, $v) = each %DEF_CFG) { |
2581 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2585 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2582 | } |
2586 | } |
2583 | |
2587 | |
2584 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2588 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2585 | $PROFILE = $CFG->{profile}{default}; |
2589 | $PROFILE = $CFG->{profile}{default}; |
2586 | |
2590 | |
2587 | # convert old bindings (only default profile matters) |
2591 | # convert old bindings (only default profile matters) |
2588 | if (my $bindings = delete $PROFILE->{bindings}) { |
2592 | if (my $bindings = delete $PROFILE->{bindings}) { |
2589 | while (my ($mod, $syms) = each %$bindings) { |
2593 | while (my ($mod, $syms) = each %$bindings) { |
2590 | while (my ($sym, $cmds) = each %$syms) { |
2594 | while (my ($sym, $cmds) = each %$syms) { |
2591 | push @{ $PROFILE->{macro} }, { |
2595 | push @{ $PROFILE->{macro} }, { |
2592 | accelkey => [$mod*1, $sym*1], |
2596 | accelkey => [$mod*1, $sym*1], |
2593 | action => $cmds, |
2597 | action => $cmds, |
|
|
2598 | }; |
2594 | }; |
2599 | } |
2595 | } |
2600 | } |
2596 | } |
2601 | } |
2597 | } |
|
|
2598 | |
2602 | |
2599 | sdl_init; |
2603 | sdl_init; |
2600 | |
2604 | |
2601 | { |
2605 | { |
2602 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2606 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2603 | DejaVuSans.ttf |
2607 | DejaVuSans.ttf |
2604 | DejaVuSansMono.ttf |
2608 | DejaVuSansMono.ttf |
2605 | DejaVuSans-Bold.ttf |
2609 | DejaVuSans-Bold.ttf |
2606 | DejaVuSansMono-Bold.ttf |
2610 | DejaVuSansMono-Bold.ttf |
2607 | DejaVuSans-Oblique.ttf |
2611 | DejaVuSans-Oblique.ttf |
2608 | DejaVuSansMono-Oblique.ttf |
2612 | DejaVuSansMono-Oblique.ttf |
2609 | DejaVuSans-BoldOblique.ttf |
2613 | DejaVuSans-BoldOblique.ttf |
2610 | DejaVuSansMono-BoldOblique.ttf |
2614 | DejaVuSansMono-BoldOblique.ttf |
2611 | ); |
2615 | ); |
2612 | |
2616 | |
2613 | DC::add_font $_ for @fonts; |
2617 | DC::add_font $_ for @fonts; |
2614 | |
2618 | |
2615 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2619 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2616 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2620 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2617 | |
2621 | |
2618 | $FONT_PROP->make_default; |
2622 | $FONT_PROP->make_default; |
2619 | |
2623 | |
2620 | DC::pango_init; |
2624 | DC::pango_init; |
2621 | } |
2625 | } |
2622 | |
2626 | |
2623 | # compare mono (ft) vs. rgba (cairo) |
2627 | # compare mono (ft) vs. rgba (cairo) |
2624 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2628 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2625 | # for my $rgba (0..1) { |
2629 | # for my $rgba (0..1) { |
2626 | # my $t1 = Time::HiRes::time; |
2630 | # my $t1 = Time::HiRes::time; |
… | |
… | |
2631 | # } |
2635 | # } |
2632 | # my $t2 = Time::HiRes::time; |
2636 | # my $t2 = Time::HiRes::time; |
2633 | # warn $t2-$t1; |
2637 | # warn $t2-$t1; |
2634 | # } |
2638 | # } |
2635 | |
2639 | |
2636 | video_init; |
2640 | video_init; |
2637 | audio_init; |
2641 | audio_init; |
2638 | } |
2642 | } |
2639 | |
2643 | |
2640 | show_tip_of_the_day if $CFG->{show_tips}; |
2644 | show_tip_of_the_day if $CFG->{show_tips}; |
2641 | |
2645 | |
2642 | our $STARTUP_CANCEL = EV::idle sub { |
2646 | our $STARTUP_CANCEL = EV::idle sub { |
2643 | undef $::STARTUP_CANCEL; |
2647 | undef $::STARTUP_CANCEL; |
2644 | $startup_done->(); |
2648 | $startup_done->(); |
2645 | }; |
2649 | }; |
2646 | |
2650 | |
2647 | delete $SIG{__DIE__}; |
2651 | delete $SIG{__DIE__}; |
2648 | EV::loop; |
2652 | EV::loop; |
2649 | |
2653 | |
2650 | #video_shutdown; |
2654 | #video_shutdown; |
2651 | #audio_shutdown; |
2655 | #audio_shutdown; |
2652 | DC::OpenGL::quit; |
2656 | DC::OpenGL::quit; |
2653 | DC::SDL_Quit; |
2657 | DC::SDL_Quit; |
2654 | DC::DB::Server::stop; |
2658 | DC::DB::Server::stop; |
|
|
2659 | } |
|
|
2660 | |
|
|
2661 | DC::SDL_braino; # see sub above |
2655 | |
2662 | |
2656 | =head1 NAME |
2663 | =head1 NAME |
2657 | |
2664 | |
2658 | deliantra - A Deliantra MORPG game client |
2665 | deliantra - A Deliantra MORPG game client |
2659 | |
2666 | |