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.66 by root, Mon Sep 1 09:12:08 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
113use Compress::LZF; 114use Compress::LZF;
114use JSON::XS; 115use JSON::XS;
115 116
116use DC; 117use DC;
117 118
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($;$) { 119sub crash($;$) {
125 my ($msg, $backtrace) = @_; 120 # nop during compiletime
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} 121}
147
148#############################################################################
149 122
150BEGIN { 123BEGIN {
151 $SIG{__DIE__} = sub { 124 $SIG{__DIE__} = sub {
152 return if $^S; 125 return if $^S;
153 crash ("CRASH/DIE: $_[0]" => 1); 126 crash "CRASH/DIE: $_[0]" => 1;
154 DC::fatal Carp::longmess "$_[0]"; 127 DC::fatal Carp::longmess "$_[0]";
155 } 128 }
156} 129}
157 130
158use DC::OpenGL (); 131use DC::OpenGL ();
172 145
173$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 146$SIG{QUIT} = sub { Carp::cluck "QUIT" };
174$SIG{PIPE} = 'IGNORE'; 147$SIG{PIPE} = 'IGNORE';
175 148
176$EV::DIED = sub { 149$EV::DIED = sub {
177 crash ("CRASH/EV::DIED: $@" => 1); 150 crash "CRASH/EV::DIED: $@" => 1;
178 DC::fatal Carp::longmess $@; 151 DC::fatal Carp::longmess $@;
179}; 152};
180 153
181my $MAX_FPS = 60; 154my $MAX_FPS = 60;
182 155
201our $FULLSCREEN; 174our $FULLSCREEN;
202our $FONTSIZE; 175our $FONTSIZE;
203 176
204our $FONT_PROP; 177our $FONT_PROP;
205our $FONT_FIXED; 178our $FONT_FIXED;
179
180our $CONN;
206 181
207our $MAP; 182our $MAP;
208our $MAPMAP; 183our $MAPMAP;
209our $MAPWIDGET; 184our $MAPWIDGET;
210our $COMPLETER; 185our $COMPLETER;
252our $DEBUG_STATUS; 227our $DEBUG_STATUS;
253 228
254our $INV; 229our $INV;
255our $INVR; 230our $INVR;
256our $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};
257 259
258############################################################################# 260#############################################################################
259 261
260sub status { 262sub status {
261 $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]);
2260 @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;
2261 2263
2262 if (!defined $CFG->{sdl_mode} or $CFG->{sdl_mode} > $#SDL_MODES) { 2264 if (!defined $CFG->{sdl_mode} or $CFG->{sdl_mode} > $#SDL_MODES) {
2263 $CFG->{sdl_mode} = 0; # lowest resolution by default 2265 $CFG->{sdl_mode} = 0; # lowest resolution by default
2264 2266
2265 # now choose biggets mode <= 1024x768 2267 # now choose biggest mode <= 1024x768
2266 for (0 .. $#SDL_MODES) { 2268 for (0 .. $#SDL_MODES) {
2267 if ($SDL_MODES[$_][0] * $SDL_MODES[$_][1] <= 1024 * 768) { 2269 if ($SDL_MODES[$_][0] * $SDL_MODES[$_][1] <= 1024 * 768) {
2268 $CFG->{sdl_mode} = $_; 2270 $CFG->{sdl_mode} = $_;
2269 } 2271 }
2270 } 2272 }
2462 $BUTTONBAR->show; 2464 $BUTTONBAR->show;
2463 $SETUP_DIALOG->show; 2465 $SETUP_DIALOG->show;
2464 $MESSAGE_WINDOW->show; 2466 $MESSAGE_WINDOW->show;
2465 } 2467 }
2466 2468
2467 $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]);
2468 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); 2470 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode});
2469 2471
2470 $CAVEAT_LABEL->set_text ("None :)"); 2472 $CAVEAT_LABEL->set_text ("None :)");
2471 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") 2473 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)")
2472 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; 2474 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines