--- deliantra/server/lib/cf.pm 2006/08/28 16:52:51 1.52 +++ deliantra/server/lib/cf.pm 2006/08/29 14:49:28 1.54 @@ -109,15 +109,21 @@ =item $object->attach ($attachment, key => $value...) -Attach a pre-registered attachment to an object. +=item $object->detach ($attachment) + +Attach/detach a pre-registered attachment to an object. =item $player->attach ($attachment, key => $value...) -Attach a pre-registered attachment to a player. +=item $player->detach ($attachment) + +Attach/detach a pre-registered attachment to a player. + +=item $map->attach ($attachment, key => $value...) -=item $map->attach ($attachment, key => $value...) # not yet persistent +=item $map->detach ($attachment) -Attach a pre-registered attachment to a map. +Attach/detach a pre-registered attachment to a map. =item cf::attach_global ... @@ -278,23 +284,23 @@ $res } -sub cf::object::attach { - my ($obj, $name, %arg) = @_; - - _attach_attachment $obj, $name, %arg; -} - -sub cf::player::attach { +*cf::object::attach = +*cf::player::attach = +*cf::map::attach = sub { my ($obj, $name, %arg) = @_; _attach_attachment $obj, $name, %arg; } -sub cf::map::attach { - my ($obj, $name, %arg) = @_; - - _attach_attachment $obj, $name, %arg; -} +# all those should be optimised +*cf::object::detach = +*cf::player::detach = +*cf::map::detach = sub { + my ($obj, $name) = @_; + + delete $obj->{_attachment}{$name}; + reattach $obj; +}; sub attach_global { _attach @CB_GLOBAL, KLASS_GLOBAL, @_