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.78 by root, Tue Sep 30 03:05:07 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};
766} 780}
767 781
768sub dc_connect { 782sub dc_connect {
769 my ($host, $port) = @_; 783 my ($host, $port) = @_;
770 784
771 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 785 my $mapw = List::Util::min 48, List::Util::max 11, int 1.5 + $WIDTH * $CFG->{mapsize} * 0.01 / 32;
786 my $maph = List::Util::min 48, List::Util::max 11, int 1.5 + $HEIGHT * $CFG->{mapsize} * 0.01 / 32;
772 787
773 $CONN = 788 $CONN =
774 new DC::Protocol 789 new DC::Protocol
775 host => $host, 790 host => $host,
776 port => $port, 791 port => $port,
777 user => $PROFILE->{user}, 792 user => $PROFILE->{user},
778 pass => $PROFILE->{password}, 793 pass => $PROFILE->{password},
779 mapw => $mapsize, 794 mapw => $mapw,
780 maph => $mapsize, 795 maph => $maph,
781 796
782 client => "$DC::VERSION $] $^O", 797 client => "$DC::VERSION $] $^O",
783 798
784 map_widget => $MAPWIDGET, 799 map_widget => $MAPWIDGET,
785 statusbox => $STATUSBOX, 800 statusbox => $STATUSBOX,
933 ); 948 );
934 949
935 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); 950 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha");
936 $table->add_at (1, $row++, new DC::UI::CheckBox 951 $table->add_at (1, $row++, new DC::UI::CheckBox
937 state => $CFG->{disable_alpha}, 952 state => $CFG->{disable_alpha},
938 tooltip => "Forbid off the use of the alpha channel. This makes Deliantra look a lot worse " 953 tooltip => "Forbid the use of the alpha channel. This makes Deliantra look a lot worse "
939 . "by disabling a number of textures and transparency effects. Normally, these " 954 . "by disabling a number of textures and transparency effects. Normally, these "
940 . "effects do not cost a lot of resources, but some graphics cards might fall " 955 . "effects do not cost a lot of resources, but some graphics cards might fall "
941 . "back to extremely slow rendering if this is enabled. If disabling this option " 956 . "back to extremely slow rendering if this is enabled. If disabling this option "
942 . "noticably improves the framerate of the client please report this! " 957 . "noticably improves the framerate of the client please report this! "
943 . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", 958 . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>",
2585$SIG{INT} = $SIG{TERM} = sub { 2600$SIG{INT} = $SIG{TERM} = sub {
2586 EV::unloop; 2601 EV::unloop;
2587 #d# TODO calling exit here hangs the process in some futex 2602 #d# TODO calling exit here hangs the process in some futex
2588}; 2603};
2589 2604
2605# initialise the resolver now, as vista forces us back to the desktop
2606# when doing this.
2607AnyEvent::DNS::resolver;
2608
2590# 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
2591sub main { 2610sub main {
2592 { 2611 {
2593 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; 2612 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst";
2594 2613
2595 if (-e "$Deliantra::VARDIR/client.cf") { 2614 if (-e "$Deliantra::VARDIR/client.cf") {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines