… | |
… | |
96 | use EV; |
96 | use EV; |
97 | use List::Util qw(max min); |
97 | use List::Util qw(max min); |
98 | |
98 | |
99 | use Deliantra; |
99 | use Deliantra; |
100 | use Deliantra::Protocol::Constants; |
100 | use Deliantra::Protocol::Constants; |
|
|
101 | |
|
|
102 | use AnyEvent::DNS; |
101 | |
103 | |
102 | use Compress::LZF; |
104 | use Compress::LZF; |
103 | |
105 | |
104 | use DC; |
106 | use DC; |
105 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } |
107 | BEGIN { $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 | |
731 | sub start_game { |
733 | sub 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 | |
|
|
773 | sub 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 | |
778 | sub stop_game { |
799 | sub 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); |