--- deliantra/server/lib/cf.pm 2007/08/28 19:38:40 1.346 +++ deliantra/server/lib/cf.pm 2007/09/02 00:57:38 1.351 @@ -274,6 +274,9 @@ for example when the coroutine gets canceled), the lock is automatically returned. +Locks are *not* recursive, locking from the same coro twice results in a +deadlocked coro. + Lock names should begin with a unique identifier (for example, cf::map::find uses map_find and cf::map::load uses map_load). @@ -2085,17 +2088,21 @@ sub nuke { my ($self) = @_; - delete $cf::MAP{$self->path}; + { + my $lock = cf::lock_acquire "map_data:$self->{path}"; - $self->unlink_save; + delete $cf::MAP{$self->path}; - bless $self, "cf::map"; - delete $self->{deny_reset}; - $self->{deny_save} = 1; - $self->reset_timeout (1); - $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); + $self->unlink_save; + + bless $self, "cf::map"; + delete $self->{deny_reset}; + $self->{deny_save} = 1; + $self->reset_timeout (1); + $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); - $cf::MAP{$self->path} = $self; + $cf::MAP{$self->path} = $self; + } $self->reset; # polite request, might not happen } @@ -2499,6 +2506,15 @@ =cut +our %CHANNEL = ( + "c/identify" => { + id => "identify", + title => "Identify", + reply => undef, + tooltip => "Items recently identified", + }, +); + sub cf::client::send_msg { my ($self, $channel, $msg, $color, @extra) = @_; @@ -2506,6 +2522,9 @@ $color &= cf::NDI_CLIENT_MASK; # just in case... + # check predefined channels, for the benefit of C + $channel = $CHANNEL{$channel} if $CHANNEL{$channel}; + if (ref $channel) { # send meta info to client, if not yet sent unless (exists $self->{channel}{$channel->{id}}) { @@ -2835,6 +2854,10 @@ sub load_facedata($) { my ($path) = @_; + # HACK to clear player env face cache, we need some signal framework + # for this (global event?) + %ext::player_env::MUSIC_FACE_CACHE = (); + my $enc = JSON::XS->new->utf8->canonical->relaxed; warn "loading facedata from $path\n"; @@ -2955,6 +2978,10 @@ }; sub reload_regions { + # HACK to clear player env face cache, we need some signal framework + # for this (global event?) + %ext::player_env::MUSIC_FACE_CACHE = (); + load_resource_file "$MAPDIR/regions" or die "unable to load regions file\n";