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.1 by root, Sun Oct 14 15:33:31 2007 UTC vs.
Revision 1.5 by root, Wed Nov 14 23:50:29 2007 UTC

71# need to do it again because that pile of garbage called PAR nukes it before main 71# need to do it again because that pile of garbage called PAR nukes it before main
72unshift @INC, $ENV{PAR_TEMP} 72unshift @INC, $ENV{PAR_TEMP}
73 if %PAR::LibCache; 73 if %PAR::LibCache;
74 74
75use Time::HiRes 'time'; 75use Time::HiRes 'time';
76use Event; 76use EV;
77use List::Util qw(max min); 77use List::Util qw(max min);
78 78
79use Crossfire; 79use Crossfire;
80use Crossfire::Protocol::Constants; 80use Crossfire::Protocol::Constants;
81 81
97use CFPlus::Macro; 97use CFPlus::Macro;
98 98
99$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 99$SIG{QUIT} = sub { Carp::cluck "QUIT" };
100$SIG{PIPE} = 'IGNORE'; 100$SIG{PIPE} = 'IGNORE';
101 101
102$Event::Eval = 1;
103$Event::DIED = sub { 102$EV::DIED = sub {
104 CFPlus::fatal Carp::longmess $_[1] 103 CFPlus::fatal Carp::longmess $@;
105}; 104};
106 105
107my $MAX_FPS = 60; 106my $MAX_FPS = 60;
108my $MIN_FPS = 5; # unused as of yet 107my $MIN_FPS = 5; # unused as of yet
109 108
223 222
224 $AUDIO_PLAY{$face} 223 $AUDIO_PLAY{$face}
225 or return; 224 or return;
226 225
227 if (my $chunk = $AUDIO_CHUNK{$face}) { 226 if (my $chunk = $AUDIO_CHUNK{$face}) {
228 for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { 227 for (grep $_->[0] >= EV::now, @{(delete $AUDIO_PLAY{$face}) || []}) {
229 my (undef, $dx, $dy, $vol) = @$_; 228 my (undef, $dx, $dy, $vol) = @$_;
230 229
231 my $channel = CFPlus::Channel::find; 230 my $channel = CFPlus::Channel::find;
232 $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); 231 $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255);
233 $channel->set_position_r ($dx, $dy, 20); 232 $channel->set_position_r ($dx, $dy, 20);
269 or return; 268 or return;
270 $CFG->{effects_enable} 269 $CFG->{effects_enable}
271 or return; 270 or return;
272 271
273 my $queue = $AUDIO_PLAY{$face} ||= []; 272 my $queue = $AUDIO_PLAY{$face} ||= [];
274 push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events 273 push @$queue, [EV::now + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events
275 audio_sound_push $face 274 audio_sound_push $face
276 unless @$queue > 1; 275 unless @$queue > 1;
277} 276}
278 277
279sub audio_music_set_meta { 278sub audio_music_set_meta {
462 461
463 # FIXME: a very ugly hack to wait for stat update #d# 462 # FIXME: a very ugly hack to wait for stat update #d#
464 if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { 463 if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) {
465 unless ($QUERY_TIMER) { 464 unless ($QUERY_TIMER) {
466 $QUERY_TIMER = 465 $QUERY_TIMER =
467 Event->timer ( 466 EV::timer 1, 0, sub {
468 after => 1,
469 cb => sub {
470 server_query ($conn, $flags, $prompt, 1); 467 server_query ($conn, $flags, $prompt, 1);
471 $QUERY_TIMER = undef 468 $QUERY_TIMER = undef
472 }
473 ); 469 };
474 return; 470 return;
475 } 471 }
476 } 472 }
477 473
478 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel 474 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel
1521 $CFG->{profile}{default}{host} = $value; 1517 $CFG->{profile}{default}{host} = $value;
1522 1 1518 1
1523 } 1519 }
1524 ); 1520 );
1525 1521
1522 if (0) { #d# disabled
1526 $vbox->add (new CFPlus::UI::Button 1523 $vbox->add (new CFPlus::UI::Button
1527 expand => 1, 1524 expand => 1,
1528 text => "Server List", 1525 text => "Server List",
1529 other => $METASERVER, 1526 other => $METASERVER,
1530 tooltip => "Show a list of available crossfire servers", 1527 tooltip => "Show a list of available crossfire servers",
1531 on_activate => sub { $METASERVER->toggle_visibility; 0 }, 1528 on_activate => sub { $METASERVER->toggle_visibility; 0 },
1532 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, 1529 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 },
1533 ); 1530 );
1531 }#d#
1534 } 1532 }
1535 1533
1536 $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size"); 1534 $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size");
1537 $table->add_at (1, $row, new CFPlus::UI::Slider 1535 $table->add_at (1, $row, new CFPlus::UI::Slider
1538 force_w => 100, 1536 force_w => 100,
2013 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 2011 on_activate => sub { $QUIT_DIALOG->hide; 0 },
2014 ); 2012 );
2015 $hb->add (new CFPlus::UI::Button 2013 $hb->add (new CFPlus::UI::Button
2016 text => "Quit anyway", 2014 text => "Quit anyway",
2017 expand => 1, 2015 expand => 1,
2018 on_activate => sub { Event::unloop_all }, 2016 on_activate => sub { EV::unloop EV::UNLOOP_ALL },
2019 ); 2017 );
2020 } 2018 }
2021 2019
2022 $QUIT_DIALOG->show; 2020 $QUIT_DIALOG->show;
2023 $QUIT_DIALOG->grab_focus; 2021 $QUIT_DIALOG->grab_focus;
2139 force_y => "max", 2137 force_y => "max",
2140 child => $STATUSBOX, 2138 child => $STATUSBOX,
2141 )->show; 2139 )->show;
2142 2140
2143 CFPlus::UI::Toplevel->new ( 2141 CFPlus::UI::Toplevel->new (
2144 title => "Map", 2142 title => "Minimap",
2145 name => "mapmap", 2143 name => "mapmap",
2146 x => 0, 2144 x => 0,
2147 y => $FONTSIZE + 8, 2145 y => $FONTSIZE + 8,
2148 border_bg => [1, 1, 1, 192/255], 2146 border_bg => [1, 1, 1, 192/255],
2149 bg => [1, 1, 1, 0], 2147 bg => [1, 1, 1, 0],
2237 tooltip => "Terminates the program", 2235 tooltip => "Terminates the program",
2238 on_activate => sub { 2236 on_activate => sub {
2239 if ($CONN) { 2237 if ($CONN) {
2240 open_quit_dialog; 2238 open_quit_dialog;
2241 } else { 2239 } else {
2242 Event::unloop_all; 2240 EV::unloop EV::UNLOOP_ALL;
2243 } 2241 }
2244 0 2242 0
2245 }, 2243 },
2246 ); 2244 );
2247 2245
2263my $animate_timer; 2261my $animate_timer;
2264 2262
2265my $fps = 9; 2263my $fps = 9;
2266 2264
2267sub force_refresh { 2265sub force_refresh {
2266 $WANT_REFRESH->stop;
2267
2268 if ($ENV{CFPLUS_DEBUG} & 4) { 2268 if ($ENV{CFPLUS_DEBUG} & 4) {
2269 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; 2269 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
2270 debug sprintf "%3.2f", $fps; 2270 debug sprintf "%3.2f", $fps;
2271 } 2271 }
2272 2272
2273 $CFPlus::UI::ROOT->draw; 2273 $CFPlus::UI::ROOT->draw;
2274 CFPlus::SDL_GL_SwapBuffers; 2274 CFPlus::SDL_GL_SwapBuffers;
2275 $LAST_REFRESH = $NOW; 2275 $LAST_REFRESH = $NOW;
2276 $WANT_REFRESH->stop;
2277} 2276}
2278 2277
2279$WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh); 2278$WANT_REFRESH = EV::idle_ns \&force_refresh;
2280 2279
2281my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub { 2280my $input = EV::timer 0, 1/60, sub {
2282 $NOW = time; 2281 $NOW = time;
2283 2282
2284 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 2283 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
2285 for CFPlus::poll_events; 2284 for CFPlus::poll_events;
2286 2285
2287 if (%animate_object) { 2286 if (%animate_object) {
2288 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 2287 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
2289 $WANT_REFRESH->start; 2288 $WANT_REFRESH->start;
2290 } 2289 }
2291}); 2290};
2292 2291
2293sub animation_start { 2292sub animation_start {
2294 my ($widget) = @_; 2293 my ($widget) = @_;
2295 $animate_object{$widget} = $widget; 2294 $animate_object{$widget} = $widget;
2296} 2295}
2300 delete $animate_object{$widget}; 2299 delete $animate_object{$widget};
2301} 2300}
2302 2301
2303%SDL_CB = ( 2302%SDL_CB = (
2304 CFPlus::SDL_QUIT => sub { 2303 CFPlus::SDL_QUIT => sub {
2305 Event::unloop_all; 2304 EV::unloop EV::UNLOOP_ALL;
2306 }, 2305 },
2307 CFPlus::SDL_VIDEORESIZE => sub { 2306 CFPlus::SDL_VIDEORESIZE => sub {
2308 }, 2307 },
2309 CFPlus::SDL_VIDEOEXPOSE => sub { 2308 CFPlus::SDL_VIDEOEXPOSE => sub {
2310 CFPlus::UI::full_refresh; 2309 CFPlus::UI::full_refresh;
2350 2349
2351 CFPlus::UI::set_layout ($::CFG->{layout}); 2350 CFPlus::UI::set_layout ($::CFG->{layout});
2352 2351
2353 my %DEF_CFG = ( 2352 my %DEF_CFG = (
2354 sdl_mode => 0, 2353 sdl_mode => 0,
2355 fullscreen => 0, 2354 fullscreen => 1,
2356 fast => 0, 2355 fast => 0,
2357 force_opengl11 => undef, 2356 force_opengl11 => undef,
2358 texture_compression => 1, 2357 texture_compression => 1,
2359 map_scale => 1, 2358 map_scale => 1,
2360 fow_enable => 1, 2359 fow_enable => 1,
2451 audio_init; 2450 audio_init;
2452} 2451}
2453 2452
2454show_tip_of_the_day if $CFG->{show_tips}; 2453show_tip_of_the_day if $CFG->{show_tips};
2455 2454
2456Event->idle (cb => sub { 2455our $STARTUP_CANCEL = EV::idle sub {
2457 $_[0]->w->cancel; 2456 undef $::STARTUP_CANCEL;
2458 $startup_done->(); 2457 $startup_done->();
2459}); 2458};
2460 2459
2461Event::loop; 2460EV::loop;
2462 2461
2463#video_shutdown; 2462#video_shutdown;
2464#audio_shutdown; 2463#audio_shutdown;
2465CFPlus::SDL_Quit; 2464CFPlus::SDL_Quit;
2466CFPlus::DB::Server::stop; 2465CFPlus::DB::Server::stop;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines