… | |
… | |
11 | |
11 | |
12 | our $SCHEDULER = cf::coro { |
12 | our $SCHEDULER = cf::coro { |
13 | while () { |
13 | while () { |
14 | Coro::Timer::sleep $SCHEDULE_INTERVAL; |
14 | Coro::Timer::sleep $SCHEDULE_INTERVAL; |
15 | |
15 | |
16 | for my $map (values %cf::MAP) { |
16 | # this weird form of iteration over values is used because |
|
|
17 | # the hash changes underneath us frequently, and for |
|
|
18 | # keeps a direct reference to the value without (in 5.8 perls) |
|
|
19 | # keeping a reference, so this is prone to crashes or worse. |
|
|
20 | my @maps = keys %cf::MAP; |
|
|
21 | for (@maps) { |
|
|
22 | my $map = $cf::MAP{$_} |
|
|
23 | or next; |
|
|
24 | $map->valid or next; |
|
|
25 | |
17 | eval { |
26 | eval { |
18 | # not yet, because maps might become visible to players nearby |
27 | # not yet, because maps might become visible to players nearby |
19 | # we need to remove the map from %cf::MAP and all tiled map links |
28 | # we need to remove the map from %cf::MAP and all tiled map links |
20 | # if ($last_access + $DEACTIVATE_TIMEOUT <= $cf::RUNTIME) { |
29 | # if ($last_access + $DEACTIVATE_TIMEOUT <= $cf::RUNTIME) { |
21 | # $map->deactivate; |
30 | # $map->deactivate; |
… | |
… | |
33 | } |
42 | } |
34 | } |
43 | } |
35 | }; |
44 | }; |
36 | warn $@ if $@; |
45 | warn $@ if $@; |
37 | Coro::cede; |
46 | Coro::cede; |
38 | } |
47 | }; |
39 | } |
48 | } |
40 | }; |
49 | }; |
41 | |
50 | |
42 | $SCHEDULER->prio (-2); |
51 | $SCHEDULER->prio (-2); |
43 | |
52 | |