… | |
… | |
32 | Win32::GUI::SplashScreen::Done (1); |
32 | Win32::GUI::SplashScreen::Done (1); |
33 | }; |
33 | }; |
34 | } |
34 | } |
35 | } |
35 | } |
36 | |
36 | |
37 | use strict; |
37 | use common::sense; |
38 | use utf8; |
|
|
39 | |
38 | |
40 | use Carp 'verbose'; |
39 | use Carp 'verbose'; |
41 | |
40 | |
42 | # do things only needed for single-binary version (par) |
41 | # do things only needed for single-binary version (par) |
43 | BEGIN { |
42 | BEGIN { |
… | |
… | |
144 | our $NOW; |
143 | our $NOW; |
145 | |
144 | |
146 | our $CFG; |
145 | our $CFG; |
147 | our $PROFILE; # current profile |
146 | our $PROFILE; # current profile |
148 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
147 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
|
|
148 | our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1; |
149 | |
149 | |
150 | our $WANT_REFRESH; |
150 | our $WANT_REFRESH; |
151 | |
151 | |
152 | our $MODE_SLIDER; |
152 | our $MODE_SLIDER; |
153 | our $CAVEAT_LABEL; |
153 | our $CAVEAT_LABEL; |
… | |
… | |
807 | user => $PROFILE->{user}, |
807 | user => $PROFILE->{user}, |
808 | pass => $PROFILE->{password}, |
808 | pass => $PROFILE->{password}, |
809 | mapw => $mapw, |
809 | mapw => $mapw, |
810 | maph => $maph, |
810 | maph => $maph, |
811 | |
811 | |
|
|
812 | c_version => { |
|
|
813 | client => "deliantra", |
812 | client => "$DC::VERSION $] $^O", |
814 | clientver => $DC::VERSION, |
|
|
815 | gl_vendor => DC::OpenGL::gl_vendor, |
|
|
816 | gl_version => DC::OpenGL::gl_version, |
|
|
817 | }, |
813 | |
818 | |
814 | map_widget => $MAPWIDGET, |
819 | map_widget => $MAPWIDGET, |
815 | statusbox => $STATUSBOX, |
820 | statusbox => $STATUSBOX, |
816 | map => $MAP, |
821 | map => $MAP, |
817 | mapmap => $MAPMAP, |
822 | mapmap => $MAPMAP, |
… | |
… | |
849 | |
854 | |
850 | # hack to make SURE we find the IP address all right |
855 | # hack to make SURE we find the IP address all right |
851 | # can be removed once AnyEvent::DNS is proven stable. |
856 | # can be removed once AnyEvent::DNS is proven stable. |
852 | if ($host eq "gameserver.deliantra.net") { |
857 | if ($host eq "gameserver.deliantra.net") { |
853 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
858 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
854 | if ($_[0] ne "80.101.114.108") { # Perl |
859 | if ($_[0] ne "80.101.114.108") { # P-e-r-l |
855 | status "dns failure, trying differently"; |
860 | status "dns failure, trying differently"; |
856 | $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; |
861 | $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; |
857 | unless (defined $host) { |
862 | unless (defined $host) { |
858 | status "dns failure, using hardcoded address"; |
863 | status "dns failure, using hardcoded address"; |
859 | $host = "129.13.162.95"; |
864 | $host = "194.126.175.154"; |
860 | } |
865 | } |
861 | } |
866 | } |
862 | |
867 | |
863 | dc_connect $host, $port; |
868 | dc_connect $host, $port; |
864 | }; |
869 | }; |
… | |
… | |
1140 | ]); |
1145 | ]); |
1141 | |
1146 | |
1142 | my $text = !$freq |
1147 | my $text = !$freq |
1143 | ? "audio is off" |
1148 | ? "audio is off" |
1144 | : "audio is enabled\n" |
1149 | : "audio is enabled\n" |
|
|
1150 | . "driver: " . DC::SDL_AudioDriverName . "\n" |
1145 | . "frequency (Hz): $freq\n" |
1151 | . "frequency (Hz): $freq\n" |
1146 | . "channels: $chans\n" |
1152 | . "channels: $chans\n" |
1147 | . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n" |
1153 | . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n" |
1148 | . "music decoders available: " . (join ", ", DC::MixMusic::decoders); |
1154 | . "music decoders available: " . (join ", ", DC::MixMusic::decoders); |
1149 | |
1155 | |
1150 | $AUDIO_INFO->set_text ($text); |
1156 | $AUDIO_INFO->set_text ($text); |
1151 | } |
1157 | } |
1152 | |
1158 | |
1153 | sub audio_setup { |
1159 | sub audio_setup { |
… | |
… | |
1182 | ); |
1188 | ); |
1183 | |
1189 | |
1184 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
1190 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
1185 | $table->add_at (1, $row, new DC::UI::CheckBox |
1191 | $table->add_at (1, $row, new DC::UI::CheckBox |
1186 | expand => 1, state => $CFG->{bgm_enable}, |
1192 | expand => 1, state => $CFG->{bgm_enable}, |
1187 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
1193 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played. Needs server reconnect to take effect.", |
1188 | on_changed => sub { |
1194 | on_changed => sub { |
1189 | $CFG->{bgm_enable} = $_[1]; |
1195 | $CFG->{bgm_enable} = $_[1]; |
1190 | $CONN->update_fx_want if $CONN; |
1196 | $CONN->update_fx_want if $CONN; |
1191 | audio_music_push; |
1197 | audio_music_push; |
1192 | 1 |
1198 | 1 |
… | |
… | |
1329 | &set_gauge_window_fontsize; |
1335 | &set_gauge_window_fontsize; |
1330 | |
1336 | |
1331 | $win |
1337 | $win |
1332 | } |
1338 | } |
1333 | |
1339 | |
|
|
1340 | our $BW_WATCHER; |
|
|
1341 | |
|
|
1342 | sub debug_toggle($) { |
|
|
1343 | $DELIANTRA_DEBUG ^= $_[0]; |
|
|
1344 | |
|
|
1345 | if ($DELIANTRA_DEBUG & 16) { |
|
|
1346 | $BW_WATCHER = EV::periodic 0, 1, 0, sub { |
|
|
1347 | return unless $CONN; |
|
|
1348 | debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3; |
|
|
1349 | $CONN->{octets_in} = 0; |
|
|
1350 | }; |
|
|
1351 | } else { |
|
|
1352 | undef $BW_WATCHER; |
|
|
1353 | } |
|
|
1354 | |
|
|
1355 | } |
|
|
1356 | |
1334 | sub debug_setup { |
1357 | sub debug_setup { |
1335 | my $table = new DC::UI::Table; |
1358 | my $table = new DC::UI::Table; |
1336 | |
1359 | |
1337 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1360 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1338 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); |
1361 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { debug_toggle 1; 0 }); |
1339 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1362 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1340 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); |
1363 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { debug_toggle 2; 0 }); |
1341 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1364 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1342 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); |
1365 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { debug_toggle 4; 0 }); |
1343 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1366 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1344 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); |
1367 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { debug_toggle 8; 0 }); |
|
|
1368 | $table->add_at (0, 4, new DC::UI::Label text => "Show Bandwidth"); |
|
|
1369 | $table->add_at (1, 4, new DC::UI::CheckBox on_changed => sub { debug_toggle 16; 0 }); |
|
|
1370 | |
1345 | $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1371 | $table->add_at (0, 6, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1346 | |
|
|
1347 | $table->add_at (0, 5, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1372 | $table->add_at (0, 7, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1348 | |
1373 | |
1349 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1374 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1350 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1375 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1351 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1376 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1352 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
1377 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
… | |
… | |
1942 | $r |
1967 | $r |
1943 | } |
1968 | } |
1944 | |
1969 | |
1945 | my %SORT_ORDER = ( |
1970 | my %SORT_ORDER = ( |
1946 | type => sub { |
1971 | type => sub { |
|
|
1972 | use sort 'stable'; |
1947 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1973 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1948 | }, |
1974 | }, |
1949 | mtime => sub { |
1975 | mtime => sub { |
|
|
1976 | use sort 'stable'; |
1950 | my $NOW = time; |
1977 | my $NOW = time; |
1951 | sort { |
1978 | sort { |
1952 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1979 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1953 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1980 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1954 | |
1981 | |
1955 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1982 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1956 | or $btime <=> $atime |
1983 | or $btime <=> $atime |
1957 | or $a->{type} <=> $b->{type} |
1984 | or $a->{type} <=> $b->{type} |
1958 | } @_ |
1985 | } @_ |
1959 | }, |
1986 | }, |
1960 | weight => sub { sort { |
1987 | weight => sub { |
|
|
1988 | use sort 'stable'; |
|
|
1989 | sort { |
1961 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1990 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1962 | or $a->{type} <=> $b->{type} |
1991 | or $a->{type} <=> $b->{type} |
1963 | } @_ }, |
1992 | } @_ |
|
|
1993 | }, |
1964 | ); |
1994 | ); |
1965 | |
1995 | |
1966 | sub inventory_widget { |
1996 | sub inventory_widget { |
1967 | my $hb = new DC::UI::HBox homogeneous => 1; |
1997 | my $hb = new DC::UI::HBox homogeneous => 1; |
1968 | |
1998 | |
… | |
… | |
2482 | |
2512 | |
2483 | $DEBUG_STATUS = new DC::UI::Label |
2513 | $DEBUG_STATUS = new DC::UI::Label |
2484 | padding => 0, |
2514 | padding => 0, |
2485 | z => 100, |
2515 | z => 100, |
2486 | force_x => "max", |
2516 | force_x => "max", |
2487 | force_y => 0; |
2517 | force_y => 20; |
2488 | $DEBUG_STATUS->show; |
2518 | $DEBUG_STATUS->show; |
2489 | |
2519 | |
2490 | $STATUSBOX = new DC::UI::Statusbox; |
2520 | $STATUSBOX = new DC::UI::Statusbox; |
2491 | |
2521 | |
2492 | $MODBOX = new DC::UI::Label |
2522 | $MODBOX = new DC::UI::Label |
… | |
… | |
2620 | my $animate_timer; |
2650 | my $animate_timer; |
2621 | |
2651 | |
2622 | my $fps = 9; |
2652 | my $fps = 9; |
2623 | |
2653 | |
2624 | sub force_refresh { |
2654 | sub force_refresh { |
2625 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2655 | if ($DELIANTRA_DEBUG & 4) { |
2626 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2656 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2627 | debug sprintf "%3.2f", $fps; |
2657 | debug sprintf "%3.2f", $fps; |
2628 | } |
2658 | } |
2629 | |
2659 | |
2630 | undef $WANT_REFRESH; |
2660 | undef $WANT_REFRESH; |
… | |
… | |
2786 | my @args = @ARGV; |
2816 | my @args = @ARGV; |
2787 | |
2817 | |
2788 | my $profile = 'default'; |
2818 | my $profile = 'default'; |
2789 | |
2819 | |
2790 | for (my $i = 0; $i < @args; $i++) { |
2820 | for (my $i = 0; $i < @args; $i++) { |
2791 | if ($args[$i] eq '-profile') { |
2821 | if ($args[$i] =~ /^--?profile$/) { |
2792 | $profile = $args[$i + 1]; |
2822 | $profile = $args[$i + 1]; |
2793 | splice @args, $i, 2, (); |
2823 | splice @args, $i, 2, (); |
2794 | $i = 0; |
2824 | $i = 0; |
|
|
2825 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2826 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2827 | exit 0; |
2795 | } |
2828 | } |
2796 | } |
2829 | } |
2797 | |
2830 | |
2798 | $CFG->{profile}{$profile} ||= {}; |
2831 | $CFG->{profile}{$profile} ||= {}; |
2799 | $PROFILE = $CFG->{profile}{$profile}; |
2832 | $PROFILE = $CFG->{profile}{$profile}; |
… | |
… | |
2865 | our $STARTUP_CANCEL = EV::idle sub { |
2898 | our $STARTUP_CANCEL = EV::idle sub { |
2866 | undef $::STARTUP_CANCEL; |
2899 | undef $::STARTUP_CANCEL; |
2867 | $startup_done->(); |
2900 | $startup_done->(); |
2868 | }; |
2901 | }; |
2869 | |
2902 | |
|
|
2903 | debug_toggle 0; |
|
|
2904 | |
2870 | delete $SIG{__DIE__}; |
2905 | delete $SIG{__DIE__}; |
2871 | EV::loop; |
2906 | EV::loop; |
2872 | |
2907 | |
2873 | DC::write_cfg if $CFG->{config_autosave}; |
2908 | DC::write_cfg if $CFG->{config_autosave}; |
2874 | |
2909 | |
… | |
… | |
2886 | |
2921 | |
2887 | deliantra - A Deliantra MORPG game client |
2922 | deliantra - A Deliantra MORPG game client |
2888 | |
2923 | |
2889 | =head1 SYNOPSIS |
2924 | =head1 SYNOPSIS |
2890 | |
2925 | |
2891 | Just run it - no commandline arguments are supported. |
2926 | deliantra [--profile name] [host [user [password]]] |
|
|
2927 | deliantra --help |
2892 | |
2928 | |
2893 | =head1 USAGE |
2929 | =head1 USAGE |
2894 | |
2930 | |
2895 | deliantra utilises OpenGL for all UI elements and the game. It is supposed to |
2931 | The deliantra client utilises OpenGL for all UI elements and the game. It |
2896 | be used in fullscreen mode and interactively. |
2932 | is supposed to be used in fullscreen mode and interactively. |
2897 | |
2933 | |
2898 | =head1 DEBUGGING |
2934 | =head1 DEBUGGING |
2899 | |
2935 | |
2900 | |
|
|
2901 | CFPLUS_DEBUG - environment variable |
2936 | DELIANTRA_DEBUG - environment variable |
2902 | |
2937 | |
2903 | 1 draw borders around widgets |
2938 | 1 draw borders around widgets |
2904 | 2 add low-level widget info to tooltips |
2939 | 2 add low-level widget info to tooltips |
2905 | 4 show fps |
2940 | 4 show fps |
2906 | 8 suppress tooltips |
2941 | 8 suppress tooltips |
|
|
2942 | 16 show bandwidth downstream |
2907 | |
2943 | |
2908 | =head1 AUTHOR |
2944 | =head1 AUTHOR |
2909 | |
2945 | |
2910 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2946 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2911 | |
2947 | |