--- deliantra/server/lib/cf.pm 2006/08/27 13:02:04 1.47 +++ deliantra/server/lib/cf.pm 2006/08/27 15:24:22 1.48 @@ -107,15 +107,15 @@ ############################################################################# # "new" plug-in system -=item $object->attach ($attachment, ...) +=item $object->attach ($attachment, key => $value...) Attach a pre-registered attachment to an object. -=item $player->attach ($attachment, ...) +=item $player->attach ($attachment, key => $value...) Attach a pre-registered attachment to a player. -=item $map->attach ($attachment, ...) # not yet persistent +=item $map->attach ($attachment, key => $value...) # not yet persistent Attach a pre-registered attachment to a map. @@ -247,7 +247,7 @@ } sub _attach_attachment { - my ($obj, $name, @args) = @_; + my ($obj, $name, %arg) = @_; my $res; @@ -259,15 +259,7 @@ $res = _attach @$registry, $klass, @attach; } - if (my $cb = delete $registry->[EVENT_OBJECT_INSTANTIATE]) { - for (@$cb) { - eval { $_->[1]->($obj, @args); }; - if ($@) { - warn "$@"; - warn "... while processing '$name' instantiate with args <@args>.\n"; - } - } - } + $obj->{$name} = \%arg; } else { warn "object uses attachment '$name' that is not available, postponing.\n"; } @@ -279,21 +271,21 @@ } sub cf::object::attach { - my ($obj, $name, @args) = @_; + my ($obj, $name, %arg) = @_; - _attach_attachment $obj, $name, @args; + _attach_attachment $obj, $name, %arg; } sub cf::player::attach { - my ($obj, $name, @args) = @_; + my ($obj, $name, %arg) = @_; - _attach_attachment KLASS_PLAYER, $obj, $name, @args; + _attach_attachment KLASS_PLAYER, $obj, $name, %arg; } sub cf::map::attach { - my ($obj, $name, @args) = @_; + my ($obj, $name, %arg) = @_; - _attach_attachment KLASS_MAP, $obj, $name, @args; + _attach_attachment KLASS_MAP, $obj, $name, %arg; } sub attach_global { @@ -366,7 +358,7 @@ for (@$data) { my ($name, $args) = @$_; - attach $obj, $name, @{$args || [] }; + attach $obj, $name, %{$args || {} }; } }