… | |
… | |
32 | use EV; |
32 | use EV; |
33 | use Opcode; |
33 | use Opcode; |
34 | use Safe; |
34 | use Safe; |
35 | use Safe::Hole; |
35 | use Safe::Hole; |
36 | use Storable (); |
36 | use Storable (); |
|
|
37 | use Carp (); |
37 | |
38 | |
38 | use Guard (); |
39 | use Guard (); |
39 | use Coro (); |
40 | use Coro (); |
40 | use Coro::State; |
41 | use Coro::State; |
41 | use Coro::Handle; |
42 | use Coro::Handle; |
… | |
… | |
228 | returns directly I<after> the tick processing (and consequently, can only wake one process |
229 | returns directly I<after> the tick processing (and consequently, can only wake one process |
229 | per tick), while cf::wait_for_tick wakes up all waiters after tick processing. |
230 | per tick), while cf::wait_for_tick wakes up all waiters after tick processing. |
230 | |
231 | |
231 | =item @cf::INVOKE_RESULTS |
232 | =item @cf::INVOKE_RESULTS |
232 | |
233 | |
233 | This array contains the results of the last C<invoke ()> call. When |
234 | This array contains the results of the last C<invoke ()> call. When |
234 | C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of |
235 | C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of |
235 | that call. |
236 | that call. |
236 | |
237 | |
237 | =item %cf::REFLECT |
238 | =item %cf::REFLECT |
238 | |
239 | |
… | |
… | |
289 | )) { |
290 | )) { |
290 | @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; |
291 | @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; |
291 | } |
292 | } |
292 | |
293 | |
293 | $EV::DIED = sub { |
294 | $EV::DIED = sub { |
294 | warn "error in event callback: @_"; |
295 | Carp::cluck "error in event callback: @_"; |
295 | }; |
296 | }; |
296 | |
297 | |
297 | ############################################################################# |
298 | ############################################################################# |
298 | |
299 | |
299 | =head2 UTILITY FUNCTIONS |
300 | =head2 UTILITY FUNCTIONS |
… | |
… | |
2341 | : normalise $_ |
2342 | : normalise $_ |
2342 | } @{ aio_readdir $UNIQUEDIR or [] } |
2343 | } @{ aio_readdir $UNIQUEDIR or [] } |
2343 | ] |
2344 | ] |
2344 | } |
2345 | } |
2345 | |
2346 | |
|
|
2347 | =item cf::map::static_maps |
|
|
2348 | |
|
|
2349 | Returns an arrayref if paths of all static maps (all preinstalled F<.map> |
|
|
2350 | file in the shared directory excluding F</styles> and F</editor>). May |
|
|
2351 | block. |
|
|
2352 | |
|
|
2353 | =cut |
|
|
2354 | |
|
|
2355 | sub static_maps() { |
|
|
2356 | my @dirs = ""; |
|
|
2357 | my @maps; |
|
|
2358 | |
|
|
2359 | while (@dirs) { |
|
|
2360 | my $dir = shift @dirs; |
|
|
2361 | |
|
|
2362 | next if $dir eq "/styles" || $dir eq "/editor"; |
|
|
2363 | |
|
|
2364 | my ($dirs, $files) = Coro::AIO::aio_scandir "$MAPDIR$dir", 2 |
|
|
2365 | or return; |
|
|
2366 | |
|
|
2367 | for (@$files) { |
|
|
2368 | s/\.map$// or next; |
|
|
2369 | utf8::decode $_; |
|
|
2370 | push @maps, "$dir/$_"; |
|
|
2371 | } |
|
|
2372 | |
|
|
2373 | push @dirs, map "$dir/$_", @$dirs; |
|
|
2374 | } |
|
|
2375 | |
|
|
2376 | \@maps |
|
|
2377 | } |
|
|
2378 | |
2346 | =back |
2379 | =back |
2347 | |
2380 | |
2348 | =head3 cf::object |
2381 | =head3 cf::object |
2349 | |
2382 | |
2350 | =cut |
2383 | =cut |
… | |
… | |
2545 | ($x, $y) = (-1, -1) |
2578 | ($x, $y) = (-1, -1) |
2546 | unless (defined $x) && (defined $y); |
2579 | unless (defined $x) && (defined $y); |
2547 | |
2580 | |
2548 | # use -1 or undef as default coordinates, not 0, 0 |
2581 | # use -1 or undef as default coordinates, not 0, 0 |
2549 | ($x, $y) = ($map->enter_x, $map->enter_y) |
2582 | ($x, $y) = ($map->enter_x, $map->enter_y) |
2550 | if $x <=0 && $y <= 0; |
2583 | if $x <= 0 && $y <= 0; |
2551 | |
2584 | |
2552 | $map->load; |
2585 | $map->load; |
2553 | $map->load_neighbours; |
2586 | $map->load_neighbours; |
2554 | |
2587 | |
2555 | return unless $self->contr->active; |
2588 | return unless $self->contr->active; |
… | |
… | |
2765 | |
2798 | |
2766 | =cut |
2799 | =cut |
2767 | |
2800 | |
2768 | # non-persistent channels (usually the info channel) |
2801 | # non-persistent channels (usually the info channel) |
2769 | our %CHANNEL = ( |
2802 | our %CHANNEL = ( |
|
|
2803 | "c/motd" => { |
|
|
2804 | id => "infobox", |
|
|
2805 | title => "MOTD", |
|
|
2806 | reply => undef, |
|
|
2807 | tooltip => "The message of the day", |
|
|
2808 | }, |
2770 | "c/identify" => { |
2809 | "c/identify" => { |
2771 | id => "infobox", |
2810 | id => "infobox", |
2772 | title => "Identify", |
2811 | title => "Identify", |
2773 | reply => undef, |
2812 | reply => undef, |
2774 | tooltip => "Items recently identified", |
2813 | tooltip => "Items recently identified", |
… | |
… | |
2776 | "c/examine" => { |
2815 | "c/examine" => { |
2777 | id => "infobox", |
2816 | id => "infobox", |
2778 | title => "Examine", |
2817 | title => "Examine", |
2779 | reply => undef, |
2818 | reply => undef, |
2780 | tooltip => "Signs and other items you examined", |
2819 | tooltip => "Signs and other items you examined", |
|
|
2820 | }, |
|
|
2821 | "c/shopinfo" => { |
|
|
2822 | id => "infobox", |
|
|
2823 | title => "Shop Info", |
|
|
2824 | reply => undef, |
|
|
2825 | tooltip => "What your bargaining skill tells you about the shop", |
2781 | }, |
2826 | }, |
2782 | "c/book" => { |
2827 | "c/book" => { |
2783 | id => "infobox", |
2828 | id => "infobox", |
2784 | title => "Book", |
2829 | title => "Book", |
2785 | reply => undef, |
2830 | reply => undef, |