--- deliantra/Deliantra-Client/bin/deliantra 2007/11/03 12:08:44 1.3 +++ deliantra/Deliantra-Client/bin/deliantra 2007/11/12 23:25:37 1.4 @@ -73,7 +73,7 @@ if %PAR::LibCache; use Time::HiRes 'time'; -use Event; +use EV; use List::Util qw(max min); use Crossfire; @@ -99,9 +99,8 @@ $SIG{QUIT} = sub { Carp::cluck "QUIT" }; $SIG{PIPE} = 'IGNORE'; -$Event::Eval = 1; -$Event::DIED = sub { - CFPlus::fatal Carp::longmess $_[1] +$EV::DIED = sub { + CFPlus::fatal Carp::longmess $@; }; my $MAX_FPS = 60; @@ -225,7 +224,7 @@ or return; if (my $chunk = $AUDIO_CHUNK{$face}) { - for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { + for (grep $_->[0] >= EV::now, @{(delete $AUDIO_PLAY{$face}) || []}) { my (undef, $dx, $dy, $vol) = @$_; my $channel = CFPlus::Channel::find; @@ -271,7 +270,7 @@ or return; my $queue = $AUDIO_PLAY{$face} ||= []; - push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events + push @$queue, [EV::now + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events audio_sound_push $face unless @$queue > 1; } @@ -464,13 +463,10 @@ if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { unless ($QUERY_TIMER) { $QUERY_TIMER = - Event->timer ( - after => 1, - cb => sub { - server_query ($conn, $flags, $prompt, 1); - $QUERY_TIMER = undef - } - ); + EV::timer 1, 0, sub { + server_query ($conn, $flags, $prompt, 1); + $QUERY_TIMER = undef + }; return; } } @@ -2015,7 +2011,7 @@ $hb->add (new CFPlus::UI::Button text => "Quit anyway", expand => 1, - on_activate => sub { Event::unloop_all }, + on_activate => sub { EV::unloop EV::UNLOOP_ALL }, ); } @@ -2239,7 +2235,7 @@ if ($CONN) { open_quit_dialog; } else { - Event::unloop_all; + EV::unloop EV::UNLOOP_ALL; } 0 }, @@ -2265,6 +2261,8 @@ my $fps = 9; sub force_refresh { + $WANT_REFRESH->stop; + if ($ENV{CFPLUS_DEBUG} & 4) { $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; debug sprintf "%3.2f", $fps; @@ -2273,12 +2271,11 @@ $CFPlus::UI::ROOT->draw; CFPlus::SDL_GL_SwapBuffers; $LAST_REFRESH = $NOW; - $WANT_REFRESH->stop; } -$WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh); +$WANT_REFRESH = EV::idle_ns \&force_refresh; -my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub { +my $input = EV::timer 0, 1/60, sub { $NOW = time; ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) @@ -2288,7 +2285,7 @@ $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; $WANT_REFRESH->start; } -}); +}; sub animation_start { my ($widget) = @_; @@ -2302,7 +2299,7 @@ %SDL_CB = ( CFPlus::SDL_QUIT => sub { - Event::unloop_all; + EV::unloop EV::UNLOOP_ALL; }, CFPlus::SDL_VIDEORESIZE => sub { }, @@ -2453,12 +2450,12 @@ show_tip_of_the_day if $CFG->{show_tips}; -Event->idle (cb => sub { - $_[0]->w->cancel; +our $STARTUP_CANCEL = EV::idle sub { + undef $::STARTUP_CANCEL; $startup_done->(); -}); +}; -Event::loop; +EV::loop; #video_shutdown; #audio_shutdown;