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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines