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.48 by root, Sun Aug 27 15:24:22 2006 UTC vs.
Revision 1.50 by root, Mon Aug 28 07:07:42 2006 UTC

72 72
73@safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object'; 73@safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object';
74 74
75# we bless all objects into (empty) derived classes to force a method lookup 75# we bless all objects into (empty) derived classes to force a method lookup
76# within the Safe compartment. 76# within the Safe compartment.
77for my $pkg (qw(cf::object cf::object::player cf::player cf::map cf::party cf::region cf::arch)) { 77for my $pkg (qw(cf::object cf::object::player cf::player cf::map cf::party cf::region cf::arch cf::living)) {
78 no strict 'refs'; 78 no strict 'refs';
79 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; 79 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg;
80} 80}
81 81
82$Event::DIED = sub { 82$Event::DIED = sub {
262 $obj->{$name} = \%arg; 262 $obj->{$name} = \%arg;
263 } else { 263 } else {
264 warn "object uses attachment '$name' that is not available, postponing.\n"; 264 warn "object uses attachment '$name' that is not available, postponing.\n";
265 } 265 }
266 266
267 push @{$obj->{_attachment}}, $name; 267 $obj->{_attachment}{$name} = undef;
268 268
269 $res->{attachment} = $name; 269 $res->{attachment} = $name;
270 $res 270 $res
271} 271}
272 272
356 356
357 $data = from_json $data; 357 $data = from_json $data;
358 358
359 for (@$data) { 359 for (@$data) {
360 my ($name, $args) = @$_; 360 my ($name, $args) = @$_;
361
361 attach $obj, $name, %{$args || {} }; 362 $obj->attach ($name, %{$args || {} });
362 } 363 }
363} 364}
364 365
365# basically do the same as instantiate, without calling instantiate 366# basically do the same as instantiate, without calling instantiate
366sub reattach { 367sub reattach {
367 my ($obj) = @_; 368 my ($obj) = @_;
368 my $registry = $obj->registry; 369 my $registry = $obj->registry;
369 370
370 @$registry = (); 371 @$registry = ();
371 372
373 delete $obj->{_attachment} unless scalar keys %{ $obj->{_attachment} || {} };
374
372 for my $name (@{ $obj->{_attachment} }) { 375 for my $name (keys %{ $obj->{_attachment} || {} }) {
373 if (my $attach = $attachment{$name}) { 376 if (my $attach = $attachment{$name}) {
374 for (@$attach) { 377 for (@$attach) {
375 my ($klass, @attach) = @$_; 378 my ($klass, @attach) = @$_;
376 _attach @$registry, $klass, @attach; 379 _attach @$registry, $klass, @attach;
377 } 380 }
413 416
414 @{$dst->registry} = @{$src->registry}; 417 @{$dst->registry} = @{$src->registry};
415 418
416 %$dst = %$src; 419 %$dst = %$src;
417 420
418 $dst->{_attachment} = [@{ $src->{_attachment} }] 421 %{$dst->{_attachment}} = %{$src->{_attachment}}
419 if exists $src->{_attachment}; 422 if exists $src->{_attachment};
420 }, 423 },
421; 424;
422 425
423############################################################################# 426#############################################################################
684 687
685 $data->{version} <= 1 688 $data->{version} <= 1
686 or return; # too new 689 or return; # too new
687 690
688 $map->_set_obs ($data->{obs}); 691 $map->_set_obs ($data->{obs});
692 $map->invoke (EVENT_MAP_UPGRADE);
689}; 693};
690 694
691attach_to_maps prio => -10000, package => cf::mapsupport::; 695attach_to_maps prio => -10000, package => cf::mapsupport::;
692 696
693############################################################################# 697#############################################################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines