ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/deliantra
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/deliantra (file contents):
Revision 1.48 by root, Mon Jul 7 08:02:17 2008 UTC vs.
Revision 1.52 by root, Fri Jul 18 21:18:42 2008 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3{
4package Deliantra::Client; # work around CPAN breakage
5package App::Deliantra; # try to reserve namespace
6}
7 2
8if ($ENV{DELIANTRA_CORO_DEBUG}) { 3if ($ENV{DELIANTRA_CORO_DEBUG}) {
9 eval ' 4 eval '
10 use Coro; 5 use Coro;
11 use Coro::EV; 6 use Coro::EV;
103 98
104use Deliantra; 99use Deliantra;
105use Deliantra::Protocol::Constants; 100use Deliantra::Protocol::Constants;
106 101
107use AnyEvent::DNS; 102use AnyEvent::DNS;
103use AnyEvent::Socket ();
108 104
109use Compress::LZF; 105use Compress::LZF;
110 106
111use DC; 107use DC;
112BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } 108BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } }
113use DC::OpenGL (); 109use DC::OpenGL ();
114use DC::Protocol; 110use DC::Protocol;
115use DC::DB; 111use DC::DB;
116use DC::UI; 112use DC::UI;
117use DC::UI::Canvas; 113use DC::UI::Canvas;
146our $FAST; # fast, low-quality mode, possibly useful for software-rendering 142our $FAST; # fast, low-quality mode, possibly useful for software-rendering
147 143
148our $WANT_REFRESH; 144our $WANT_REFRESH;
149 145
150our @SDL_MODES; 146our @SDL_MODES;
147our $SDL_REINIT = 1;
151our $WIDTH; 148our $WIDTH;
152our $HEIGHT; 149our $HEIGHT;
153our $FULLSCREEN; 150our $FULLSCREEN;
154our $FONTSIZE; 151our $FONTSIZE;
155 152
741 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 738 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
742 739
743 $CONN = 740 $CONN =
744 new DC::Protocol 741 new DC::Protocol
745 host => $host, 742 host => $host,
746 port => $port || 13327, 743 port => $port,
747 user => $PROFILE->{user}, 744 user => $PROFILE->{user},
748 pass => $PROFILE->{password}, 745 pass => $PROFILE->{password},
749 mapw => $mapsize, 746 mapw => $mapsize,
750 maph => $mapsize, 747 maph => $mapsize,
751 748
779 status "logging in..."; 776 status "logging in...";
780 777
781 $LOGIN_BUTTON->set_text ("Logout"); 778 $LOGIN_BUTTON->set_text ("Logout");
782 $SETUP_DIALOG->hide; 779 $SETUP_DIALOG->hide;
783 780
784 my ($host, $port) = split /:/, $PROFILE->{host}; 781 my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327";
785 782
786 $MAP = new DC::Map; 783 $MAP = new DC::Map;
787 784
788 # hack to make SURE we find the IP address all right 785 # hack to make SURE we find the IP address all right
789 # can be removed once AnyEvent::DNS is proven stable. 786 # can be removed once AnyEvent::DNS is proven stable.
868 state => $CFG->{force_opengl11}, 865 state => $CFG->{force_opengl11},
869 tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in " 866 tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in "
870 . "higher memory usage and slower performance. It will, however, help tremendously on " 867 . "higher memory usage and slower performance. It will, however, help tremendously on "
871 . "cards that claim to support a feature but fall back to software rendering. " 868 . "cards that claim to support a feature but fall back to software rendering. "
872 . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " 869 . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, "
873 . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " 870 . "but cards and drivers from other vendors (ATI) are often just as bad. "
874 . "experience extremely low framerates and your card should do better, try this option.</b>", 871 . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>",
875 on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } 872 on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 }
873 );
874
875 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha");
876 $table->add_at (1, $row++, new DC::UI::CheckBox
877 state => $CFG->{disable_alpha},
878 tooltip => "Forbid off the use of the alpha channel. This makes Deliantra look a lot worse "
879 . "by disabling a number of textures and transparency effects. Normally, these "
880 . "effects do not cost a lot of resources, but some graphics cards might fall "
881 . "back to etxremely slow rendering if this is enabled. If disabling this option "
882 . "noticably improves the framerate of the client please report this! "
883 . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>",
884 on_changed => sub {
885 my ($self, $value) = @_;
886 $CFG->{disable_alpha} = $value;
887 $SDL_REINIT = 1; # SDL_SetVideoMode ignores GL attr changes
888 0
889 }
876 ); 890 );
877 891
878 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); 892 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures");
879 $table->add_at (1, $row++, new DC::UI::CheckBox 893 $table->add_at (1, $row++, new DC::UI::CheckBox
880 state => $CFG->{texture_compression}, 894 state => $CFG->{texture_compression},
2151 $dialog->show; 2165 $dialog->show;
2152 }; 2166 };
2153} 2167}
2154 2168
2155sub sdl_init { 2169sub sdl_init {
2156 DC::SDL_Init 2170 DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE
2157 and die "SDL::Init failed!\n"; 2171 and die "SDL::Init failed!\n";
2158} 2172}
2159 2173
2160sub video_init { 2174sub video_init {
2175 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT;
2176 $SDL_REINIT = 0;
2177
2178 @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 8;
2179 @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES;
2180 @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES;
2181 @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
2182
2183 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES;
2184
2161 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; 2185 if (!exists $CFG->{sdl_mode} or $CFG->{sdl_mode} >= @SDL_MODES) {
2186 $CFG->{sdl_mode} = 0;
2187 for (reverse 0 .. $#SDL_MODES) {
2188 $CFG->{sdl_mode} = $_ if $SDL_MODES[$_][0] * $SDL_MODES[$_][1] >= 800 * 600;
2189 }
2190 }
2162 2191
2163 my ($old_w, $old_h) = ($WIDTH, $HEIGHT); 2192 my ($old_w, $old_h) = ($WIDTH, $HEIGHT);
2164 2193
2165 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 2194 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
2166 $FULLSCREEN = $CFG->{fullscreen}; 2195 $FULLSCREEN = $CFG->{fullscreen};
2355 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2384 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2356} 2385}
2357 2386
2358sub video_shutdown { 2387sub video_shutdown {
2359 DC::OpenGL::shutdown; 2388 DC::OpenGL::shutdown;
2389 DC::SDL_QuitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT;
2360 2390
2361 undef $SDL_ACTIVE; 2391 undef $SDL_ACTIVE;
2362} 2392}
2363 2393
2364my %animate_object; 2394my %animate_object;
2425# printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; 2455# printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS;
2426 }, 2456 },
2427 DC::SDL_KEYDOWN => sub { 2457 DC::SDL_KEYDOWN => sub {
2428 if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { 2458 if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) {
2429 # alt-enter 2459 # alt-enter
2460 video_shutdown;
2430 $FULLSCREEN_ENABLE->toggle; 2461 $FULLSCREEN_ENABLE->toggle;
2431 video_shutdown;
2432 video_init; 2462 video_init;
2433 } else { 2463 } else {
2434 &DC::UI::feed_sdl_key_down_event; 2464 &DC::UI::feed_sdl_key_down_event;
2435 } 2465 }
2436 update_modbox; 2466 update_modbox;
2485 my %DEF_CFG = ( 2515 my %DEF_CFG = (
2486 sdl_mode => 0, 2516 sdl_mode => 0,
2487 fullscreen => 1, 2517 fullscreen => 1,
2488 fast => 0, 2518 fast => 0,
2489 force_opengl11 => undef, 2519 force_opengl11 => undef,
2520 disable_alpha => 0,
2490 texture_compression => 1, 2521 texture_compression => 1,
2491 map_scale => 1, 2522 map_scale => 1,
2492 fow_enable => 1, 2523 fow_enable => 1,
2493 fow_intensity => 0, 2524 fow_intensity => 0,
2494 map_smoothing => 1, 2525 map_smoothing => 1,
2535 } 2566 }
2536 } 2567 }
2537 2568
2538 sdl_init; 2569 sdl_init;
2539 2570
2540 @SDL_MODES = DC::SDL_ListModes 8, 8;
2541 @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES;
2542 @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
2543
2544 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES;
2545
2546 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
2547
2548 { 2571 {
2549 my @fonts = map DC::find_rcfile "fonts/$_", qw( 2572 my @fonts = map DC::find_rcfile "fonts/$_", qw(
2550 DejaVuSans.ttf 2573 DejaVuSans.ttf
2551 DejaVuSansMono.ttf 2574 DejaVuSansMono.ttf
2552 DejaVuSans-Bold.ttf 2575 DejaVuSans-Bold.ttf

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines