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.61 by root, Fri Aug 22 18:20:17 2008 UTC vs.
Revision 1.66 by root, Mon Sep 1 09:12:08 2008 UTC

104use List::Util qw(max min); 104use List::Util qw(max min);
105 105
106use Deliantra; 106use Deliantra;
107use Deliantra::Protocol::Constants; 107use Deliantra::Protocol::Constants;
108 108
109use AnyEvent::Util ();
109use AnyEvent::DNS; 110use AnyEvent::DNS;
110use AnyEvent::Socket (); 111use AnyEvent::Socket ();
111 112
112use Compress::LZF; 113use Compress::LZF;
114use JSON::XS;
113 115
114use DC; 116use DC;
115BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } } 117
118#############################################################################
119
120our $CONN;
121
122# write a crash message blockingly to the socket, if possible
123# this is a bit too complicated for my tastes, but it was easy.
124sub crash($;$) {
125 my ($msg, $backtrace) = @_;
126
127 return unless $CONN;
128
129 my $fh = $CONN->{fh}
130 or return;
131
132 my $buf = delete $CONN->{wbuf};
133
134 $buf .= pack "n/a*", "exti " . JSON::XS::encode_json [clientlog => undef, substr $msg, 0, 8000];
135
136 AnyEvent::Util::fh_nonblocking $fh, 0;
137
138 syswrite $fh, $buf;
139 AnyEvent::Util::fh_nonblocking $fh, 1;
140
141 $msg =~ s/\s+$//;
142
143 # backtrace as second step, in case it crashes, too
144 crash (Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated")
145 if $backtrace;
146}
147
148#############################################################################
149
150BEGIN {
151 $SIG{__DIE__} = sub {
152 return if $^S;
153 crash ("CRASH/DIE: $_[0]" => 1);
154 DC::fatal Carp::longmess "$_[0]";
155 }
156}
157
116use DC::OpenGL (); 158use DC::OpenGL ();
117use DC::Protocol; 159use DC::Protocol;
118use DC::DB; 160use DC::DB;
119use DC::UI; 161use DC::UI;
120use DC::UI::Canvas; 162use DC::UI::Canvas;
121use DC::UI::Inventory; 163use DC::UI::Inventory;
122use DC::UI::SpellList; 164use DC::UI::SpellList;
123use DC::UI::Dockable; 165use DC::UI::Dockable;
124use DC::UI::Dockbar; 166use DC::UI::Dockbar;
125use DC::UI::MessageWindow;
126use DC::UI::ChatView; 167use DC::UI::ChatView;
127use DC::MessageDistributor; 168use DC::MessageDistributor;
128use DC::Pod; 169use DC::Pod;
129use DC::MapWidget; 170use DC::MapWidget;
130use DC::Macro; 171use DC::Macro;
131 172
132$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 173$SIG{QUIT} = sub { Carp::cluck "QUIT" };
133$SIG{PIPE} = 'IGNORE'; 174$SIG{PIPE} = 'IGNORE';
134 175
135$EV::DIED = sub { 176$EV::DIED = sub {
177 crash ("CRASH/EV::DIED: $@" => 1);
136 DC::fatal Carp::longmess $@; 178 DC::fatal Carp::longmess $@;
137}; 179};
138 180
139my $MAX_FPS = 60; 181my $MAX_FPS = 60;
140 182
142 184
143our $LAST_REFRESH; 185our $LAST_REFRESH;
144our $NOW; 186our $NOW;
145 187
146our $CFG; 188our $CFG;
147our $CONN;
148our $PROFILE; # current profile 189our $PROFILE; # current profile
149our $FAST; # fast, low-quality mode, possibly useful for software-rendering 190our $FAST; # fast, low-quality mode, possibly useful for software-rendering
150 191
151our $WANT_REFRESH; 192our $WANT_REFRESH;
152 193
807 dc_connect $host, $port; 848 dc_connect $host, $port;
808 } 849 }
809} 850}
810 851
811sub stop_game { 852sub stop_game {
853 crash "stop_game";
854
812 $LOGIN_BUTTON->set_text ("Login / Register"); 855 $LOGIN_BUTTON->set_text ("Login / Register");
813 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); 856 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);
814 $SETUP_DIALOG->show; 857 $SETUP_DIALOG->show;
815 $PL_WINDOW->hide; 858 $PL_WINDOW->hide;
816 $SPELL_LIST->clear_spells; 859 $SPELL_LIST->clear_spells;
836 879
837 my $row = 0; 880 my $row = 0;
838 881
839 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info"); 882 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info");
840 $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version, 883 $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version,
841 can_events => 1, 884 can_events => 1,
842 tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>"); 885 tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>");
843 886
844 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Caveats"); 887 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Caveats");
845 $table->add_at (1, $row++, $CAVEAT_LABEL = new DC::UI::Label fontsize => 0.8, 888 $table->add_at (1, $row++, $CAVEAT_LABEL = new DC::UI::Label fontsize => 0.8,
846 can_events => 1, 889 can_events => 1,
847 tooltip => "This field shows any known issues with your config or driver, such as " 890 tooltip => "This field shows any known issues with your config or driver, such as "
910 953
911 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); 954 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures");
912 $table->add_at (1, $row++, new DC::UI::CheckBox 955 $table->add_at (1, $row++, new DC::UI::CheckBox
913 state => $CFG->{texture_compression}, 956 state => $CFG->{texture_compression},
914 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " 957 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but "
915 . "will save a lot of memory and increase performance. The compression algorithm " 958 . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). "
916 . "can differ form card to card, so your mileage may vary. This setting is ignored in " 959 . "The compression algorithm can differ form card to card, so your mileage may vary. This setting is ignored in "
917 . "forced OpenGL 1.1 mode.", 960 . "forced OpenGL 1.1 mode and when using the Apple renderer.",
918 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } 961 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 }
919 ); 962 );
920 963
921 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); 964 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly");
922 $table->add_at (1, $row++, new DC::UI::CheckBox 965 $table->add_at (1, $row++, new DC::UI::CheckBox
1597 }, 1640 },
1598 ); 1641 );
1599 1642
1600 $vbox->add (new DC::UI::FancyFrame 1643 $vbox->add (new DC::UI::FancyFrame
1601 label => "How to Play", 1644 label => "How to Play",
1602 min_h => 200, 1645 min_h => 240,
1603 child => (new DC::UI::Label valign => 0, ellipsise => 0, 1646 child => (new DC::UI::Label valign => 0, ellipsise => 0,
1604 markup => 1647 markup =>
1605 "First select a suitable video resolution in the Graphics tab, above.\n\n" 1648 "First select a suitable video resolution in the <b>Graphics</b> tab, above.\n\n"
1606 . "Then register a new account (or use an existibg one if you have one). " 1649 . "Then register a new account (or use an existing one if you have one). "
1607 . "To register an account, choose a username that hasn't been taken yet and " 1650 . "To register an account, choose a username that hasn't been taken yet (just guess) and "
1608 . "try to log-in. Follow the instructions in the Log tab in the message window.", 1651 . "try to log-in. Follow the instructions in the Log tab in the message window.",
1609 ), 1652 ),
1610 ); 1653 );
1611 1654
1612 $vbox 1655 $vbox
2133 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 2176 on_activate => sub { $QUIT_DIALOG->hide; 0 },
2134 ); 2177 );
2135 $hb->add (new DC::UI::Button 2178 $hb->add (new DC::UI::Button
2136 text => "Quit anyway", 2179 text => "Quit anyway",
2137 expand => 1, 2180 expand => 1,
2138 on_activate => sub { EV::unloop EV::UNLOOP_ALL }, 2181 on_activate => sub {
2182 crash "Quit anyway";
2183 EV::unloop EV::UNLOOP_ALL;
2184 },
2139 ); 2185 );
2140 } 2186 }
2141 2187
2142 $QUIT_DIALOG->show; 2188 $QUIT_DIALOG->show;
2143 $QUIT_DIALOG->grab_focus; 2189 $QUIT_DIALOG->grab_focus;
2481 delete $animate_object{$widget}; 2527 delete $animate_object{$widget};
2482} 2528}
2483 2529
2484%SDL_CB = ( 2530%SDL_CB = (
2485 DC::SDL_QUIT => sub { 2531 DC::SDL_QUIT => sub {
2532 crash "SDL_QUIT";
2486 EV::unloop EV::UNLOOP_ALL; 2533 EV::unloop EV::UNLOOP_ALL;
2487 }, 2534 },
2488 DC::SDL_VIDEORESIZE => sub { 2535 DC::SDL_VIDEORESIZE => sub {
2489 }, 2536 },
2490 DC::SDL_VIDEOEXPOSE => sub { 2537 DC::SDL_VIDEOEXPOSE => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines