… | |
… | |
12 | cf::coro { |
12 | cf::coro { |
13 | $Coro::current->prio (Coro::PRIO_MIN); |
13 | $Coro::current->prio (Coro::PRIO_MIN); |
14 | # load the header of swapped-out maps. |
14 | # load the header of swapped-out maps. |
15 | # this is not a correctness issue, it simply saves diskspace |
15 | # this is not a correctness issue, it simply saves diskspace |
16 | # because old files will get cleaned up on reset time |
16 | # because old files will get cleaned up on reset time |
17 | Coro::Timer::sleep 5; |
17 | Coro::Timer::sleep 1; |
18 | |
18 | |
19 | my $files = Coro::AIO::aio_readdir cf::localdir . "/" . cf::tmpdir; |
19 | my $files = Coro::AIO::aio_readdir cf::localdir . "/" . cf::tmpdir; |
20 | |
20 | |
21 | for my $map (@$files) { |
21 | for my $map (@$files) { |
22 | utf8::decode $map; |
22 | utf8::decode $map; |
… | |
… | |
73 | # map load prefetch for tiled maps, possibly exits, too |
73 | # map load prefetch for tiled maps, possibly exits, too |
74 | cf::map->attach ( |
74 | cf::map->attach ( |
75 | on_enter => sub { |
75 | on_enter => sub { |
76 | my ($map, $pl) = @_; |
76 | my ($map, $pl) = @_; |
77 | |
77 | |
78 | # warn "$pl $map->{path}{path}\n";#d# |
78 | (Coro::async_pool { |
79 | # floodfill surrounding maps, asynchronously |
79 | my @diag; # diagonal neighbours |
|
|
80 | |
|
|
81 | for (0 .. 3) { |
|
|
82 | my $neigh = $map->tile_path ($_) |
|
|
83 | or next; |
|
|
84 | $neigh = cf::map::find $neigh, $map |
|
|
85 | or next; |
|
|
86 | $neigh->load; |
|
|
87 | |
|
|
88 | push @diag, [$neigh->tile_path (($_ + 3) % 4), $neigh], |
|
|
89 | [$neigh->tile_path (($_ + 1) % 4), $neigh]; |
|
|
90 | } |
|
|
91 | |
|
|
92 | for (@diag) { |
|
|
93 | my $neigh = cf::map::find @$_ |
|
|
94 | or next; |
|
|
95 | $neigh->load; |
|
|
96 | } |
|
|
97 | })->prio (2); |
|
|
98 | # higher prio because prefetching is very important |
|
|
99 | # as it prefetches maps that can make the server block |
80 | }, |
100 | }, |
81 | ); |
101 | ); |
82 | |
102 | |