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.72 by root, Tue Sep 2 17:15:39 2008 UTC

97 97
98# need to do it again because that pile of garbage called PAR nukes it before main 98# need to do it again because that pile of garbage called PAR nukes it before main
99unshift @INC, $ENV{PAR_TEMP} 99unshift @INC, $ENV{PAR_TEMP}
100 if %PAR::LibCache; 100 if %PAR::LibCache;
101 101
102use Time::HiRes 'time';
103use EV; 102use EV;
103BEGIN { *time = \&EV::time }
104
104use List::Util qw(max min); 105use List::Util qw(max min);
105 106
106use Deliantra; 107use Deliantra;
107use Deliantra::Protocol::Constants; 108use Deliantra::Protocol::Constants;
108 109
110use AnyEvent::Util ();
109use AnyEvent::DNS; 111use AnyEvent::DNS;
110use AnyEvent::Socket (); 112use AnyEvent::Socket ();
111 113
112use Compress::LZF; 114use Compress::LZF;
115use JSON::XS;
113 116
114use DC; 117use DC;
115BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } } 118
119sub crash($;$) {
120 # nop during compiletime
121}
122
123BEGIN {
124 $SIG{__DIE__} = sub {
125 return if $^S;
126 crash "CRASH/DIE: $_[0]" => 1;
127 DC::fatal Carp::longmess "$_[0]";
128 }
129}
130
116use DC::OpenGL (); 131use DC::OpenGL ();
117use DC::Protocol; 132use DC::Protocol;
118use DC::DB; 133use DC::DB;
119use DC::UI; 134use DC::UI;
120use DC::UI::Canvas; 135use DC::UI::Canvas;
130 145
131$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 146$SIG{QUIT} = sub { Carp::cluck "QUIT" };
132$SIG{PIPE} = 'IGNORE'; 147$SIG{PIPE} = 'IGNORE';
133 148
134$EV::DIED = sub { 149$EV::DIED = sub {
150 crash "CRASH/EV::DIED: $@" => 1;
135 DC::fatal Carp::longmess $@; 151 DC::fatal Carp::longmess $@;
136}; 152};
137 153
138my $MAX_FPS = 60; 154my $MAX_FPS = 60;
139 155
141 157
142our $LAST_REFRESH; 158our $LAST_REFRESH;
143our $NOW; 159our $NOW;
144 160
145our $CFG; 161our $CFG;
146our $CONN;
147our $PROFILE; # current profile 162our $PROFILE; # current profile
148our $FAST; # fast, low-quality mode, possibly useful for software-rendering 163our $FAST; # fast, low-quality mode, possibly useful for software-rendering
149 164
150our $WANT_REFRESH; 165our $WANT_REFRESH;
151 166
159our $FULLSCREEN; 174our $FULLSCREEN;
160our $FONTSIZE; 175our $FONTSIZE;
161 176
162our $FONT_PROP; 177our $FONT_PROP;
163our $FONT_FIXED; 178our $FONT_FIXED;
179
180our $CONN;
164 181
165our $MAP; 182our $MAP;
166our $MAPMAP; 183our $MAPMAP;
167our $MAPWIDGET; 184our $MAPWIDGET;
168our $COMPLETER; 185our $COMPLETER;
210our $DEBUG_STATUS; 227our $DEBUG_STATUS;
211 228
212our $INV; 229our $INV;
213our $INVR; 230our $INVR;
214our $INVR_HB; 231our $INVR_HB;
232
233#############################################################################
234
235# write a crash message blockingly to the socket, if possible
236# this is a bit too complicated for my tastes, but it was easy.
237*crash = sub($;$) {
238 my ($msg, $backtrace) = @_;
239
240 return unless $CONN;
241
242 my $fh = $CONN->{fh}
243 or return;
244
245 my $buf = delete $CONN->{wbuf};
246
247 $buf .= pack "n/a*", "exti " . JSON::XS::encode_json [clientlog => undef, substr $msg, 0, 8000];
248
249 AnyEvent::Util::fh_nonblocking $fh, 0;
250 syswrite $fh, $buf;
251 AnyEvent::Util::fh_nonblocking $fh, 1;
252
253 $msg =~ s/\s+$//;
254
255 # backtrace as second step, in case it crashes, too
256 crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated"
257 if $backtrace;
258};
215 259
216############################################################################# 260#############################################################################
217 261
218sub status { 262sub status {
219 $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 263 $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
806 dc_connect $host, $port; 850 dc_connect $host, $port;
807 } 851 }
808} 852}
809 853
810sub stop_game { 854sub stop_game {
855 crash "stop_game";
856
811 $LOGIN_BUTTON->set_text ("Login / Register"); 857 $LOGIN_BUTTON->set_text ("Login / Register");
812 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); 858 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);
813 $SETUP_DIALOG->show; 859 $SETUP_DIALOG->show;
814 $PL_WINDOW->hide; 860 $PL_WINDOW->hide;
815 $SPELL_LIST->clear_spells; 861 $SPELL_LIST->clear_spells;
2132 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 2178 on_activate => sub { $QUIT_DIALOG->hide; 0 },
2133 ); 2179 );
2134 $hb->add (new DC::UI::Button 2180 $hb->add (new DC::UI::Button
2135 text => "Quit anyway", 2181 text => "Quit anyway",
2136 expand => 1, 2182 expand => 1,
2137 on_activate => sub { EV::unloop EV::UNLOOP_ALL }, 2183 on_activate => sub {
2184 crash "Quit anyway";
2185 EV::unloop EV::UNLOOP_ALL;
2186 },
2138 ); 2187 );
2139 } 2188 }
2140 2189
2141 $QUIT_DIALOG->show; 2190 $QUIT_DIALOG->show;
2142 $QUIT_DIALOG->grab_focus; 2191 $QUIT_DIALOG->grab_focus;
2213 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; 2262 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES;
2214 2263
2215 if (!defined $CFG->{sdl_mode} or $CFG->{sdl_mode} > $#SDL_MODES) { 2264 if (!defined $CFG->{sdl_mode} or $CFG->{sdl_mode} > $#SDL_MODES) {
2216 $CFG->{sdl_mode} = 0; # lowest resolution by default 2265 $CFG->{sdl_mode} = 0; # lowest resolution by default
2217 2266
2218 # now choose biggets mode <= 1024x768 2267 # now choose biggest mode <= 1024x768
2219 for (0 .. $#SDL_MODES) { 2268 for (0 .. $#SDL_MODES) {
2220 if ($SDL_MODES[$_][0] * $SDL_MODES[$_][1] <= 1024 * 768) { 2269 if ($SDL_MODES[$_][0] * $SDL_MODES[$_][1] <= 1024 * 768) {
2221 $CFG->{sdl_mode} = $_; 2270 $CFG->{sdl_mode} = $_;
2222 } 2271 }
2223 } 2272 }
2415 $BUTTONBAR->show; 2464 $BUTTONBAR->show;
2416 $SETUP_DIALOG->show; 2465 $SETUP_DIALOG->show;
2417 $MESSAGE_WINDOW->show; 2466 $MESSAGE_WINDOW->show;
2418 } 2467 }
2419 2468
2420 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, $#SDL_MODES, 1, 1]); 2469 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]);
2421 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); 2470 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode});
2422 2471
2423 $CAVEAT_LABEL->set_text ("None :)"); 2472 $CAVEAT_LABEL->set_text ("None :)");
2424 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") 2473 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)")
2425 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; 2474 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL;
2480 delete $animate_object{$widget}; 2529 delete $animate_object{$widget};
2481} 2530}
2482 2531
2483%SDL_CB = ( 2532%SDL_CB = (
2484 DC::SDL_QUIT => sub { 2533 DC::SDL_QUIT => sub {
2534 crash "SDL_QUIT";
2485 EV::unloop EV::UNLOOP_ALL; 2535 EV::unloop EV::UNLOOP_ALL;
2486 }, 2536 },
2487 DC::SDL_VIDEORESIZE => sub { 2537 DC::SDL_VIDEORESIZE => sub {
2488 }, 2538 },
2489 DC::SDL_VIDEOEXPOSE => sub { 2539 DC::SDL_VIDEOEXPOSE => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines