… | |
… | |
88 | use Deliantra::Protocol::Constants; |
88 | use Deliantra::Protocol::Constants; |
89 | |
89 | |
90 | use AnyEvent::Util (); |
90 | use AnyEvent::Util (); |
91 | use AnyEvent::DNS; |
91 | use AnyEvent::DNS; |
92 | use AnyEvent::Socket (); |
92 | use AnyEvent::Socket (); |
|
|
93 | use AnyEvent::DNS (); |
93 | |
94 | |
94 | use Compress::LZF; |
95 | use Compress::LZF; |
95 | use JSON::XS; |
96 | use JSON::XS; |
96 | |
97 | |
97 | use DC; |
98 | use DC; |
… | |
… | |
125 | |
126 | |
126 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
127 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
127 | $SIG{PIPE} = 'IGNORE'; |
128 | $SIG{PIPE} = 'IGNORE'; |
128 | |
129 | |
129 | $EV::DIED = sub { |
130 | $EV::DIED = sub { |
130 | crash "CRASH/EV::DIED: $@" => 1; |
131 | crash "CRASH/EV::DIED: $@" => 0; |
131 | DC::fatal Carp::longmess $@; |
132 | DC::fatal Carp::longmess $@; |
132 | }; |
133 | }; |
133 | |
134 | |
134 | my $MAX_FPS = 60; |
135 | my $MAX_FPS = 60; |
135 | |
136 | |
… | |
… | |
215 | # write a crash message blockingly to the socket, if possible |
216 | # write a crash message blockingly to the socket, if possible |
216 | # this is a bit too complicated for my tastes, but it was easy. |
217 | # this is a bit too complicated for my tastes, but it was easy. |
217 | *crash = sub($;$) { |
218 | *crash = sub($;$) { |
218 | my ($msg, $backtrace) = @_; |
219 | my ($msg, $backtrace) = @_; |
219 | |
220 | |
|
|
221 | warn $msg; |
|
|
222 | |
220 | return unless $CONN; |
223 | return unless $CONN; |
221 | |
224 | |
222 | my $fh = $CONN->{fh} |
225 | my $fh = $CONN->{fh} |
223 | or return; |
226 | or return; |
224 | |
227 | |
… | |
… | |
234 | |
237 | |
235 | # backtrace as second step, in case it crashes, too |
238 | # backtrace as second step, in case it crashes, too |
236 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
239 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
237 | if $backtrace; |
240 | if $backtrace; |
238 | }; |
241 | }; |
|
|
242 | |
|
|
243 | sub clienterror($;$) { |
|
|
244 | my ($msg, $backtrace) = @_; |
|
|
245 | |
|
|
246 | warn $msg; |
|
|
247 | |
|
|
248 | return unless $CONN; |
|
|
249 | |
|
|
250 | $CONN->send_exti_msg (clientlog => $msg); |
|
|
251 | $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; |
|
|
252 | } |
239 | |
253 | |
240 | ############################################################################# |
254 | ############################################################################# |
241 | |
255 | |
242 | sub status { |
256 | sub status { |
243 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
257 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
… | |
… | |
398 | my $rwops = $meta->{path} |
412 | my $rwops = $meta->{path} |
399 | ? new_from_file DC::RW $meta->{path} |
413 | ? new_from_file DC::RW $meta->{path} |
400 | : new DC::RW $$MUSIC_PLAYING_DATA; |
414 | : new DC::RW $$MUSIC_PLAYING_DATA; |
401 | |
415 | |
402 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
416 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
403 | or Carp::confess "music face $meta->{face} unloadable: " . DC::Mix_GetError; |
417 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
404 | |
418 | |
405 | my $NOW = time; |
419 | my $NOW = time; |
406 | |
420 | |
407 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
421 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
408 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
422 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
… | |
… | |
2586 | $SIG{INT} = $SIG{TERM} = sub { |
2600 | $SIG{INT} = $SIG{TERM} = sub { |
2587 | EV::unloop; |
2601 | EV::unloop; |
2588 | #d# TODO calling exit here hangs the process in some futex |
2602 | #d# TODO calling exit here hangs the process in some futex |
2589 | }; |
2603 | }; |
2590 | |
2604 | |
|
|
2605 | # initialise the resolver now, as vista forces us back to the desktop |
|
|
2606 | # when doing this. |
|
|
2607 | AnyEvent::DNS::resolver; |
|
|
2608 | |
2591 | # due to mac os x + sdl combined briandamage, we need this contortion |
2609 | # due to mac os x + sdl combined braindamage, we need this contortion |
2592 | sub main { |
2610 | sub main { |
2593 | { |
2611 | { |
2594 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2612 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2595 | |
2613 | |
2596 | if (-e "$Deliantra::VARDIR/client.cf") { |
2614 | if (-e "$Deliantra::VARDIR/client.cf") { |