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.47 by root, Mon Jul 7 05:02:03 2008 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3{
4package Deliantra::Client; # work around CPAN breakage
5}
2 6
3if ($ENV{DELIANTRA_CORO_DEBUG}) { 7if ($ENV{DELIANTRA_CORO_DEBUG}) {
4 eval ' 8 eval '
5 use Coro; 9 use Coro;
6 use Coro::EV; 10 use Coro::EV;
97use List::Util qw(max min); 101use List::Util qw(max min);
98 102
99use Deliantra; 103use Deliantra;
100use Deliantra::Protocol::Constants; 104use Deliantra::Protocol::Constants;
101 105
106use AnyEvent::DNS;
107
102use Compress::LZF; 108use Compress::LZF;
103 109
110use DC;
104use DC; BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } 111BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } }
105use DC::OpenGL (); 112use DC::OpenGL ();
106use DC::Protocol; 113use DC::Protocol;
107use DC::DB; 114use DC::DB;
108use DC::UI; 115use DC::UI;
109use DC::UI::Canvas; 116use DC::UI::Canvas;
725 732
726 $vbox->add (@dialog); 733 $vbox->add (@dialog);
727 $dialog->show; 734 $dialog->show;
728} 735}
729 736
730sub start_game { 737sub dc_connect {
731 status "logging in..."; 738 my ($host, $port) = @_;
732
733 $LOGIN_BUTTON->set_text ("Logout");
734 $SETUP_DIALOG->hide;
735 739
736 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 740 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
737 741
738 my ($host, $port) = split /:/, $PROFILE->{host};
739
740 $MAP = new DC::Map;
741
742 $CONN = eval { 742 $CONN =
743 new DC::Protocol 743 new DC::Protocol
744 host => $host, 744 host => $host,
745 port => $port || 13327, 745 port => $port || 13327,
746 user => $PROFILE->{user}, 746 user => $PROFILE->{user},
747 pass => $PROFILE->{password}, 747 pass => $PROFILE->{password},
757 query => \&server_query, 757 query => \&server_query,
758 758
759 setup_req => { 759 setup_req => {
760 smoothing => $CFG->{map_smoothing}*1, 760 smoothing => $CFG->{map_smoothing}*1,
761 }, 761 },
762 };
763 762
764 if ($CONN) { 763 on_connect => sub {
764 if ($_[0]) {
765 DC::lowdelay fileno $CONN->{fh}; 765 DC::lowdelay fileno $CONN->{fh};
766 766
767 status "login successful"; 767 status "login successful";
768 } else {
769 undef $CONN;
770 status "unable to connect: $!";
771 stop_game();
772 }
773 },
774 ;
775}
776
777sub start_game {
778 status "logging in...";
779
780 $LOGIN_BUTTON->set_text ("Logout");
781 $SETUP_DIALOG->hide;
782
783 my ($host, $port) = split /:/, $PROFILE->{host};
784
785 $MAP = new DC::Map;
786
787 # hack to make SURE we find the IP address all right
788 # can be removed once AnyEvent::DNS is proven stable.
789 if ($host eq "gameserver.deliantra.net") {
790 AnyEvent::DNS::a "dnstest.deliantra.net", sub {
791 if ($_[0] ne "80.101.114.108") { # Perl
792 status "dns failure, using hardcoded address";
793 $host = "129.13.162.95";
794 }
795
796 dc_connect $host, $port;
797 };
768 } else { 798 } else {
769 warn $@; 799 dc_connect $host, $port;
770 status "unable to connect";
771 stop_game();
772 } 800 }
773} 801}
774 802
775sub stop_game { 803sub stop_game {
776 $LOGIN_BUTTON->set_text ("Login / Register"); 804 $LOGIN_BUTTON->set_text ("Login / Register");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines