… | |
… | |
1143 | $map->per_player (0) if $path->{user_rel}; |
1143 | $map->per_player (0) if $path->{user_rel}; |
1144 | } |
1144 | } |
1145 | |
1145 | |
1146 | $map->path ($key); |
1146 | $map->path ($key); |
1147 | $map->{path} = $path; |
1147 | $map->{path} = $path; |
|
|
1148 | $map->{last_save} = $cf::RUNTIME; |
1148 | $map->last_access ($cf::RUNTIME); |
1149 | $map->last_access ($cf::RUNTIME); |
1149 | |
1150 | |
1150 | if ($map->should_reset) { |
1151 | if ($map->should_reset) { |
1151 | $map->reset; |
1152 | $map->reset; |
1152 | $map = find_map $path; |
1153 | $map = find_map $path; |
… | |
… | |
1383 | (ref $cf::CFG{"may_$access"} |
1384 | (ref $cf::CFG{"may_$access"} |
1384 | ? scalar grep $self->name eq $_, @{$cf::CFG{"may_$access"}} |
1385 | ? scalar grep $self->name eq $_, @{$cf::CFG{"may_$access"}} |
1385 | : $cf::CFG{"may_$access"}) |
1386 | : $cf::CFG{"may_$access"}) |
1386 | } |
1387 | } |
1387 | |
1388 | |
|
|
1389 | =item $player_object->enter_link |
|
|
1390 | |
|
|
1391 | Freezes the player and moves him/her to a special map (C<{link}>). |
|
|
1392 | |
|
|
1393 | The player should be reaosnably safe there for short amounts of time. You |
|
|
1394 | I<MUST> call C<leave_link> as soon as possible, though. |
|
|
1395 | |
|
|
1396 | =item $player_object->leave_link ($map, $x, $y) |
|
|
1397 | |
|
|
1398 | Moves the player out of the specila link map onto the given map. If the |
|
|
1399 | map is not valid (or omitted), the player will be moved back to the |
|
|
1400 | location he/she was before the call to C<enter_link>, or, if that fails, |
|
|
1401 | to the emergency map position. |
|
|
1402 | |
|
|
1403 | Might block. |
|
|
1404 | |
|
|
1405 | =cut |
|
|
1406 | |
1388 | sub cf::object::player::enter_link { |
1407 | sub cf::object::player::enter_link { |
1389 | my ($self) = @_; |
1408 | my ($self) = @_; |
1390 | |
1409 | |
1391 | return if $self->map == $LINK_MAP; |
1410 | return if $self->map == $LINK_MAP; |
1392 | |
1411 | |
… | |
… | |
1401 | my ($self, $map, $x, $y) = @_; |
1420 | my ($self, $map, $x, $y) = @_; |
1402 | |
1421 | |
1403 | my $link_pos = delete $self->{_link_pos}; |
1422 | my $link_pos = delete $self->{_link_pos}; |
1404 | |
1423 | |
1405 | unless ($map) { |
1424 | unless ($map) { |
1406 | $self->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED); |
|
|
1407 | |
|
|
1408 | # restore original map position |
1425 | # restore original map position |
1409 | ($map, $x, $y) = @{ $link_pos || [] }; |
1426 | ($map, $x, $y) = @{ $link_pos || [] }; |
1410 | $map = cf::map::find_map $map; |
1427 | $map = cf::map::find_map $map; |
1411 | |
1428 | |
1412 | unless ($map) { |
1429 | unless ($map) { |
… | |
… | |
1444 | my $map = cf::map::find_map $path->as_string; |
1461 | my $map = cf::map::find_map $path->as_string; |
1445 | $map = $map->customise_for ($self) if $map; |
1462 | $map = $map->customise_for ($self) if $map; |
1446 | |
1463 | |
1447 | warn "entering ", $map->path, " at ($x, $y)\n" |
1464 | warn "entering ", $map->path, " at ($x, $y)\n" |
1448 | if $map; |
1465 | if $map; |
|
|
1466 | |
|
|
1467 | $map or $self->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED); |
1449 | |
1468 | |
1450 | $self->leave_link ($map, $x, $y); |
1469 | $self->leave_link ($map, $x, $y); |
1451 | })->prio (1); |
1470 | })->prio (1); |
1452 | } |
1471 | } |
1453 | |
1472 | |
… | |
… | |
1864 | } |
1883 | } |
1865 | |
1884 | |
1866 | sub main { |
1885 | sub main { |
1867 | # we must not ever block the main coroutine |
1886 | # we must not ever block the main coroutine |
1868 | local $Coro::idle = sub { |
1887 | local $Coro::idle = sub { |
1869 | Carp::cluck "FATAL: Coro::idle was called, major BUG\n";#d# |
1888 | Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# |
1870 | (Coro::unblock_sub { |
1889 | (Coro::unblock_sub { |
1871 | Event::one_event; |
1890 | Event::one_event; |
1872 | })->(); |
1891 | })->(); |
1873 | }; |
1892 | }; |
1874 | |
1893 | |