… | |
… | |
2 | |
2 | |
3 | our $SCHEDULE_INTERVAL = $cf::CFG{extractor_schedule_interval} || 3600; |
3 | our $SCHEDULE_INTERVAL = $cf::CFG{extractor_schedule_interval} || 3600; |
4 | |
4 | |
5 | use JSON::XS; |
5 | use JSON::XS; |
6 | |
6 | |
7 | our $db_mapinfo = cf::sync_job { cf::db_table "tag-mapinfo" }; # info/cache for maps |
7 | our $db_mapinfo = cf::db_table "tag-mapinfo"; # info/cache for maps |
8 | our $db_target = cf::sync_job { cf::db_table "tag-target" }; # tag => maps |
8 | our $db_target = cf::db_table "tag-target"; # tag => maps |
9 | |
9 | |
10 | sub remove_tag_target { |
10 | sub remove_tag_target { |
11 | my ($txn, $tag, $target) = @_; |
11 | my ($txn, $tag, $target) = @_; |
12 | # - U O |
12 | # - U O |
13 | |
13 | |
… | |
… | |
70 | |
70 | |
71 | # we don't actually care if it succeeds or not, as we |
71 | # we don't actually care if it succeeds or not, as we |
72 | # will just retry an hour later |
72 | # will just retry an hour later |
73 | BDB::db_txn_finish $txn; |
73 | BDB::db_txn_finish $txn; |
74 | |
74 | |
75 | warn "tag-updated $file (= $key) <@tags>\n" |
75 | cf::debug "tag-updated $file (= $key) <@tags>\n" |
76 | if @tags; |
76 | if @tags; |
77 | } |
77 | } |
78 | |
78 | |
79 | sub scan_static { |
79 | sub scan_static { |
80 | my $maps = cf::map::static_maps; |
80 | my $maps = cf::map::static_maps; |
… | |
… | |
84 | } |
84 | } |
85 | |
85 | |
86 | sub reload { |
86 | sub reload { |
87 | my $guard = cf::lock_acquire "map-tags::reload"; |
87 | my $guard = cf::lock_acquire "map-tags::reload"; |
88 | |
88 | |
89 | my $start = EV::time; |
89 | my $start = AE::time; |
90 | |
90 | |
91 | # 1. check for maps no longer existing |
91 | # 1. check for maps no longer existing |
92 | { |
92 | { |
93 | my @delkeys; |
93 | my @delkeys; |
94 | |
94 | |
… | |
… | |
126 | |
126 | |
127 | # now hunt for all per-player maps |
127 | # now hunt for all per-player maps |
128 | # scan_dir $cf::PLAYERDIR |
128 | # scan_dir $cf::PLAYERDIR |
129 | # for my $login (@{ cf::player::list_logins or [] }) { |
129 | # for my $login (@{ cf::player::list_logins or [] }) { |
130 | # for my $path (@{ cf::player::maps $login or [] }) { |
130 | # for my $path (@{ cf::player::maps $login or [] }) { |
131 | # cf::cede_to_tick; |
|
|
132 | # |
131 | # |
133 | # $path =~ /^~[^\/]+(\/.*)$/ |
132 | # $path =~ /^~[^\/]+(\/.*)$/ |
134 | # or next; # doh |
133 | # or next; # doh |
135 | # |
134 | # |
136 | # my $base = cf::map::find $1; |
135 | # my $base = cf::map::find $1; |
… | |
… | |
149 | # delete $map->{deny_reset}; |
148 | # delete $map->{deny_reset}; |
150 | # } |
149 | # } |
151 | # } |
150 | # } |
152 | # } |
151 | # } |
153 | |
152 | |
154 | warn sprintf "map-tag scan (%fs)", EV::time - $start; |
153 | cf::info sprintf "map-tag scan finished (%fs)\n", AE::time - $start; |
155 | } |
154 | } |
156 | |
155 | |
157 | our $RELOAD_SCHEDULER = cf::periodic $SCHEDULE_INTERVAL, Coro::unblock_sub { |
156 | our $RELOAD_SCHEDULER = cf::periodic $SCHEDULE_INTERVAL, Coro::unblock_sub { |
158 | $Coro::current->prio (Coro::PRIO_MIN); |
157 | $Coro::current->prio (Coro::PRIO_MIN); |
159 | $Coro::current->desc ("map-tag scanner"); |
158 | $Coro::current->desc ("map-tag scanner"); |
… | |
… | |
176 | grep $_, |
175 | grep $_, |
177 | map { cf::map::find $_ } |
176 | map { cf::map::find $_ } |
178 | grep s/^s//, |
177 | grep s/^s//, |
179 | split /\x00/, $data |
178 | split /\x00/, $data |
180 | } |
179 | } |
|
|
180 | |
|
|
181 | sub unload { |
|
|
182 | my $guard = cf::lock_acquire "map-tags::reload"; |
|
|
183 | |
|
|
184 | BDB::db_close $db_target; |
|
|
185 | BDB::db_close $db_mapinfo; |
|
|
186 | } |
|
|
187 | |