--- deliantra/Deliantra-Client/bin/deliantra 2008/05/26 03:35:42 1.45 +++ deliantra/Deliantra-Client/bin/deliantra 2008/07/07 08:02:17 1.48 @@ -1,5 +1,10 @@ #!/opt/bin/perl +{ +package Deliantra::Client; # work around CPAN breakage +package App::Deliantra; # try to reserve namespace +} + if ($ENV{DELIANTRA_CORO_DEBUG}) { eval ' use Coro; @@ -99,6 +104,8 @@ use Deliantra; use Deliantra::Protocol::Constants; +use AnyEvent::DNS; + use Compress::LZF; use DC; @@ -728,18 +735,11 @@ $dialog->show; } -sub start_game { - status "logging in..."; - - $LOGIN_BUTTON->set_text ("Logout"); - $SETUP_DIALOG->hide; +sub dc_connect { + my ($host, $port) = @_; my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; - my ($host, $port) = split /:/, $PROFILE->{host}; - - $MAP = new DC::Map; - $CONN = new DC::Protocol host => $host, @@ -775,6 +775,32 @@ ; } +sub start_game { + status "logging in..."; + + $LOGIN_BUTTON->set_text ("Logout"); + $SETUP_DIALOG->hide; + + my ($host, $port) = split /:/, $PROFILE->{host}; + + $MAP = new DC::Map; + + # hack to make SURE we find the IP address all right + # can be removed once AnyEvent::DNS is proven stable. + if ($host eq "gameserver.deliantra.net") { + AnyEvent::DNS::a "dnstest.deliantra.net", sub { + if ($_[0] ne "80.101.114.108") { # Perl + status "dns failure, using hardcoded address"; + $host = "129.13.162.95"; + } + + dc_connect $host, $port; + }; + } else { + dc_connect $host, $port; + } +} + sub stop_game { $LOGIN_BUTTON->set_text ("Login / Register"); $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);