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

Comparing cf.schmorp.de/server/lib/cf.pm (file contents):
Revision 1.168 by root, Sun Jan 14 00:37:14 2007 UTC vs.
Revision 1.171 by root, Sun Jan 14 12:24:48 2007 UTC

503our @CB_TYPE = (); # registry for type (cf-object class) based events 503our @CB_TYPE = (); # registry for type (cf-object class) based events
504our @CB_MAP = (); 504our @CB_MAP = ();
505 505
506my %attachment; 506my %attachment;
507 507
508sub cf::attachable::thawer_merge {
509 # simply override everything except _meta
510 local $_[0]{_meta};
511 %{$_[0]} = %{$_[1]};
512}
513
508sub _attach_cb($$$$) { 514sub _attach_cb($$$$) {
509 my ($registry, $event, $prio, $cb) = @_; 515 my ($registry, $event, $prio, $cb) = @_;
510 516
511 use sort 'stable'; 517 use sort 'stable';
512 518
683# object support 689# object support
684 690
685sub reattach { 691sub reattach {
686 # basically do the same as instantiate, without calling instantiate 692 # basically do the same as instantiate, without calling instantiate
687 my ($obj) = @_; 693 my ($obj) = @_;
694
695 bless $obj, ref $obj; # re-bless in case extensions have been reloaded
688 696
689 my $registry = $obj->registry; 697 my $registry = $obj->registry;
690 698
691 @$registry = (); 699 @$registry = ();
692 700
1142} 1150}
1143 1151
1144# also paths starting with '/' 1152# also paths starting with '/'
1145$EXT_MAP{"cf::map"} = qr{^(?=/)}; 1153$EXT_MAP{"cf::map"} = qr{^(?=/)};
1146 1154
1155sub thawer_merge {
1156 # we have to keep some variables in memory intact
1157 local $_[0]{path};
1158 local $_[0]{deny_save};
1159 local $_[0]{deny_reset};
1160
1161 $_[0]->SUPER::thawer_merge ($_[1]);
1162}
1163
1147sub normalise { 1164sub normalise {
1148 my ($path, $base) = @_; 1165 my ($path, $base) = @_;
1149 1166
1150 # map plan: 1167 # map plan:
1151 # 1168 #
1247 1264
1248sub unlink_save { 1265sub unlink_save {
1249 my ($self) = @_; 1266 my ($self) = @_;
1250 1267
1251 utf8::encode (my $save = $self->save_path); 1268 utf8::encode (my $save = $self->save_path);
1252 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink $save; 1269 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink $save;
1253 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink "$save.pst"; 1270 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink "$save.pst";
1254} 1271}
1255 1272
1256sub load_header_from($) { 1273sub load_header_from($) {
1257 my ($self, $path) = @_; 1274 my ($self, $path) = @_;
1258 1275
1319 1336
1320 $map->load_header 1337 $map->load_header
1321 or return; 1338 or return;
1322 1339
1323 if ($map->should_reset) { 1340 if ($map->should_reset) {
1341 $cf::WAIT_FOR_TICK->wait;
1324 $map->reset; 1342 $map->reset;
1325 undef $guard; 1343 undef $guard;
1326 $map = find $path 1344 $map = find $path
1327 or return; 1345 or return;
1328 } 1346 }
1498 1516
1499sub reset_at { 1517sub reset_at {
1500 my ($self) = @_; 1518 my ($self) = @_;
1501 1519
1502 # TODO: safety, remove and allow resettable per-player maps 1520 # TODO: safety, remove and allow resettable per-player maps
1503 return 1e99 if $self->isa ("ext::map_per_player"); 1521 return 1e99 if $self->isa ("ext::map_per_player");#d#
1504 return 1e99 if $self->{deny_reset}; 1522 return 1e99 if $self->{deny_reset};
1505 1523
1506 my $time = $self->fixed_resettime ? $self->{instantiate_time} : $self->last_access; 1524 my $time = $self->fixed_resettime ? $self->{instantiate_time} : $self->last_access;
1507 my $to = List::Util::min $MAX_RESET, $self->reset_timeout || $DEFAULT_RESET; 1525 my $to = List::Util::min $MAX_RESET, $self->reset_timeout || $DEFAULT_RESET;
1508 1526

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines