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.42 by elmex, Thu May 8 18:25:25 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 new DC::Protocol 740 new DC::Protocol
744 host => $host, 741 host => $host,
745 port => $port || 13327, 742 port => $port,
746 user => $PROFILE->{user}, 743 user => $PROFILE->{user},
747 pass => $PROFILE->{password}, 744 pass => $PROFILE->{password},
748 mapw => $mapsize, 745 mapw => $mapsize,
749 maph => $mapsize, 746 maph => $mapsize,
750 747
757 query => \&server_query, 754 query => \&server_query,
758 755
759 setup_req => { 756 setup_req => {
760 smoothing => $CFG->{map_smoothing}*1, 757 smoothing => $CFG->{map_smoothing}*1,
761 }, 758 },
762 };
763 759
764 if ($CONN) { 760 on_connect => sub {
761 if ($_[0]) {
765 DC::lowdelay fileno $CONN->{fh}; 762 DC::lowdelay fileno $CONN->{fh};
766 763
767 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 };
768 } else { 795 } else {
769 warn $@; 796 dc_connect $host, $port;
770 status "unable to connect";
771 stop_game();
772 } 797 }
773} 798}
774 799
775sub stop_game { 800sub stop_game {
776 $LOGIN_BUTTON->set_text ("Login / Register"); 801 $LOGIN_BUTTON->set_text ("Login / Register");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines