ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.114 by root, Mon Jan 1 16:00:10 2007 UTC vs.
Revision 1.117 by root, Mon Jan 1 17:50:26 2007 UTC

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;
1213} 1214}
1214 1215
1215sub save { 1216sub save {
1216 my ($self) = @_; 1217 my ($self) = @_;
1217 1218
1219 $self->{last_save} = $cf::RUNTIME;
1220
1221 return unless $self->dirty;
1222
1218 my $save = $self->{path}->save_path; utf8::encode $save; 1223 my $save = $self->{path}->save_path; utf8::encode $save;
1219 my $uniq = $self->{path}->uniq_path; utf8::encode $uniq; 1224 my $uniq = $self->{path}->uniq_path; utf8::encode $uniq;
1220
1221 $self->{last_save} = $cf::RUNTIME;
1222
1223 return unless $self->dirty;
1224 1225
1225 $self->{load_path} = $save; 1226 $self->{load_path} = $save;
1226 1227
1227 return if $self->{deny_save}; 1228 return if $self->{deny_save};
1228 1229
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
1391Freezes the player and moves him/her to a special map (C<{link}>).
1392
1393The player should be reaosnably safe there for short amounts of time. You
1394I<MUST> call C<leave_link> as soon as possible, though.
1395
1396=item $player_object->leave_link ($map, $x, $y)
1397
1398Moves the player out of the specila link map onto the given map. If the
1399map is not valid (or omitted), the player will be moved back to the
1400location he/she was before the call to C<enter_link>, or, if that fails,
1401to the emergency map position.
1402
1403Might block.
1404
1405=cut
1406
1388sub cf::object::player::enter_link { 1407sub 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
1866sub main { 1885sub 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines