… | |
… | |
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}) { |
… | |
… | |
1831 | |
1842 | |
1832 | $EXT_MAP{$pkg} = [$prio, qr<$regex>]; |
1843 | $EXT_MAP{$pkg} = [$prio, qr<$regex>]; |
1833 | } |
1844 | } |
1834 | |
1845 | |
1835 | # also paths starting with '/' |
1846 | # also paths starting with '/' |
1836 | $EXT_MAP{"cf::map"} = [0, qr{^(?=/)}]; |
1847 | $EXT_MAP{"cf::map::wrap"} = [0, qr{^(?=/)}]; |
1837 | |
1848 | |
1838 | sub thawer_merge { |
1849 | sub thawer_merge { |
1839 | my ($self, $merge) = @_; |
1850 | my ($self, $merge) = @_; |
1840 | |
1851 | |
1841 | # we have to keep some variables in memory intact |
1852 | # we have to keep some variables in memory intact |
… | |
… | |
2332 | |
2343 | |
2333 | delete $cf::MAP{$self->path}; |
2344 | delete $cf::MAP{$self->path}; |
2334 | |
2345 | |
2335 | $self->unlink_save; |
2346 | $self->unlink_save; |
2336 | |
2347 | |
2337 | bless $self, "cf::map"; |
2348 | bless $self, "cf::map::wrap"; |
2338 | delete $self->{deny_reset}; |
2349 | delete $self->{deny_reset}; |
2339 | $self->{deny_save} = 1; |
2350 | $self->{deny_save} = 1; |
2340 | $self->reset_timeout (1); |
2351 | $self->reset_timeout (1); |
2341 | $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); |
2352 | $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); |
2342 | |
2353 | |
… | |
… | |
2647 | local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext |
2658 | local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext |
2648 | $self->enter_map ($map, $x, $y); |
2659 | $self->enter_map ($map, $x, $y); |
2649 | |
2660 | |
2650 | # only activate afterwards, to support waiting in hooks |
2661 | # only activate afterwards, to support waiting in hooks |
2651 | $self->activate_recursive; |
2662 | $self->activate_recursive; |
|
|
2663 | # unless exists $self->{_link_pos}; # maybe we re in-flight again |
2652 | } |
2664 | } |
2653 | |
2665 | |
2654 | =item $player_object->goto ($path, $x, $y[, $check->($map)[, $done->()]]) |
2666 | =item $player_object->goto ($path, $x, $y[, $check->($map)[, $done->()]]) |
2655 | |
2667 | |
2656 | Moves the player to the given map-path and coordinates by first freezing |
2668 | Moves the player to the given map-path and coordinates by first freezing |
… | |
… | |
3789 | } |
3801 | } |
3790 | } |
3802 | } |
3791 | |
3803 | |
3792 | sub do_reload_perl() { |
3804 | sub do_reload_perl() { |
3793 | # can/must only be called in main |
3805 | # can/must only be called in main |
3794 | if ($Coro::current != $Coro::main) { |
3806 | if (in_main) { |
3795 | warn "can only reload from main coroutine"; |
3807 | warn "can only reload from main coroutine"; |
3796 | return; |
3808 | return; |
3797 | } |
3809 | } |
3798 | |
3810 | |
3799 | return if $RELOAD++; |
3811 | return if $RELOAD++; |