--- deliantra/server/lib/cf.pm 2006/12/17 22:03:44 1.91 +++ deliantra/server/lib/cf.pm 2006/12/21 06:42:28 1.92 @@ -154,12 +154,20 @@ =item $map->detach ($attachment) +Attach/detach a pre-registered attachment to a client. + +=item $client->attach ($attachment, key => $value...) + +=item $client->detach ($attachment) + Attach/detach a pre-registered attachment to a map. =item $bool = $object->attached ($name) =item $bool = $player->attached ($name) +=item $bool = $client->attached ($name) + =item $bool = $map->attached ($name) Checks wether the named attachment is currently attached to the object. @@ -215,6 +223,10 @@ Attach handlers to all players. +=item cf::attach_to_clients ... + +Attach handlers to all players. + =item cf::attach_to_maps ... Attach handlers to all maps. @@ -240,6 +252,7 @@ our @CB_GLOBAL = (); # registry for all global events our @CB_OBJECT = (); # all objects (should not be used except in emergency) our @CB_PLAYER = (); +our @CB_CLIENT = (); our @CB_TYPE = (); # registry for type (cf-object class) based events our @CB_MAP = (); @@ -332,6 +345,7 @@ *cf::object::attach = *cf::player::attach = +*cf::client::attach = *cf::map::attach = sub { my ($obj, $name, %arg) = @_; @@ -341,6 +355,7 @@ # all those should be optimised *cf::object::detach = *cf::player::detach = +*cf::client::detach = *cf::map::detach = sub { my ($obj, $name) = @_; @@ -350,6 +365,7 @@ *cf::object::attached = *cf::player::attached = +*cf::client::attached = *cf::map::attached = sub { my ($obj, $name) = @_; @@ -375,6 +391,10 @@ _attach @CB_PLAYER, KLASS_PLAYER, @_ } +sub attach_to_clients { + _attach @CB_CLIENT, KLASS_CLIENT, @_ +} + sub attach_to_maps { _attach @CB_MAP, KLASS_MAP, @_ } @@ -391,6 +411,12 @@ $attachment{$name} = [[KLASS_PLAYER, @_]]; } +sub register_client_attachment { + my $name = shift; + + $attachment{$name} = [[KLASS_CLIENT, @_]]; +} + sub register_map_attachment { my $name = shift; @@ -434,6 +460,8 @@ =item $bool = $player->invoke (EVENT_PLAYER_XXX, ...) +=item $bool = $client->invoke (EVENT_CLIENT_XXX, ...) + =item $bool = $map->invoke (EVENT_MAP_XXX, ...) Generate a global/object/player/map-specific event with the given arguments. @@ -452,7 +480,7 @@ =over 4 -=item $object->valid, $player->valid, $map->valid +=item $object->valid, $player->valid, $client->valid, $map->valid Just because you have a perl object does not mean that the corresponding C-level object still exists. If you try to access an object that has no @@ -466,6 +494,7 @@ *cf::object::valid = *cf::player::valid = +*cf::client::valid = *cf::map::valid = \&cf::_valid; #############################################################################