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.41 by elmex, Mon May 5 20:51:36 2008 UTC vs.
Revision 1.50 by root, Thu Jul 17 13:07:01 2008 UTC

97use List::Util qw(max min); 97use List::Util qw(max min);
98 98
99use Deliantra; 99use Deliantra;
100use Deliantra::Protocol::Constants; 100use Deliantra::Protocol::Constants;
101 101
102use AnyEvent::DNS;
103
102use Compress::LZF; 104use Compress::LZF;
103 105
106use DC;
104use DC; BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } 107BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } }
105use DC::OpenGL (); 108use DC::OpenGL ();
106use DC::Protocol; 109use DC::Protocol;
107use DC::DB; 110use DC::DB;
108use DC::UI; 111use DC::UI;
109use DC::UI::Canvas; 112use DC::UI::Canvas;
725 728
726 $vbox->add (@dialog); 729 $vbox->add (@dialog);
727 $dialog->show; 730 $dialog->show;
728} 731}
729 732
730sub start_game { 733sub dc_connect {
731 status "logging in..."; 734 my ($host, $port) = @_;
732
733 $LOGIN_BUTTON->set_text ("Logout");
734 $SETUP_DIALOG->hide;
735 735
736 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 736 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
737 737
738 my ($host, $port) = split /:/, $PROFILE->{host};
739
740 $MAP = new DC::Map;
741
742 $CONN = eval { 738 $CONN =
743 new DC::Protocol 739 new DC::Protocol
744 host => $host, 740 host => $host,
745 port => $port || 13327, 741 port => $port || "deliantra=13327",
746 user => $PROFILE->{user}, 742 user => $PROFILE->{user},
747 pass => $PROFILE->{password}, 743 pass => $PROFILE->{password},
748 mapw => $mapsize, 744 mapw => $mapsize,
749 maph => $mapsize, 745 maph => $mapsize,
750 746
757 query => \&server_query, 753 query => \&server_query,
758 754
759 setup_req => { 755 setup_req => {
760 smoothing => $CFG->{map_smoothing}*1, 756 smoothing => $CFG->{map_smoothing}*1,
761 }, 757 },
762 };
763 758
764 if ($CONN) { 759 on_connect => sub {
760 if ($_[0]) {
765 DC::lowdelay fileno $CONN->{fh}; 761 DC::lowdelay fileno $CONN->{fh};
766 762
767 status "login successful"; 763 status "login successful";
764 } else {
765 undef $CONN;
766 status "unable to connect: $!";
767 stop_game();
768 }
769 },
770 ;
771}
772
773sub start_game {
774 status "logging in...";
775
776 $LOGIN_BUTTON->set_text ("Logout");
777 $SETUP_DIALOG->hide;
778
779 my ($host, $port) = split /:/, $PROFILE->{host};
780
781 $MAP = new DC::Map;
782
783 # hack to make SURE we find the IP address all right
784 # can be removed once AnyEvent::DNS is proven stable.
785 if ($host eq "gameserver.deliantra.net") {
786 AnyEvent::DNS::a "dnstest.deliantra.net", sub {
787 if ($_[0] ne "80.101.114.108") { # Perl
788 status "dns failure, using hardcoded address";
789 $host = "129.13.162.95";
790 }
791
792 dc_connect $host, $port;
793 };
768 } else { 794 } else {
769 warn $@; 795 dc_connect $host, $port;
770 status "unable to connect";
771 stop_game();
772 } 796 }
773} 797}
774 798
775sub stop_game { 799sub stop_game {
776 $LOGIN_BUTTON->set_text ("Login / Register"); 800 $LOGIN_BUTTON->set_text ("Login / Register");
2482 pickup => 0, 2506 pickup => 0,
2483 inv_sort => "mtime", 2507 inv_sort => "mtime",
2484 default => "profile", # default profile 2508 default => "profile", # default profile
2485 show_tips => 1, 2509 show_tips => 1,
2486 logview_max_par => 1000, 2510 logview_max_par => 1000,
2511 shift_fire_stop => 0,
2487 ); 2512 );
2488 2513
2489 while (my ($k, $v) = each %DEF_CFG) { 2514 while (my ($k, $v) = each %DEF_CFG) {
2490 $CFG->{$k} = $v unless exists $CFG->{$k}; 2515 $CFG->{$k} = $v unless exists $CFG->{$k};
2491 } 2516 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines