… | |
… | |
165 | |
165 | |
166 | our $EMERGENCY_POSITION; |
166 | our $EMERGENCY_POSITION; |
167 | |
167 | |
168 | sub cf::map::normalise; |
168 | sub cf::map::normalise; |
169 | |
169 | |
|
|
170 | sub in_main() { |
|
|
171 | $Coro::current == $Coro::main |
|
|
172 | } |
|
|
173 | |
170 | ############################################################################# |
174 | ############################################################################# |
171 | |
175 | |
172 | %REFLECT = (); |
176 | %REFLECT = (); |
173 | for (@REFLECT) { |
177 | for (@REFLECT) { |
174 | my $reflect = JSON::XS::decode_json $_; |
178 | my $reflect = JSON::XS::decode_json $_; |
… | |
… | |
261 | $Coro::State::DIEHOOK = sub { |
265 | $Coro::State::DIEHOOK = sub { |
262 | return unless $^S eq 0; # "eq", not "==" |
266 | return unless $^S eq 0; # "eq", not "==" |
263 | |
267 | |
264 | warn Carp::longmess $_[0]; |
268 | warn Carp::longmess $_[0]; |
265 | |
269 | |
266 | if ($Coro::current == $Coro::main) {#d# |
270 | if (in_main) {#d# |
267 | warn "DIEHOOK called in main context, Coro bug?\n";#d# |
271 | warn "DIEHOOK called in main context, Coro bug?\n";#d# |
268 | return;#d# |
272 | return;#d# |
269 | }#d# |
273 | }#d# |
270 | |
274 | |
271 | # kill coroutine otherwise |
275 | # kill coroutine otherwise |
… | |
… | |
1691 | \@logins |
1695 | \@logins |
1692 | } |
1696 | } |
1693 | |
1697 | |
1694 | =item $player->maps |
1698 | =item $player->maps |
1695 | |
1699 | |
|
|
1700 | =item cf::player::maps $login |
|
|
1701 | |
1696 | Returns an arrayref of map paths that are private for this |
1702 | Returns an arrayref of map paths that are private for this |
1697 | player. May block. |
1703 | player. May block. |
1698 | |
1704 | |
1699 | =cut |
1705 | =cut |
1700 | |
1706 | |
… | |
… | |
1761 | |
1767 | |
1762 | =cut |
1768 | =cut |
1763 | |
1769 | |
1764 | sub find_by_path($) { |
1770 | sub find_by_path($) { |
1765 | my ($path) = @_; |
1771 | my ($path) = @_; |
|
|
1772 | |
|
|
1773 | $path =~ s/^~[^\/]*//; # skip ~login |
1766 | |
1774 | |
1767 | my ($match, $specificity); |
1775 | my ($match, $specificity); |
1768 | |
1776 | |
1769 | for my $region (list) { |
1777 | for my $region (list) { |
1770 | if ($region->{match} && $path =~ $region->{match}) { |
1778 | if ($region->{match} && $path =~ $region->{match}) { |
… | |
… | |
1834 | |
1842 | |
1835 | $EXT_MAP{$pkg} = [$prio, qr<$regex>]; |
1843 | $EXT_MAP{$pkg} = [$prio, qr<$regex>]; |
1836 | } |
1844 | } |
1837 | |
1845 | |
1838 | # also paths starting with '/' |
1846 | # also paths starting with '/' |
1839 | $EXT_MAP{"cf::map"} = [0, qr{^(?=/)}]; |
1847 | $EXT_MAP{"cf::map::wrap"} = [0, qr{^(?=/)}]; |
1840 | |
1848 | |
1841 | sub thawer_merge { |
1849 | sub thawer_merge { |
1842 | my ($self, $merge) = @_; |
1850 | my ($self, $merge) = @_; |
1843 | |
1851 | |
1844 | # we have to keep some variables in memory intact |
1852 | # we have to keep some variables in memory intact |
… | |
… | |
2335 | |
2343 | |
2336 | delete $cf::MAP{$self->path}; |
2344 | delete $cf::MAP{$self->path}; |
2337 | |
2345 | |
2338 | $self->unlink_save; |
2346 | $self->unlink_save; |
2339 | |
2347 | |
2340 | bless $self, "cf::map"; |
2348 | bless $self, "cf::map::wrap"; |
2341 | delete $self->{deny_reset}; |
2349 | delete $self->{deny_reset}; |
2342 | $self->{deny_save} = 1; |
2350 | $self->{deny_save} = 1; |
2343 | $self->reset_timeout (1); |
2351 | $self->reset_timeout (1); |
2344 | $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); |
2352 | $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); |
2345 | |
2353 | |
… | |
… | |
3792 | } |
3800 | } |
3793 | } |
3801 | } |
3794 | |
3802 | |
3795 | sub do_reload_perl() { |
3803 | sub do_reload_perl() { |
3796 | # can/must only be called in main |
3804 | # can/must only be called in main |
3797 | if ($Coro::current != $Coro::main) { |
3805 | if (in_main) { |
3798 | warn "can only reload from main coroutine"; |
3806 | warn "can only reload from main coroutine"; |
3799 | return; |
3807 | return; |
3800 | } |
3808 | } |
3801 | |
3809 | |
3802 | return if $RELOAD++; |
3810 | return if $RELOAD++; |