… | |
… | |
21 | |
21 | |
22 | for my $map (@$files) { |
22 | for my $map (@$files) { |
23 | utf8::decode $map; |
23 | utf8::decode $map; |
24 | next if $map =~ /\.(?:pst|meta)$/; |
24 | next if $map =~ /\.(?:pst|meta)$/; |
25 | cf::map::find $map; |
25 | cf::map::find $map; |
26 | $cf::WAIT_FOR_TICK->wait; |
26 | cf::wait_for_tick; |
27 | $cf::WAIT_FOR_TICK->wait; |
|
|
28 | $cf::WAIT_FOR_TICK->wait; |
|
|
29 | } |
27 | } |
30 | |
28 | |
31 | #TODO: should also preload random maps... |
29 | #TODO: should also preload random maps... |
32 | }; |
30 | }; |
33 | |
31 | |
… | |
… | |
56 | $map->reset; |
54 | $map->reset; |
57 | } elsif ($map->in_memory == cf::MAP_IN_MEMORY) { |
55 | } elsif ($map->in_memory == cf::MAP_IN_MEMORY) { |
58 | my $max_idle = cf::object::actives_size > $MAX_ACTIVES ? 1 : $SWAP_TIMEOUT; |
56 | my $max_idle = cf::object::actives_size > $MAX_ACTIVES ? 1 : $SWAP_TIMEOUT; |
59 | if ($map->last_access + $max_idle <= $cf::RUNTIME && !$map->players) { |
57 | if ($map->last_access + $max_idle <= $cf::RUNTIME && !$map->players) { |
60 | $map->swap_out; |
58 | $map->swap_out; |
61 | $cf::WAIT_FOR_TICK_ONE->wait unless $max_idle == 1; |
59 | cf::wait_for_tick unless $max_idle == 1; |
62 | } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
60 | } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
63 | $map->save; |
61 | $map->save; |
64 | $cf::WAIT_FOR_TICK_ONE->wait unless $max_idle == 1; |
62 | cf::wait_for_tick unless $max_idle == 1; |
65 | } |
63 | } |
66 | } |
64 | } |
67 | }; |
65 | }; |
68 | warn $@ if $@; |
66 | warn $@ if $@; |
69 | Coro::cede; |
67 | Coro::cede; |