--- deliantra/server/lib/cf.pm 2006/12/25 14:43:23 1.101 +++ deliantra/server/lib/cf.pm 2006/12/27 15:20:54 1.102 @@ -456,6 +456,28 @@ ############################################################################# # object support +sub reattach { + # basically do the same as instantiate, without calling instantiate + my ($obj) = @_; + + my $registry = $obj->registry; + + @$registry = (); + + delete $obj->{_attachment} unless scalar keys %{ $obj->{_attachment} || {} }; + + for my $name (keys %{ $obj->{_attachment} || {} }) { + if (my $attach = $attachment{$name}) { + for (@$attach) { + my ($klass, @attach) = @$_; + _attach $registry, $klass, @attach; + } + } else { + warn "object uses attachment '$name' that is not available, postponing.\n"; + } + } +} + cf::attachable->attach ( prio => -1000000, on_instantiate => sub { @@ -469,26 +491,7 @@ $obj->attach ($name, %{$args || {} }); } }, - on_reattach => sub { - # basically do the same as instantiate, without calling instantiate - my ($obj) = @_; - my $registry = $obj->registry; - - @$registry = (); - - delete $obj->{_attachment} unless scalar keys %{ $obj->{_attachment} || {} }; - - for my $name (keys %{ $obj->{_attachment} || {} }) { - if (my $attach = $attachment{$name}) { - for (@$attach) { - my ($klass, @attach) = @$_; - _attach $registry, $klass, @attach; - } - } else { - warn "object uses attachment '$name' that is not available, postponing.\n"; - } - } - }, + on_reattach => \&reattach, on_clone => sub { my ($src, $dst) = @_;