--- deliantra/server/ext/Jeweler.pm 2007/08/09 10:49:56 1.19 +++ deliantra/server/ext/Jeweler.pm 2008/02/17 22:37:34 1.24 @@ -26,13 +26,12 @@ sub read_config { my ($filename) = @_; - unless (-e $filename) { - warn "$filename doesn't exists! no config for jeweler skill loaded!\n"; + if (my $meta = $cf::RESOURCE{$filename}) { + $CFG = cf::decode_json $meta->{data}; + } else { + warn "$filename doesn't exist! no config for jeweler skill loaded!\n"; $CFG = {}; - return } - - $CFG = YAML::LoadFile $filename; } sub getcfg { @@ -167,11 +166,13 @@ my ($sk, $chdl, $pl, $input_level) = @_; my $hadunid = 0; + my $found = 0; for ($chdl->grep_by_type (cf::RING, cf::AMULET)) { if (!$_->flag (cf::FLAG_IDENTIFIED) && $_->need_identify) { $hadunid = 1; next; } + $found = 1; my $r = Jeweler::Object->new (object => $_); my $msg = $r->analyze ($sk, $pl, $input_level); $pl->message ($r->to_string . ": " . $msg); @@ -179,9 +180,10 @@ $r->wiz_analyze ($pl); } } - if ($hadunid) { - $pl->message ("You couldn't identify the other rings and not analyze them!"); - } + $pl->message ("You couldn't identify the other rings and not analyze them!") + if $hadunid; + $pl->message ("You couldn't find anything in the bench to analyse!") + unless $found; } # this function converts metals/minerals into a raw ring (of adornment) @@ -205,7 +207,7 @@ } unless ($xp_gain > 0) { - warn "WARNING: xp gain isn't > 0 in convesion '$outarch'\n"; + warn "WARNING: xp gain isn't > 0 in conversion '$outarch'\n"; return; } @@ -223,17 +225,17 @@ my $outarchval = cf::arch::find ($outarch)->value; - my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); + my $nrof = int $archvalsum / (($outarchval || 1000) * $outarchvalfact); if ($nrof) { - # XXX: yes, i know what i'm doing here, i don't set nrof, but it didn't work somehow (pls. chek sometimes) - for (1..$nrof) { + # XXX: yes, I know what I'm doing here, I don't set nrof, but it didn't work somehow (pls. check sometimes) + for (1 .. $nrof) { $chdl->put (my $ob = cf::object::new $outarch); $ob->set_animation (cf::rndm $ob->num_animations) if ($ob->type == cf::RING); $ob->flag (cf::FLAG_IDENTIFIED, 1); } - my $xp_sum = ($xp_gain * $nrof); + my $xp_sum = $xp_gain * $nrof; if ($xp_sum) { $pl->ob->message ("You got $xp_sum xp by making $nrof ${outarch}s"); @@ -357,7 +359,7 @@ my ($self, $obj) = @_; return undef unless $self->{cauldron}; - $obj->insert_ob_in_ob ($self->{cauldron}); + $self->{cauldron}->insert ($obj); } =back @@ -479,7 +481,7 @@ sub improve_ring_by_plan { my ($self, $plan, $ring) = @_; - $ring = dclone ($ring); + $ring = do { my $guard = Coro::Storable::guard; dclone $ring }; my $ingred = $self->{ingredients}; my $impr = {}; @@ -573,7 +575,7 @@ sub check_costs { my ($self, $costs, $do_remove) = @_; - my $costs = dclone ($costs); + my $costs = do { my $guard = Coro::Storable::guard; dclone $costs }; for my $key (keys %$costs) { my @grepar;