--- deliantra/server/lib/cf.pm 2007/07/10 16:23:59 1.302 +++ deliantra/server/lib/cf.pm 2007/07/16 15:27:06 1.309 @@ -872,7 +872,7 @@ sub override { $override = 1; - @invoke_results = (); + @invoke_results = (@_); } sub do_invoke { @@ -1491,7 +1491,7 @@ my ($match, $specificity); for my $region (list) { - if ($region->match && $path =~ $region->match) { + if ($region->{match} && $path =~ $region->{match}) { ($match, $specificity) = ($region, $region->specificity) if $region->specificity > $specificity; } @@ -1621,7 +1621,7 @@ } } - Carp::carp "unable to resolve path '$path' (base '$base')."; + Carp::cluck "unable to resolve path '$path' (base '$base')."; () } @@ -1909,9 +1909,9 @@ $MAP_PREFETCHER ||= cf::async { while (%MAP_PREFETCH) { for my $path (keys %MAP_PREFETCH) { - my $map = find $path - or next; - $map->load; + if (my $map = find $path) { + $map->load; + } delete $MAP_PREFETCH{$path}; } @@ -2258,19 +2258,20 @@ $self->enter_map ($map, $x, $y); } -=item $player_object->goto ($path, $x, $y[, $check->($map)]) +=item $player_object->goto ($path, $x, $y[, $check->($map)[, $done->()]]) Moves the player to the given map-path and coordinates by first freezing her, loading and preparing them map, calling the provided $check callback that has to return the map if sucecssful, and then unfreezes the player on -the new (success) or old (failed) map position. +the new (success) or old (failed) map position. In either case, $done will +be called at the end of this process. =cut our $GOTOGEN; sub cf::object::player::goto { - my ($self, $path, $x, $y, $check) = @_; + my ($self, $path, $x, $y, $check, $done) = @_; # do generation counting so two concurrent goto's will be executed in-order my $gen = $self->{_goto_generation} = ++$GOTOGEN; @@ -2300,6 +2301,8 @@ delete $self->{_goto_generation}; $self->leave_link ($map, $x, $y); } + + $done->() if $done; })->prio (1); } @@ -2467,6 +2470,8 @@ sub cf::client::ext_event($$%) { my ($self, $type, %msg) = @_; + return unless $self->extcmd; + $msg{msgtype} = "event_$type"; $self->send_packet ("ext " . $self->{json_coder}->encode (\%msg)); } @@ -2766,18 +2771,22 @@ my $meta = $enc->encode ({ name => $name, type => $info->{type}, - copyright => $info->{copyright}, + copyright => $info->{copyright}, #TODO# }); - my $data = pack "(w/a*)*", $meta, $info->{data}; - my $chk = Digest::MD5::md5 "$info->{chksum},$meta"; # mangle data checksum and metadata - - use Data::Dumper; warn Dumper substr $data, 0, 100;#d# my $idx = (cf::face::find $name) || cf::face::alloc $name; - cf::face::set_type $idx, 1; - cf::face::set_data $idx, 0, $data, $chk; - # TODO + if ($name =~ /\.jpg$/) { + cf::face::set_data $idx, 0, $info->{data}, $info->{chksum};#d# temp hack + cf::face::set_data $idx, 1, $info->{data}, $info->{chksum};#d# temp hack + } else { + my $data = pack "(w/a*)*", $meta, $info->{data}; + my $chk = Digest::MD5::md5 "$info->{chksum},$meta"; # mangle data checksum and metadata + + cf::face::set_type $idx, 1; + cf::face::set_data $idx, 0, $data, $chk; + } + cf::cede_to_tick; } } @@ -2788,6 +2797,11 @@ sub reload_regions { load_resource_file "$MAPDIR/regions" or die "unable to load regions file\n"; + + for (cf::region::list) { + $_->{match} = qr/$_->{match}/ + if exists $_->{match}; + } } sub reload_facedata {