… | |
… | |
1079 | =cut |
1079 | =cut |
1080 | |
1080 | |
1081 | sub maps($) { |
1081 | sub maps($) { |
1082 | my ($pl) = @_; |
1082 | my ($pl) = @_; |
1083 | |
1083 | |
|
|
1084 | $pl = ref $pl ? $pl->ob->name : $pl; |
|
|
1085 | |
1084 | my $files = aio_readdir playerdir $pl |
1086 | my $files = aio_readdir playerdir $pl |
1085 | or return; |
1087 | or return; |
1086 | |
1088 | |
1087 | my @paths; |
1089 | my @paths; |
1088 | |
1090 | |
1089 | for (@$files) { |
1091 | for (@$files) { |
1090 | utf8::decode $_; |
1092 | utf8::decode $_; |
1091 | next if /\.(?:pl|pst)$/; |
1093 | next if /\.(?:pl|pst)$/; |
1092 | next unless /^$PATH_SEP/o; |
1094 | next unless /^$PATH_SEP/o; |
1093 | |
1095 | |
1094 | push @paths, cf::map::normalise "~" . $pl->ob->name . "/" . $_; |
1096 | push @paths, cf::map::normalise "~$pl/$_"; |
1095 | } |
1097 | } |
1096 | |
1098 | |
1097 | \@paths |
1099 | \@paths |
1098 | } |
1100 | } |
1099 | |
1101 | |
… | |
… | |
2001 | # get handled first |
2003 | # get handled first |
2002 | my $queue = delete $ns->{query_queue} |
2004 | my $queue = delete $ns->{query_queue} |
2003 | or return; # be conservative, not sure how that can happen, but we saw a crash here |
2005 | or return; # be conservative, not sure how that can happen, but we saw a crash here |
2004 | |
2006 | |
2005 | (shift @$queue)->[1]->($msg); |
2007 | (shift @$queue)->[1]->($msg); |
|
|
2008 | return unless $ns->valid; # temporary(?) workaround for callback destroying socket |
2006 | |
2009 | |
2007 | push @{ $ns->{query_queue} }, @$queue; |
2010 | push @{ $ns->{query_queue} }, @$queue; |
2008 | |
2011 | |
2009 | if (@{ $ns->{query_queue} } == @$queue) { |
2012 | if (@{ $ns->{query_queue} } == @$queue) { |
2010 | if (@$queue) { |
2013 | if (@$queue) { |
… | |
… | |
2267 | }, |
2270 | }, |
2268 | ); |
2271 | ); |
2269 | } |
2272 | } |
2270 | |
2273 | |
2271 | ############################################################################# |
2274 | ############################################################################# |
2272 | # the server's main() |
2275 | # the server's init and main functions |
|
|
2276 | |
|
|
2277 | sub load_resources { |
|
|
2278 | load_regions sprintf "%s/%s/regions", cf::datadir, cf::mapdir |
|
|
2279 | or die "unable to load regions file\n";#d# |
|
|
2280 | } |
2273 | |
2281 | |
2274 | sub cfg_load { |
2282 | sub cfg_load { |
2275 | open my $fh, "<:utf8", cf::confdir . "/config" |
2283 | open my $fh, "<:utf8", cf::confdir . "/config" |
2276 | or return; |
2284 | or return; |
2277 | |
2285 | |
… | |
… | |
2288 | $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()" |
2296 | $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()" |
2289 | and die "WARNING: m(un)lockall failed: $!\n"; |
2297 | and die "WARNING: m(un)lockall failed: $!\n"; |
2290 | }; |
2298 | }; |
2291 | warn $@ if $@; |
2299 | warn $@ if $@; |
2292 | } |
2300 | } |
|
|
2301 | } |
|
|
2302 | |
|
|
2303 | sub init { |
|
|
2304 | load_resources; |
2293 | } |
2305 | } |
2294 | |
2306 | |
2295 | sub main { |
2307 | sub main { |
2296 | # we must not ever block the main coroutine |
2308 | # we must not ever block the main coroutine |
2297 | local $Coro::idle = sub { |
2309 | local $Coro::idle = sub { |
… | |
… | |
2458 | warn "reattaching attachments to objects/players"; |
2470 | warn "reattaching attachments to objects/players"; |
2459 | _global_reattach; |
2471 | _global_reattach; |
2460 | warn "reattaching attachments to maps"; |
2472 | warn "reattaching attachments to maps"; |
2461 | reattach $_ for values %MAP; |
2473 | reattach $_ for values %MAP; |
2462 | |
2474 | |
|
|
2475 | warn "loading reloadable resources"; |
|
|
2476 | load_resources; |
|
|
2477 | |
2463 | warn "restarting server ticker"; |
2478 | warn "restarting server ticker"; |
2464 | |
2479 | |
2465 | $TICK_WATCHER->start; |
2480 | $TICK_WATCHER->start; |
2466 | }; |
2481 | }; |
2467 | |
2482 | |