… | |
… | |
11 | our $SWAP_LOAD1 = $cf::CFG{swap_load1} || .1; # start aggressively swapping at this load |
11 | our $SWAP_LOAD1 = $cf::CFG{swap_load1} || .1; # start aggressively swapping at this load |
12 | our $SWAP_LOAD2 = $cf::CFG{swap_load2} || .4; # swap as fast as possible at this load |
12 | our $SWAP_LOAD2 = $cf::CFG{swap_load2} || .4; # swap as fast as possible at this load |
13 | |
13 | |
14 | cf::async_ext { |
14 | cf::async_ext { |
15 | $Coro::current->prio (Coro::PRIO_MIN); |
15 | $Coro::current->prio (Coro::PRIO_MIN); |
|
|
16 | |
16 | # load the header of swapped-out maps. |
17 | # load the header of swapped-out maps. |
17 | # this is not a correctness issue, it simply saves diskspace |
18 | # this is not a correctness issue, it simply saves diskspace |
18 | # because old files will get cleaned up on reset time |
19 | # because old files will get cleaned up on reset time |
19 | Coro::Timer::sleep 1; |
20 | Coro::Timer::sleep 0.25; |
20 | |
21 | |
21 | my $files = Coro::AIO::aio_readdir $cf::TMPDIR; |
22 | for my $map (@{ cf::map::tmp_maps or [] }) { |
22 | |
|
|
23 | for my $map (@$files) { |
|
|
24 | utf8::decode $map; |
|
|
25 | next if $map =~ /\.(?:pst|meta)$/; |
|
|
26 | cf::map::find $map; |
23 | cf::map::find $map; |
27 | cf::wait_for_tick; |
24 | cf::wait_for_tick; Coro::cede; |
28 | } |
25 | } |
29 | |
26 | |
30 | #TODO: should also preload random maps... |
27 | #TODO: should also preload random maps... |
|
|
28 | |
|
|
29 | # now hunt for resettable per-player maps |
|
|
30 | for my $login (@{ cf::player::list_logins or [] }) { |
|
|
31 | for my $path (@{ cf::player::maps $login or [] }) { |
|
|
32 | Coro::cede; |
|
|
33 | |
|
|
34 | $path =~ /^~[^\/]+(\/.*)$/ |
|
|
35 | or next; # doh |
|
|
36 | |
|
|
37 | my $base = cf::map::find $1; |
|
|
38 | |
|
|
39 | # skip maps without base maps on the assumption |
|
|
40 | # that those are old, unresettable maps |
|
|
41 | next unless $base; |
|
|
42 | |
|
|
43 | # skip unresettable maps, for speed |
|
|
44 | next if $base->{deny_reset}; |
|
|
45 | |
|
|
46 | my $map = cf::map::find $path; |
|
|
47 | cf::wait_for_tick; |
|
|
48 | |
|
|
49 | if ($map->{deny_reset}) { |
|
|
50 | warn "found noreset map with resettable base map, resetting: $path\n"; |
|
|
51 | delete $map->{deny_reset}; |
|
|
52 | } |
|
|
53 | } |
|
|
54 | } |
31 | }; |
55 | }; |
32 | |
56 | |
33 | our $SCHEDULER = cf::async_ext { |
57 | our $SCHEDULER = cf::async_ext { |
34 | while () { |
58 | while () { |
35 | Coro::Event::do_timer (after => $SCHEDULE_INTERVAL) |
59 | Coro::Event::do_timer (after => $SCHEDULE_INTERVAL) |