… | |
… | |
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; |
… | |
… | |
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; |