… | |
… | |
125 | |
125 | |
126 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
126 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
127 | $SIG{PIPE} = 'IGNORE'; |
127 | $SIG{PIPE} = 'IGNORE'; |
128 | |
128 | |
129 | $EV::DIED = sub { |
129 | $EV::DIED = sub { |
130 | crash "CRASH/EV::DIED: $@" => 1; |
130 | crash "CRASH/EV::DIED: $@" => 0; |
131 | DC::fatal Carp::longmess $@; |
131 | DC::fatal Carp::longmess $@; |
132 | }; |
132 | }; |
133 | |
133 | |
134 | my $MAX_FPS = 60; |
134 | my $MAX_FPS = 60; |
135 | |
135 | |
… | |
… | |
215 | # write a crash message blockingly to the socket, if possible |
215 | # write a crash message blockingly to the socket, if possible |
216 | # this is a bit too complicated for my tastes, but it was easy. |
216 | # this is a bit too complicated for my tastes, but it was easy. |
217 | *crash = sub($;$) { |
217 | *crash = sub($;$) { |
218 | my ($msg, $backtrace) = @_; |
218 | my ($msg, $backtrace) = @_; |
219 | |
219 | |
|
|
220 | warn $msg; |
|
|
221 | |
220 | return unless $CONN; |
222 | return unless $CONN; |
221 | |
223 | |
222 | my $fh = $CONN->{fh} |
224 | my $fh = $CONN->{fh} |
223 | or return; |
225 | or return; |
224 | |
226 | |
… | |
… | |
234 | |
236 | |
235 | # backtrace as second step, in case it crashes, too |
237 | # backtrace as second step, in case it crashes, too |
236 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
238 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
237 | if $backtrace; |
239 | if $backtrace; |
238 | }; |
240 | }; |
|
|
241 | |
|
|
242 | sub clienterror($;$) { |
|
|
243 | my ($msg, $backtrace) = @_; |
|
|
244 | |
|
|
245 | warn $msg; |
|
|
246 | |
|
|
247 | return unless $CONN; |
|
|
248 | |
|
|
249 | $CONN->send_exti_msg (clientlog => $msg); |
|
|
250 | $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; |
|
|
251 | } |
239 | |
252 | |
240 | ############################################################################# |
253 | ############################################################################# |
241 | |
254 | |
242 | sub status { |
255 | sub status { |
243 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
256 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
… | |
… | |
398 | my $rwops = $meta->{path} |
411 | my $rwops = $meta->{path} |
399 | ? new_from_file DC::RW $meta->{path} |
412 | ? new_from_file DC::RW $meta->{path} |
400 | : new DC::RW $$MUSIC_PLAYING_DATA; |
413 | : new DC::RW $$MUSIC_PLAYING_DATA; |
401 | |
414 | |
402 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
415 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
403 | or Carp::confess "music face $meta->{face} unloadable: " . DC::Mix_GetError; |
416 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
404 | |
417 | |
405 | my $NOW = time; |
418 | my $NOW = time; |
406 | |
419 | |
407 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
420 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
408 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
421 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |