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.119 by root, Tue Jan 2 08:26:42 2007 UTC

817 (aio_load "$filename.pst", $av) >= 0 817 (aio_load "$filename.pst", $av) >= 0
818 or return; 818 or return;
819 $av = eval { (Storable::thaw $av)->{objs} }; 819 $av = eval { (Storable::thaw $av)->{objs} };
820 } 820 }
821 821
822 warn sprintf "loading %s (%d)\n",
823 $filename, length $data, scalar @{$av || []};#d#
822 return ($data, $av); 824 return ($data, $av);
823} 825}
824 826
825############################################################################# 827#############################################################################
826# command handling &c 828# command handling &c
1140 $map->instantiate; 1142 $map->instantiate;
1141 1143
1142 # per-player maps become, after loading, normal maps 1144 # per-player maps become, after loading, normal maps
1143 $map->per_player (0) if $path->{user_rel}; 1145 $map->per_player (0) if $path->{user_rel};
1144 } 1146 }
1147 #Coro::Timer::sleep 1;#d#
1145 1148
1146 $map->path ($key); 1149 $map->path ($key);
1147 $map->{path} = $path; 1150 $map->{path} = $path;
1151 $map->{last_save} = $cf::RUNTIME;
1148 $map->last_access ($cf::RUNTIME); 1152 $map->last_access ($cf::RUNTIME);
1149 1153
1150 if ($map->should_reset) { 1154 if ($map->should_reset) {
1151 $map->reset; 1155 $map->reset;
1152 $map = find_map $path; 1156 $map = find_map $path;
1213} 1217}
1214 1218
1215sub save { 1219sub save {
1216 my ($self) = @_; 1220 my ($self) = @_;
1217 1221
1222 $self->{last_save} = $cf::RUNTIME;
1223
1224 return unless $self->dirty;
1225
1218 my $save = $self->{path}->save_path; utf8::encode $save; 1226 my $save = $self->{path}->save_path; utf8::encode $save;
1219 my $uniq = $self->{path}->uniq_path; utf8::encode $uniq; 1227 my $uniq = $self->{path}->uniq_path; utf8::encode $uniq;
1220
1221 $self->{last_save} = $cf::RUNTIME;
1222
1223 return unless $self->dirty;
1224 1228
1225 $self->{load_path} = $save; 1229 $self->{load_path} = $save;
1226 1230
1227 return if $self->{deny_save}; 1231 return if $self->{deny_save};
1228 1232
1383 (ref $cf::CFG{"may_$access"} 1387 (ref $cf::CFG{"may_$access"}
1384 ? scalar grep $self->name eq $_, @{$cf::CFG{"may_$access"}} 1388 ? scalar grep $self->name eq $_, @{$cf::CFG{"may_$access"}}
1385 : $cf::CFG{"may_$access"}) 1389 : $cf::CFG{"may_$access"})
1386} 1390}
1387 1391
1392=item $player_object->enter_link
1393
1394Freezes the player and moves him/her to a special map (C<{link}>).
1395
1396The player should be reaosnably safe there for short amounts of time. You
1397I<MUST> call C<leave_link> as soon as possible, though.
1398
1399=item $player_object->leave_link ($map, $x, $y)
1400
1401Moves the player out of the specila link map onto the given map. If the
1402map is not valid (or omitted), the player will be moved back to the
1403location he/she was before the call to C<enter_link>, or, if that fails,
1404to the emergency map position.
1405
1406Might block.
1407
1408=cut
1409
1388sub cf::object::player::enter_link { 1410sub cf::object::player::enter_link {
1389 my ($self) = @_; 1411 my ($self) = @_;
1390 1412
1391 return if $self->map == $LINK_MAP; 1413 return if $self->map == $LINK_MAP;
1392 1414
1401 my ($self, $map, $x, $y) = @_; 1423 my ($self, $map, $x, $y) = @_;
1402 1424
1403 my $link_pos = delete $self->{_link_pos}; 1425 my $link_pos = delete $self->{_link_pos};
1404 1426
1405 unless ($map) { 1427 unless ($map) {
1406 $self->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED);
1407
1408 # restore original map position 1428 # restore original map position
1409 ($map, $x, $y) = @{ $link_pos || [] }; 1429 ($map, $x, $y) = @{ $link_pos || [] };
1410 $map = cf::map::find_map $map; 1430 $map = cf::map::find_map $map;
1411 1431
1412 unless ($map) { 1432 unless ($map) {
1427 1447
1428 $self->activate_recursive; 1448 $self->activate_recursive;
1429 $self->enter_map ($map, $x, $y); 1449 $self->enter_map ($map, $x, $y);
1430} 1450}
1431 1451
1432=item $player_object->goto_map ($map, $x, $y) 1452=item $player_object->goto_map ($path, $x, $y)
1433 1453
1434=cut 1454=cut
1435 1455
1436sub cf::object::player::goto_map { 1456sub cf::object::player::goto_map {
1437 my ($self, $path, $x, $y) = @_; 1457 my ($self, $path, $x, $y) = @_;
1442 $path = new cf::path $path; 1462 $path = new cf::path $path;
1443 1463
1444 my $map = cf::map::find_map $path->as_string; 1464 my $map = cf::map::find_map $path->as_string;
1445 $map = $map->customise_for ($self) if $map; 1465 $map = $map->customise_for ($self) if $map;
1446 1466
1447 warn "entering ", $map->path, " at ($x, $y)\n" 1467# warn "entering ", $map->path, " at ($x, $y)\n"
1448 if $map; 1468# if $map;
1469
1470 $map or $self->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED);
1449 1471
1450 $self->leave_link ($map, $x, $y); 1472 $self->leave_link ($map, $x, $y);
1451 })->prio (1); 1473 })->prio (1);
1452} 1474}
1453 1475
1864} 1886}
1865 1887
1866sub main { 1888sub main {
1867 # we must not ever block the main coroutine 1889 # we must not ever block the main coroutine
1868 local $Coro::idle = sub { 1890 local $Coro::idle = sub {
1869 Carp::cluck "FATAL: Coro::idle was called, major BUG\n";#d# 1891 Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d#
1870 (Coro::unblock_sub { 1892 (Coro::unblock_sub {
1871 Event::one_event; 1893 Event::one_event;
1872 })->(); 1894 })->();
1873 }; 1895 };
1874 1896

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines