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.96 by root, Mon Jul 27 23:08:41 2009 UTC vs.
Revision 1.109 by root, Thu Apr 8 19:11:21 2010 UTC

32 Win32::GUI::SplashScreen::Done (1); 32 Win32::GUI::SplashScreen::Done (1);
33 }; 33 };
34 } 34 }
35} 35}
36 36
37use strict; 37use common::sense;
38use utf8;
39 38
40use Carp 'verbose'; 39use Carp 'verbose';
41 40
42# do things only needed for single-binary version (par) 41# do things only needed for single-binary version (par)
43BEGIN { 42BEGIN {
133 crash "CRASH/EV::DIED: $@" => 0; 132 crash "CRASH/EV::DIED: $@" => 0;
134 DC::fatal Carp::longmess $@; 133 DC::fatal Carp::longmess $@;
135}; 134};
136 135
137my $MAX_FPS = 60; 136my $MAX_FPS = 60;
137
138our $DEFAULT_SERVER = "gameserver.deliantra.net";
138 139
139our $META_SERVER = "http://metaserver.schmorp.de/current.json"; 140our $META_SERVER = "http://metaserver.schmorp.de/current.json";
140 141
141our $LAST_REFRESH; 142our $LAST_REFRESH;
142our $NOW; 143our $NOW;
539 sub audio_tab_update; 540 sub audio_tab_update;
540 audio_tab_update; 541 audio_tab_update;
541} 542}
542 543
543sub audio_shutdown { 544sub audio_shutdown {
545 if ($SDL_MIXER) {
546 DC::MixMusic::halt;
547 DC::Mix_AllocateChannels 0;
548 }
549
544 undef $MUSIC_PLAYER; 550 undef $MUSIC_PLAYER;
545 undef $MUSIC_PLAYING_META; 551 undef $MUSIC_PLAYING_META;
546 undef $MUSIC_PLAYING_DATA; 552 undef $MUSIC_PLAYING_DATA;
547 553
548 $MUSIC_WANT = []; 554 $MUSIC_WANT = [];
549 @MUSIC_JINGLE = (); 555 @MUSIC_JINGLE = ();
550 %AUDIO_PLAY = (); 556 %AUDIO_PLAY = ();
551 %AUDIO_CHUNK = (); 557 %AUDIO_CHUNK = ();
552 558
553 DC::MixMusic::halt;
554 DC::Mix_AllocateChannels 0;
555 DC::Mix_CloseAudio if $SDL_MIXER; 559 DC::Mix_CloseAudio if $SDL_MIXER;
556 undef $SDL_MIXER; 560 undef $SDL_MIXER;
557} 561}
558 562
559############################################################################# 563#############################################################################
802 user => $PROFILE->{user}, 806 user => $PROFILE->{user},
803 pass => $PROFILE->{password}, 807 pass => $PROFILE->{password},
804 mapw => $mapw, 808 mapw => $mapw,
805 maph => $maph, 809 maph => $maph,
806 810
811 c_version => {
812 client => "deliantra",
807 client => "$DC::VERSION $] $^O", 813 clientver => $DC::VERSION,
814 gl_vendor => DC::OpenGL::gl_vendor,
815 gl_version => DC::OpenGL::gl_version,
816 },
808 817
809 map_widget => $MAPWIDGET, 818 map_widget => $MAPWIDGET,
810 statusbox => $STATUSBOX, 819 statusbox => $STATUSBOX,
811 map => $MAP, 820 map => $MAP,
812 mapmap => $MAPMAP, 821 mapmap => $MAPMAP,
830 ; 839 ;
831} 840}
832 841
833sub start_game { 842sub start_game {
834 status "logging in..."; 843 status "logging in...";
844
845 my $server = $PROFILE->{host} || $DEFAULT_SERVER;
846 my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327"
847 or return status "$server: unable to parse server address, try an empty field.";
835 848
836 $LOGIN_BUTTON->set_text ("Logout"); 849 $LOGIN_BUTTON->set_text ("Logout");
837 $SETUP_DIALOG->hide; 850 $SETUP_DIALOG->hide;
838
839 my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327";
840 851
841 $MAP = new DC::Map; 852 $MAP = new DC::Map;
842 853
843 # hack to make SURE we find the IP address all right 854 # hack to make SURE we find the IP address all right
844 # can be removed once AnyEvent::DNS is proven stable. 855 # can be removed once AnyEvent::DNS is proven stable.
1027 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " 1038 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1028 . "then disable this option. Changes take effect immdiately.", 1039 . "then disable this option. Changes take effect immdiately.",
1029 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } 1040 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 }
1030 ); 1041 );
1031 1042
1043 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions");
1044 $table->add_at (1, $row++, new DC::UI::CheckBox
1045 state => $CFG->{smooth_transitions},
1046 tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. "
1047 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1048 . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.",
1049 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 }
1050 );
1051
1052
1032 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); 1053 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale");
1033 $table->add_at (1, $row++, new DC::UI::Slider 1054 $table->add_at (1, $row++, new DC::UI::Slider
1034 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 1055 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
1035 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 1056 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
1036 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } 1057 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
1048 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); 1069 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War");
1049 $table->add_at (1, $row++, new DC::UI::CheckBox 1070 $table->add_at (1, $row++, new DC::UI::CheckBox
1050 state => $CFG->{fow_enable}, 1071 state => $CFG->{fow_enable},
1051 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", 1072 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.",
1052 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } 1073 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 }
1074 );
1075
1076 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Pattern");
1077 $table->add_at (1, $row++, new DC::UI::ImageButton
1078 tex => $DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}],
1079 bg => [0.3, 0.3, 0.2],
1080 force_w => 64,
1081 force_h => 64,
1082 tooltip => "<b>Fog of War Pattern.</b> The pattern that is overlaid over areas hidden from view. Click to cycle through various alternatives. Changes are instant.",
1083 on_activate => sub {
1084 my ($self) = @_;
1085 $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN;
1086 $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]);
1087 $MAPWIDGET->update;
1088 }
1053 ); 1089 );
1054 1090
1055 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); 1091 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity");
1056 $table->add_at (1, $row++, new DC::UI::Slider 1092 $table->add_at (1, $row++, new DC::UI::Slider
1057 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], 1093 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256],
1109 1145
1110 my $text = !$freq 1146 my $text = !$freq
1111 ? "audio is off" 1147 ? "audio is off"
1112 : "audio is enabled\n" 1148 : "audio is enabled\n"
1113 . "frequency (Hz): $freq\n" 1149 . "frequency (Hz): $freq\n"
1114 . "channels: $chans"; 1150 . "channels: $chans\n"
1151 . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n"
1152 . "music decoders available: " . (join ", ", DC::MixMusic::decoders);
1115 1153
1116 $AUDIO_INFO->set_text ($text); 1154 $AUDIO_INFO->set_text ($text);
1117} 1155}
1118 1156
1119sub audio_setup { 1157sub audio_setup {
1639 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), 1677 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]),
1640 ); 1678 );
1641 1679
1642 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); 1680 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username");
1643 $table->add_at (1, 4, new DC::UI::Entry 1681 $table->add_at (1, 4, new DC::UI::Entry
1644 text => $CFG->{profile}{default}{user}, 1682 text => $PROFILE->{user},
1645 tooltip => "The name of your character on the server. The name is case-sensitive!", 1683 tooltip => "The name of your character on the server. The name is case-sensitive!",
1646 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } 1684 on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 }
1647 ); 1685 );
1648 1686
1649 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); 1687 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password");
1650 $table->add_at (1, 5, new DC::UI::Entry 1688 $table->add_at (1, 5, new DC::UI::Entry
1651 text => $CFG->{profile}{default}{password}, 1689 text => $PROFILE->{password},
1652 hidden => 1, 1690 hidden => 1,
1653 tooltip => "The password for your character.", 1691 tooltip => "The password for your character.",
1654 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } 1692 on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 }
1655 ); 1693 );
1656 1694
1657 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button 1695 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button
1658 expand => 1, 1696 expand => 1,
1659 text => "Login / Register", 1697 text => "Login / Register",
1695 $table->add_at (1, $row, my $vbox = new DC::UI::VBox); 1733 $table->add_at (1, $row, my $vbox = new DC::UI::VBox);
1696 1734
1697 $vbox->add ( 1735 $vbox->add (
1698 $HOST_ENTRY = new DC::UI::Entry 1736 $HOST_ENTRY = new DC::UI::Entry
1699 expand => 1, 1737 expand => 1,
1700 text => $CFG->{profile}{default}{host}, 1738 text => $PROFILE->{host},
1701 tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", 1739 tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)",
1702 on_changed => sub { 1740 on_changed => sub {
1703 my ($self, $value) = @_; 1741 my ($self, $value) = @_;
1704 $CFG->{profile}{default}{host} = $value; 1742 $PROFILE->{host} = $value;
1705 1 1743 1
1706 } 1744 }
1707 ); 1745 );
1708 1746
1709 if (0) { #d# disabled 1747 if (0) { #d# disabled
1908 $r 1946 $r
1909} 1947}
1910 1948
1911my %SORT_ORDER = ( 1949my %SORT_ORDER = (
1912 type => sub { 1950 type => sub {
1951 use sort 'stable';
1913 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ 1952 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_
1914 }, 1953 },
1915 mtime => sub { 1954 mtime => sub {
1955 use sort 'stable';
1916 my $NOW = time; 1956 my $NOW = time;
1917 sort { 1957 sort {
1918 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; 1958 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
1919 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; 1959 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
1920 1960
1921 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) 1961 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
1922 or $btime <=> $atime 1962 or $btime <=> $atime
1923 or $a->{type} <=> $b->{type} 1963 or $a->{type} <=> $b->{type}
1924 } @_ 1964 } @_
1925 }, 1965 },
1926 weight => sub { sort { 1966 weight => sub {
1967 use sort 'stable';
1968 sort {
1927 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) 1969 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1928 or $a->{type} <=> $b->{type} 1970 or $a->{type} <=> $b->{type}
1929 } @_ }, 1971 } @_
1972 },
1930); 1973);
1931 1974
1932sub inventory_widget { 1975sub inventory_widget {
1933 my $hb = new DC::UI::HBox homogeneous => 1; 1976 my $hb = new DC::UI::HBox homogeneous => 1;
1934 1977
2565 2608
2566 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); 2609 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]);
2567 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); 2610 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode});
2568 2611
2569 $CAVEAT_LABEL->set_text ("None :)"); 2612 $CAVEAT_LABEL->set_text ("None :)");
2613 $CAVEAT_LABEL->set_text ("Apple/NVIDIA Texture bug (slow)")
2614 if $DC::OpenGL::APPLE_NVIDIA_BUG;
2570 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") 2615 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)")
2571 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; 2616 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL;
2572 2617
2573 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2618 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2574} 2619}
2707 fullscreen => 1, 2752 fullscreen => 1,
2708 fast => 0, 2753 fast => 0,
2709 force_opengl11 => undef, 2754 force_opengl11 => undef,
2710 disable_alpha => 0, 2755 disable_alpha => 0,
2711 smooth_movement => 1, 2756 smooth_movement => 1,
2757 smooth_transitions => 1,
2712 texture_compression => 1, 2758 texture_compression => 1,
2713 map_scale => 1, 2759 map_scale => 1,
2714 fow_enable => 1, 2760 fow_enable => 1,
2715 fow_intensity => 0, 2761 fow_intensity => 0,
2762 fow_texture => 0,
2716 map_smoothing => 1, 2763 map_smoothing => 1,
2717 gui_fontsize => 1, 2764 gui_fontsize => 1,
2718 log_fontsize => 0.7, 2765 log_fontsize => 0.7,
2719 gauge_fontsize => 1, 2766 gauge_fontsize => 1,
2720 gauge_size => 0.35, 2767 gauge_size => 0.35,
2738 shift_fire_stop => 0, 2785 shift_fire_stop => 0,
2739 uitheme => "wood", 2786 uitheme => "wood",
2740 map_shift_x => -24, # arbitrary 2787 map_shift_x => -24, # arbitrary
2741 map_shift_y => +24, # arbitrary 2788 map_shift_y => +24, # arbitrary
2742 ); 2789 );
2743 2790
2744 while (my ($k, $v) = each %DEF_CFG) { 2791 while (my ($k, $v) = each %DEF_CFG) {
2745 $CFG->{$k} = $v unless exists $CFG->{$k}; 2792 $CFG->{$k} = $v unless exists $CFG->{$k};
2746 } 2793 }
2747 2794
2748 $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; 2795 my @args = @ARGV;
2796
2797 my $profile = 'default';
2798
2799 for (my $i = 0; $i < @args; $i++) {
2800 if ($args[$i] =~ /^--?profile$/) {
2801 $profile = $args[$i + 1];
2802 splice @args, $i, 2, ();
2803 $i = 0;
2804 } elsif ($args[$i] =~ /^--?h/) {
2805 print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
2806 exit 0;
2807 }
2808 }
2809
2810 $CFG->{profile}{$profile} ||= {};
2749 $PROFILE = $CFG->{profile}{default}; 2811 $PROFILE = $CFG->{profile}{$profile};
2812 $PROFILE->{host} ||= "gameserver.deliantra.net";
2813
2814 $PROFILE->{host} = $args[0] if @args > 0;
2815 $PROFILE->{user} = $args[1] if @args > 1;
2816 $PROFILE->{password} = $args[2] if @args > 2;
2750 2817
2751 # convert old bindings (only default profile matters) 2818 # convert old bindings (only default profile matters)
2752 if (my $bindings = delete $PROFILE->{bindings}) { 2819 if (my $bindings = delete $PROFILE->{bindings}) {
2753 while (my ($mod, $syms) = each %$bindings) { 2820 while (my ($mod, $syms) = each %$bindings) {
2754 while (my ($sym, $cmds) = each %$syms) { 2821 while (my ($sym, $cmds) = each %$syms) {
2777 DejaVuSansMono-BoldOblique.ttf 2844 DejaVuSansMono-BoldOblique.ttf
2778 mona.ttf 2845 mona.ttf
2779 ); 2846 );
2780 2847
2781 DC::add_font $_ for @fonts; 2848 DC::add_font $_ for @fonts;
2782 2849
2783 $FONT_PROP = new_from_file DC::Font $fonts[0]; 2850 $FONT_PROP = new_from_file DC::Font $fonts[0];
2784 $FONT_FIXED = new_from_file DC::Font $fonts[1]; 2851 $FONT_FIXED = new_from_file DC::Font $fonts[1];
2785 2852
2786 $FONT_PROP->make_default; 2853 $FONT_PROP->make_default;
2787 2854
2831 2898
2832deliantra - A Deliantra MORPG game client 2899deliantra - A Deliantra MORPG game client
2833 2900
2834=head1 SYNOPSIS 2901=head1 SYNOPSIS
2835 2902
2836Just run it - no commandline arguments are supported. 2903 deliantra [--profile name] [host [user [password]]]
2904 deliantra --help
2837 2905
2838=head1 USAGE 2906=head1 USAGE
2839 2907
2840deliantra utilises OpenGL for all UI elements and the game. It is supposed to 2908The deliantra client utilises OpenGL for all UI elements and the game. It
2841be used in fullscreen mode and interactively. 2909is supposed to be used in fullscreen mode and interactively.
2842 2910
2843=head1 DEBUGGING 2911=head1 DEBUGGING
2844
2845 2912
2846CFPLUS_DEBUG - environment variable 2913CFPLUS_DEBUG - environment variable
2847 2914
2848 1 draw borders around widgets 2915 1 draw borders around widgets
2849 2 add low-level widget info to tooltips 2916 2 add low-level widget info to tooltips

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines