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.81 by root, Mon Dec 22 02:33:30 2008 UTC vs.
Revision 1.83 by root, Sun Jan 4 10:22:19 2009 UTC

88use Deliantra::Protocol::Constants; 88use Deliantra::Protocol::Constants;
89 89
90use AnyEvent::Util (); 90use AnyEvent::Util ();
91use AnyEvent::DNS; 91use AnyEvent::DNS;
92use AnyEvent::Socket (); 92use AnyEvent::Socket ();
93use AnyEvent::DNS ();
93 94
94use Compress::LZF; 95use Compress::LZF;
95use JSON::XS; 96use JSON::XS;
96 97
97use DC; 98use 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
134my $MAX_FPS = 60; 135my $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
243sub 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
242sub status { 256sub 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.
2607AnyEvent::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
2592sub main { 2610sub 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") {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines