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.45 by root, Mon May 26 03:35:42 2008 UTC vs.
Revision 1.50 by root, Thu Jul 17 13:07:01 2008 UTC

96use EV; 96use EV;
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
102use AnyEvent::DNS;
101 103
102use Compress::LZF; 104use Compress::LZF;
103 105
104use DC; 106use DC;
105BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } 107BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } }
726 728
727 $vbox->add (@dialog); 729 $vbox->add (@dialog);
728 $dialog->show; 730 $dialog->show;
729} 731}
730 732
731sub start_game { 733sub dc_connect {
732 status "logging in..."; 734 my ($host, $port) = @_;
733
734 $LOGIN_BUTTON->set_text ("Logout");
735 $SETUP_DIALOG->hide;
736 735
737 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;
738 737
739 my ($host, $port) = split /:/, $PROFILE->{host};
740
741 $MAP = new DC::Map;
742
743 $CONN = 738 $CONN =
744 new DC::Protocol 739 new DC::Protocol
745 host => $host, 740 host => $host,
746 port => $port || 13327, 741 port => $port || "deliantra=13327",
747 user => $PROFILE->{user}, 742 user => $PROFILE->{user},
748 pass => $PROFILE->{password}, 743 pass => $PROFILE->{password},
749 mapw => $mapsize, 744 mapw => $mapsize,
750 maph => $mapsize, 745 maph => $mapsize,
751 746
771 status "unable to connect: $!"; 766 status "unable to connect: $!";
772 stop_game(); 767 stop_game();
773 } 768 }
774 }, 769 },
775 ; 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 };
794 } else {
795 dc_connect $host, $port;
796 }
776} 797}
777 798
778sub stop_game { 799sub stop_game {
779 $LOGIN_BUTTON->set_text ("Login / Register"); 800 $LOGIN_BUTTON->set_text ("Login / Register");
780 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); 801 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines