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.65 by root, Sat Aug 30 06:49:05 2008 UTC vs.
Revision 1.71 by root, Mon Sep 1 15:19:07 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
110use AnyEvent::Util ();
109use AnyEvent::DNS; 111use AnyEvent::DNS;
110use AnyEvent::Socket (); 112use AnyEvent::Socket ();
111 113
112use Compress::LZF; 114use Compress::LZF;
115use JSON::XS;
113 116
114use DC; 117use DC;
115BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } } 118
119sub crash($;$) {
120 # nop during compiletime
121}
122
123BEGIN {
124 $SIG{__DIE__} = sub {
125 return if $^S;
126 crash "CRASH/DIE: $_[0]" => 1;
127 DC::fatal Carp::longmess "$_[0]";
128 }
129}
130
116use DC::OpenGL (); 131use DC::OpenGL ();
117use DC::Protocol; 132use DC::Protocol;
118use DC::DB; 133use DC::DB;
119use DC::UI; 134use DC::UI;
120use DC::UI::Canvas; 135use DC::UI::Canvas;
130 145
131$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 146$SIG{QUIT} = sub { Carp::cluck "QUIT" };
132$SIG{PIPE} = 'IGNORE'; 147$SIG{PIPE} = 'IGNORE';
133 148
134$EV::DIED = sub { 149$EV::DIED = sub {
150 crash "CRASH/EV::DIED: $@" => 1;
135 DC::fatal Carp::longmess $@; 151 DC::fatal Carp::longmess $@;
136}; 152};
137 153
138my $MAX_FPS = 60; 154my $MAX_FPS = 60;
139 155
141 157
142our $LAST_REFRESH; 158our $LAST_REFRESH;
143our $NOW; 159our $NOW;
144 160
145our $CFG; 161our $CFG;
146our $CONN;
147our $PROFILE; # current profile 162our $PROFILE; # current profile
148our $FAST; # fast, low-quality mode, possibly useful for software-rendering 163our $FAST; # fast, low-quality mode, possibly useful for software-rendering
149 164
150our $WANT_REFRESH; 165our $WANT_REFRESH;
151 166
159our $FULLSCREEN; 174our $FULLSCREEN;
160our $FONTSIZE; 175our $FONTSIZE;
161 176
162our $FONT_PROP; 177our $FONT_PROP;
163our $FONT_FIXED; 178our $FONT_FIXED;
179
180our $CONN;
164 181
165our $MAP; 182our $MAP;
166our $MAPMAP; 183our $MAPMAP;
167our $MAPWIDGET; 184our $MAPWIDGET;
168our $COMPLETER; 185our $COMPLETER;
210our $DEBUG_STATUS; 227our $DEBUG_STATUS;
211 228
212our $INV; 229our $INV;
213our $INVR; 230our $INVR;
214our $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};
215 259
216############################################################################# 260#############################################################################
217 261
218sub status { 262sub status {
219 $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]);
806 dc_connect $host, $port; 850 dc_connect $host, $port;
807 } 851 }
808} 852}
809 853
810sub stop_game { 854sub stop_game {
855 crash "stop_game";
856
811 $LOGIN_BUTTON->set_text ("Login / Register"); 857 $LOGIN_BUTTON->set_text ("Login / Register");
812 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); 858 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);
813 $SETUP_DIALOG->show; 859 $SETUP_DIALOG->show;
814 $PL_WINDOW->hide; 860 $PL_WINDOW->hide;
815 $SPELL_LIST->clear_spells; 861 $SPELL_LIST->clear_spells;
2132 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 2178 on_activate => sub { $QUIT_DIALOG->hide; 0 },
2133 ); 2179 );
2134 $hb->add (new DC::UI::Button 2180 $hb->add (new DC::UI::Button
2135 text => "Quit anyway", 2181 text => "Quit anyway",
2136 expand => 1, 2182 expand => 1,
2137 on_activate => sub { EV::unloop EV::UNLOOP_ALL }, 2183 on_activate => sub {
2184 crash "Quit anyway";
2185 EV::unloop EV::UNLOOP_ALL;
2186 },
2138 ); 2187 );
2139 } 2188 }
2140 2189
2141 $QUIT_DIALOG->show; 2190 $QUIT_DIALOG->show;
2142 $QUIT_DIALOG->grab_focus; 2191 $QUIT_DIALOG->grab_focus;
2480 delete $animate_object{$widget}; 2529 delete $animate_object{$widget};
2481} 2530}
2482 2531
2483%SDL_CB = ( 2532%SDL_CB = (
2484 DC::SDL_QUIT => sub { 2533 DC::SDL_QUIT => sub {
2534 crash "SDL_QUIT";
2485 EV::unloop EV::UNLOOP_ALL; 2535 EV::unloop EV::UNLOOP_ALL;
2486 }, 2536 },
2487 DC::SDL_VIDEORESIZE => sub { 2537 DC::SDL_VIDEORESIZE => sub {
2488 }, 2538 },
2489 DC::SDL_VIDEOEXPOSE => sub { 2539 DC::SDL_VIDEOEXPOSE => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines