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.43 by root, Wed May 21 23:35:55 2008 UTC vs.
Revision 1.51 by root, Thu Jul 17 15:23:43 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;
103use AnyEvent::Socket ();
104
102use Compress::LZF; 105use Compress::LZF;
103 106
107use DC;
104use DC; BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } 108BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } }
105use DC::OpenGL (); 109use DC::OpenGL ();
106use DC::Protocol; 110use DC::Protocol;
107use DC::DB; 111use DC::DB;
108use DC::UI; 112use DC::UI;
109use DC::UI::Canvas; 113use DC::UI::Canvas;
725 729
726 $vbox->add (@dialog); 730 $vbox->add (@dialog);
727 $dialog->show; 731 $dialog->show;
728} 732}
729 733
730sub start_game { 734sub dc_connect {
731 status "logging in..."; 735 my ($host, $port) = @_;
732
733 $LOGIN_BUTTON->set_text ("Logout");
734 $SETUP_DIALOG->hide;
735 736
736 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 737 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
737 738
738 my ($host, $port) = split /:/, $PROFILE->{host};
739
740 $MAP = new DC::Map;
741
742 $CONN = eval { 739 $CONN =
743 local $SIG{__DIE__};
744
745 new DC::Protocol 740 new DC::Protocol
746 host => $host, 741 host => $host,
747 port => $port || 13327, 742 port => $port,
748 user => $PROFILE->{user}, 743 user => $PROFILE->{user},
749 pass => $PROFILE->{password}, 744 pass => $PROFILE->{password},
750 mapw => $mapsize, 745 mapw => $mapsize,
751 maph => $mapsize, 746 maph => $mapsize,
752 747
759 query => \&server_query, 754 query => \&server_query,
760 755
761 setup_req => { 756 setup_req => {
762 smoothing => $CFG->{map_smoothing}*1, 757 smoothing => $CFG->{map_smoothing}*1,
763 }, 758 },
764 };
765 759
766 if ($CONN) { 760 on_connect => sub {
761 if ($_[0]) {
767 DC::lowdelay fileno $CONN->{fh}; 762 DC::lowdelay fileno $CONN->{fh};
768 763
769 status "login successful"; 764 status "login successful";
765 } else {
766 undef $CONN;
767 status "unable to connect: $!";
768 stop_game();
769 }
770 },
771 ;
772}
773
774sub start_game {
775 status "logging in...";
776
777 $LOGIN_BUTTON->set_text ("Logout");
778 $SETUP_DIALOG->hide;
779
780 my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327";
781
782 $MAP = new DC::Map;
783
784 # hack to make SURE we find the IP address all right
785 # can be removed once AnyEvent::DNS is proven stable.
786 if ($host eq "gameserver.deliantra.net") {
787 AnyEvent::DNS::a "dnstest.deliantra.net", sub {
788 if ($_[0] ne "80.101.114.108") { # Perl
789 status "dns failure, using hardcoded address";
790 $host = "129.13.162.95";
791 }
792
793 dc_connect $host, $port;
794 };
770 } else { 795 } else {
771 warn $@; 796 dc_connect $host, $port;
772 status "unable to connect";
773 stop_game();
774 } 797 }
775} 798}
776 799
777sub stop_game { 800sub stop_game {
778 $LOGIN_BUTTON->set_text ("Login / Register"); 801 $LOGIN_BUTTON->set_text ("Login / Register");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines