--- deliantra/Deliantra-Client/bin/deliantra 2008/03/25 21:11:52 1.33 +++ deliantra/Deliantra-Client/bin/deliantra 2008/07/07 12:56:07 1.49 @@ -99,9 +99,12 @@ use Deliantra; use Deliantra::Protocol::Constants; +use AnyEvent::DNS; + use Compress::LZF; use DC; +BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } use DC::OpenGL (); use DC::Protocol; use DC::DB; @@ -666,7 +669,6 @@ text => "Accept", on_activate => sub { $conn->send ("reply n"); - $STATS_PAGE->hide; destroy_query_dialog $conn; 0 }, @@ -728,19 +730,12 @@ $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 = eval { + $CONN = new DC::Protocol host => $host, port => $port || 13327, @@ -760,16 +755,44 @@ setup_req => { smoothing => $CFG->{map_smoothing}*1, }, - }; - if ($CONN) { - DC::lowdelay fileno $CONN->{fh}; + on_connect => sub { + if ($_[0]) { + DC::lowdelay fileno $CONN->{fh}; + + status "login successful"; + } else { + undef $CONN; + status "unable to connect: $!"; + stop_game(); + } + }, + ; +} + +sub start_game { + status "logging in..."; - status "login successful"; + $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 { - warn $@; - status "unable to connect"; - stop_game(); + dc_connect $host, $port; } } @@ -1623,10 +1646,10 @@ } ); - $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Messages Window Size"); + $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry text => $CFG->{logview_max_par}, - tooltip => "This is maximum number of messages remembered in the Messages window. If the server " + tooltip => "This is maximum number of messages remembered in the Message window. If the server " . "sends more messages than this number, older messages get removed to save memory and " . "computing time. A value of 0 disables this feature, but that is not recommended.", on_changed => sub { @@ -1745,7 +1768,9 @@ } my %SORT_ORDER = ( - type => undef, + type => sub { + sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ + }, mtime => sub { my $NOW = time; sort { @@ -2244,10 +2269,17 @@ ; $METASERVER = metaserver_dialog; - $MESSAGE_WINDOW = new DC::UI::Dockbar (name => 'message_window', title => 'Messages'); + # the name is changed to not conflict with the older name as users could have hidden it + $MESSAGE_WINDOW = new DC::UI::Dockbar + name => "message_window2", + title => 'Messages', + force_w => $::WIDTH * 0.6, + force_h => $::HEIGHT * 0.25, + ; + $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; - $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1, + $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, @@ -2275,8 +2307,8 @@ $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, tooltip => "Toggles a dialog where you can configure all aspects of this client."); - $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, - tooltip => "Toggles the server message log, where the client collects all messages from the server."); +# $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, +# tooltip => "Toggles the server message log, where the client collects all messages from the server."); make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D @@ -2288,7 +2320,7 @@ tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", on_activate => sub { $::CFG->{layout} = DC::UI::get_layout; - DC::write_cfg "$Deliantra::VARDIR/client.cf"; + DC::write_cfg; status "Configuration Saved"; 0 }, @@ -2297,7 +2329,6 @@ $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, tooltip => "View Documentation"); - $BUTTONBAR->add (new DC::UI::Button text => "Quit", tooltip => "Terminates the program", @@ -2423,6 +2454,8 @@ }; { + DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; + if (-e "$Deliantra::VARDIR/client.cf") { DC::read_cfg "$Deliantra::VARDIR/client.cf"; } else { @@ -2432,6 +2465,14 @@ } DC::DB::Server::run; + + if ($CFG->{db_schema} < 1) { + warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; + DC::DB::nuke_db; + $CFG->{db_schema} = 1; + DC::write_cfg; + } + DC::DB::open_db; DC::UI::set_layout ($::CFG->{layout}); @@ -2467,6 +2508,7 @@ default => "profile", # default profile show_tips => 1, logview_max_par => 1000, + shift_fire_stop => 0, ); while (my ($k, $v) = each %DEF_CFG) { @@ -2544,6 +2586,7 @@ $startup_done->(); }; +delete $SIG{__DIE__}; EV::loop; #video_shutdown;