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.35 by root, Sun Mar 30 06:05:53 2008 UTC vs.
Revision 1.51 by root, Thu Jul 17 15:23:43 2008 UTC

97use List::Util qw(max min); 97use List::Util qw(max min);
98 98
99use Deliantra; 99use Deliantra;
100use Deliantra::Protocol::Constants; 100use Deliantra::Protocol::Constants;
101 101
102use AnyEvent::DNS;
103use AnyEvent::Socket ();
104
102use Compress::LZF; 105use Compress::LZF;
103 106
104use DC; 107use DC;
108BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } }
105use DC::OpenGL (); 109use DC::OpenGL ();
106use DC::Protocol; 110use DC::Protocol;
107use DC::DB; 111use DC::DB;
108use DC::UI; 112use DC::UI;
109use DC::UI::Canvas; 113use DC::UI::Canvas;
664 # right: accept 668 # right: accept
665 $table->add_at (4, 0, new DC::UI::Button 669 $table->add_at (4, 0, new DC::UI::Button
666 text => "Accept", 670 text => "Accept",
667 on_activate => sub { 671 on_activate => sub {
668 $conn->send ("reply n"); 672 $conn->send ("reply n");
669 $STATS_PAGE->hide;
670 destroy_query_dialog $conn; 673 destroy_query_dialog $conn;
671 0 674 0
672 }, 675 },
673 ); 676 );
674 677
726 729
727 $vbox->add (@dialog); 730 $vbox->add (@dialog);
728 $dialog->show; 731 $dialog->show;
729} 732}
730 733
731sub start_game { 734sub dc_connect {
732 status "logging in..."; 735 my ($host, $port) = @_;
733
734 $LOGIN_BUTTON->set_text ("Logout");
735 $SETUP_DIALOG->hide;
736 736
737 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 737 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
738 738
739 my ($host, $port) = split /:/, $PROFILE->{host};
740
741 $MAP = new DC::Map;
742
743 $CONN = eval { 739 $CONN =
744 new DC::Protocol 740 new DC::Protocol
745 host => $host, 741 host => $host,
746 port => $port || 13327, 742 port => $port,
747 user => $PROFILE->{user}, 743 user => $PROFILE->{user},
748 pass => $PROFILE->{password}, 744 pass => $PROFILE->{password},
749 mapw => $mapsize, 745 mapw => $mapsize,
750 maph => $mapsize, 746 maph => $mapsize,
751 747
758 query => \&server_query, 754 query => \&server_query,
759 755
760 setup_req => { 756 setup_req => {
761 smoothing => $CFG->{map_smoothing}*1, 757 smoothing => $CFG->{map_smoothing}*1,
762 }, 758 },
763 };
764 759
765 if ($CONN) { 760 on_connect => sub {
761 if ($_[0]) {
766 DC::lowdelay fileno $CONN->{fh}; 762 DC::lowdelay fileno $CONN->{fh};
767 763
768 status "login successful"; 764 status "login successful";
765 } else {
766 undef $CONN;
767 status "unable to connect: $!";
768 stop_game();
769 }
770 },
771 ;
772}
773
774sub start_game {
775 status "logging in...";
776
777 $LOGIN_BUTTON->set_text ("Logout");
778 $SETUP_DIALOG->hide;
779
780 my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327";
781
782 $MAP = new DC::Map;
783
784 # hack to make SURE we find the IP address all right
785 # can be removed once AnyEvent::DNS is proven stable.
786 if ($host eq "gameserver.deliantra.net") {
787 AnyEvent::DNS::a "dnstest.deliantra.net", sub {
788 if ($_[0] ne "80.101.114.108") { # Perl
789 status "dns failure, using hardcoded address";
790 $host = "129.13.162.95";
791 }
792
793 dc_connect $host, $port;
794 };
769 } else { 795 } else {
770 warn $@; 796 dc_connect $host, $port;
771 status "unable to connect";
772 stop_game();
773 } 797 }
774} 798}
775 799
776sub stop_game { 800sub stop_game {
777 $LOGIN_BUTTON->set_text ("Login / Register"); 801 $LOGIN_BUTTON->set_text ("Login / Register");
1621 $CFG->{show_tips} = $value; 1645 $CFG->{show_tips} = $value;
1622 0 1646 0
1623 } 1647 }
1624 ); 1648 );
1625 1649
1626 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Messages Window Size"); 1650 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size");
1627 $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry 1651 $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry
1628 text => $CFG->{logview_max_par}, 1652 text => $CFG->{logview_max_par},
1629 tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " 1653 tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server "
1630 . "sends more messages than this number, older messages get removed to save memory and " 1654 . "sends more messages than this number, older messages get removed to save memory and "
1631 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", 1655 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.",
1632 on_changed => sub { 1656 on_changed => sub {
1633 my ($self, $value) = @_; 1657 my ($self, $value) = @_;
1634 $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); 1658 $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1);
1743 1767
1744 $r 1768 $r
1745} 1769}
1746 1770
1747my %SORT_ORDER = ( 1771my %SORT_ORDER = (
1748 type => undef, 1772 type => sub {
1773 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_
1774 },
1749 mtime => sub { 1775 mtime => sub {
1750 my $NOW = time; 1776 my $NOW = time;
1751 sort { 1777 sort {
1752 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; 1778 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
1753 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; 1779 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
2242 force_h => $::HEIGHT * 0.6, 2268 force_h => $::HEIGHT * 0.6,
2243 has_close_button => 1, 2269 has_close_button => 1,
2244 ; 2270 ;
2245 2271
2246 $METASERVER = metaserver_dialog; 2272 $METASERVER = metaserver_dialog;
2247 $MESSAGE_WINDOW = new DC::UI::Dockbar (name => 'message_window', title => 'Messages'); 2273 # the name is changed to not conflict with the older name as users could have hidden it
2274 $MESSAGE_WINDOW = new DC::UI::Dockbar
2275 name => "message_window2",
2276 title => 'Messages',
2277 force_w => $::WIDTH * 0.6,
2278 force_h => $::HEIGHT * 0.25,
2279 ;
2280
2248 $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; 2281 $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW;
2249 2282
2250 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1, 2283 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1,
2251 filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); 2284 filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1);
2252 2285
2253 $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, 2286 $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup,
2254 "Configure the server to play on, your username and password."); 2287 "Configure the server to play on, your username and password.");
2255 $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, 2288 $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup,
2273 $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 2306 $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
2274 2307
2275 $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 2308 $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
2276 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 2309 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
2277 2310
2278 $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, 2311# $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW,
2279 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); 2312# tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
2280 2313
2281 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 2314 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
2282 2315
2283 $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, 2316 $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window,
2284 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); 2317 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats.");
2294 }, 2327 },
2295 ); 2328 );
2296 2329
2297 $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, 2330 $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
2298 tooltip => "View Documentation"); 2331 tooltip => "View Documentation");
2299
2300 2332
2301 $BUTTONBAR->add (new DC::UI::Button 2333 $BUTTONBAR->add (new DC::UI::Button
2302 text => "Quit", 2334 text => "Quit",
2303 tooltip => "Terminates the program", 2335 tooltip => "Terminates the program",
2304 on_activate => sub { 2336 on_activate => sub {
2475 pickup => 0, 2507 pickup => 0,
2476 inv_sort => "mtime", 2508 inv_sort => "mtime",
2477 default => "profile", # default profile 2509 default => "profile", # default profile
2478 show_tips => 1, 2510 show_tips => 1,
2479 logview_max_par => 1000, 2511 logview_max_par => 1000,
2512 shift_fire_stop => 0,
2480 ); 2513 );
2481 2514
2482 while (my ($k, $v) = each %DEF_CFG) { 2515 while (my ($k, $v) = each %DEF_CFG) {
2483 $CFG->{$k} = $v unless exists $CFG->{$k}; 2516 $CFG->{$k} = $v unless exists $CFG->{$k};
2484 } 2517 }
2552our $STARTUP_CANCEL = EV::idle sub { 2585our $STARTUP_CANCEL = EV::idle sub {
2553 undef $::STARTUP_CANCEL; 2586 undef $::STARTUP_CANCEL;
2554 $startup_done->(); 2587 $startup_done->();
2555}; 2588};
2556 2589
2590delete $SIG{__DIE__};
2557EV::loop; 2591EV::loop;
2558 2592
2559#video_shutdown; 2593#video_shutdown;
2560#audio_shutdown; 2594#audio_shutdown;
2561DC::OpenGL::quit; 2595DC::OpenGL::quit;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines