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.65 by root, Sat Aug 30 06:49:05 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;
130 172
131$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 173$SIG{QUIT} = sub { Carp::cluck "QUIT" };
132$SIG{PIPE} = 'IGNORE'; 174$SIG{PIPE} = 'IGNORE';
133 175
134$EV::DIED = sub { 176$EV::DIED = sub {
177 crash ("CRASH/EV::DIED: $@" => 1);
135 DC::fatal Carp::longmess $@; 178 DC::fatal Carp::longmess $@;
136}; 179};
137 180
138my $MAX_FPS = 60; 181my $MAX_FPS = 60;
139 182
141 184
142our $LAST_REFRESH; 185our $LAST_REFRESH;
143our $NOW; 186our $NOW;
144 187
145our $CFG; 188our $CFG;
146our $CONN;
147our $PROFILE; # current profile 189our $PROFILE; # current profile
148our $FAST; # fast, low-quality mode, possibly useful for software-rendering 190our $FAST; # fast, low-quality mode, possibly useful for software-rendering
149 191
150our $WANT_REFRESH; 192our $WANT_REFRESH;
151 193
806 dc_connect $host, $port; 848 dc_connect $host, $port;
807 } 849 }
808} 850}
809 851
810sub stop_game { 852sub stop_game {
853 crash "stop_game";
854
811 $LOGIN_BUTTON->set_text ("Login / Register"); 855 $LOGIN_BUTTON->set_text ("Login / Register");
812 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); 856 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);
813 $SETUP_DIALOG->show; 857 $SETUP_DIALOG->show;
814 $PL_WINDOW->hide; 858 $PL_WINDOW->hide;
815 $SPELL_LIST->clear_spells; 859 $SPELL_LIST->clear_spells;
2132 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 2176 on_activate => sub { $QUIT_DIALOG->hide; 0 },
2133 ); 2177 );
2134 $hb->add (new DC::UI::Button 2178 $hb->add (new DC::UI::Button
2135 text => "Quit anyway", 2179 text => "Quit anyway",
2136 expand => 1, 2180 expand => 1,
2137 on_activate => sub { EV::unloop EV::UNLOOP_ALL }, 2181 on_activate => sub {
2182 crash "Quit anyway";
2183 EV::unloop EV::UNLOOP_ALL;
2184 },
2138 ); 2185 );
2139 } 2186 }
2140 2187
2141 $QUIT_DIALOG->show; 2188 $QUIT_DIALOG->show;
2142 $QUIT_DIALOG->grab_focus; 2189 $QUIT_DIALOG->grab_focus;
2480 delete $animate_object{$widget}; 2527 delete $animate_object{$widget};
2481} 2528}
2482 2529
2483%SDL_CB = ( 2530%SDL_CB = (
2484 DC::SDL_QUIT => sub { 2531 DC::SDL_QUIT => sub {
2532 crash "SDL_QUIT";
2485 EV::unloop EV::UNLOOP_ALL; 2533 EV::unloop EV::UNLOOP_ALL;
2486 }, 2534 },
2487 DC::SDL_VIDEORESIZE => sub { 2535 DC::SDL_VIDEORESIZE => sub {
2488 }, 2536 },
2489 DC::SDL_VIDEOEXPOSE => sub { 2537 DC::SDL_VIDEOEXPOSE => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines