… | |
… | |
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 |
… | |
… | |
1436 | if (length $@) { |
1440 | if (length $@) { |
1437 | warn "$v->{path}: $@\n"; |
1441 | warn "$v->{path}: $@\n"; |
1438 | |
1442 | |
1439 | cf::cleanup "mandatory extension '$k' failed to load, exiting." |
1443 | cf::cleanup "mandatory extension '$k' failed to load, exiting." |
1440 | if exists $v->{meta}{mandatory}; |
1444 | if exists $v->{meta}{mandatory}; |
|
|
1445 | |
|
|
1446 | warn "$v->{base}: optional extension cannot be loaded, skipping.\n"; |
|
|
1447 | delete $todo{$k}; |
1441 | } else { |
1448 | } else { |
1442 | $done{$k} = delete $todo{$k}; |
1449 | $done{$k} = delete $todo{$k}; |
1443 | push @EXTS, $v->{pkg}; |
1450 | push @EXTS, $v->{pkg}; |
1444 | $progress = 1; |
1451 | $progress = 1; |
1445 | |
1452 | |
… | |
… | |
1688 | \@logins |
1695 | \@logins |
1689 | } |
1696 | } |
1690 | |
1697 | |
1691 | =item $player->maps |
1698 | =item $player->maps |
1692 | |
1699 | |
|
|
1700 | =item cf::player::maps $login |
|
|
1701 | |
1693 | Returns an arrayref of map paths that are private for this |
1702 | Returns an arrayref of map paths that are private for this |
1694 | player. May block. |
1703 | player. May block. |
1695 | |
1704 | |
1696 | =cut |
1705 | =cut |
1697 | |
1706 | |
… | |
… | |
1758 | |
1767 | |
1759 | =cut |
1768 | =cut |
1760 | |
1769 | |
1761 | sub find_by_path($) { |
1770 | sub find_by_path($) { |
1762 | my ($path) = @_; |
1771 | my ($path) = @_; |
|
|
1772 | |
|
|
1773 | $path =~ s/^~[^\/]*//; # skip ~login |
1763 | |
1774 | |
1764 | my ($match, $specificity); |
1775 | my ($match, $specificity); |
1765 | |
1776 | |
1766 | for my $region (list) { |
1777 | for my $region (list) { |
1767 | if ($region->{match} && $path =~ $region->{match}) { |
1778 | if ($region->{match} && $path =~ $region->{match}) { |
… | |
… | |
2608 | return if UNIVERSAL::isa $self->map, "ext::map_link"; |
2619 | return if UNIVERSAL::isa $self->map, "ext::map_link"; |
2609 | |
2620 | |
2610 | $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y] |
2621 | $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y] |
2611 | if $self->map && $self->map->{path} ne "{link}"; |
2622 | if $self->map && $self->map->{path} ne "{link}"; |
2612 | |
2623 | |
2613 | $self->enter_map ($LINK_MAP || link_map, 10, 10); |
2624 | $self->enter_map ($LINK_MAP || link_map, 3, 3); |
2614 | } |
2625 | } |
2615 | |
2626 | |
2616 | sub cf::object::player::leave_link { |
2627 | sub cf::object::player::leave_link { |
2617 | my ($self, $map, $x, $y) = @_; |
2628 | my ($self, $map, $x, $y) = @_; |
2618 | |
2629 | |
… | |
… | |
3785 | my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; |
3796 | my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; |
3786 | for my $name (keys %$leaf_symtab) { |
3797 | for my $name (keys %$leaf_symtab) { |
3787 | _gv_clear *{"$pkg$name"}; |
3798 | _gv_clear *{"$pkg$name"}; |
3788 | # use PApp::Util; PApp::Util::sv_dump *{"$pkg$name"}; |
3799 | # use PApp::Util; PApp::Util::sv_dump *{"$pkg$name"}; |
3789 | } |
3800 | } |
3790 | warn "cleared package $pkg\n";#d# |
|
|
3791 | } |
3801 | } |
3792 | |
3802 | |
3793 | sub do_reload_perl() { |
3803 | sub do_reload_perl() { |
3794 | # can/must only be called in main |
3804 | # can/must only be called in main |
3795 | if ($Coro::current != $Coro::main) { |
3805 | if (in_main) { |
3796 | warn "can only reload from main coroutine"; |
3806 | warn "can only reload from main coroutine"; |
3797 | return; |
3807 | return; |
3798 | } |
3808 | } |
3799 | |
3809 | |
3800 | return if $RELOAD++; |
3810 | return if $RELOAD++; |