--- deliantra/server/ext/reseller.ext 2008/10/06 18:26:35 1.15 +++ deliantra/server/ext/reseller.ext 2010/05/04 21:45:42 1.18 @@ -2,15 +2,16 @@ sub ob2info { my ($item, $rval) = @_; + sprintf "[%s from %s (%d:%d%s) nrof: %d uuid: %s]", $item->name, $item->kv_get ('ext_reseller_seller'), $item->kv_get ('ext_reseller_orig_value'), $item->value, - (defined $rval ? ":$rval" : ""), $item->nrof, $item->uuid; + (defined $rval ? ":$rval" : ""), $item->nrof, $item->uuid } sub audit_log { my ($who, $action, $info) = @_; - warn + cf::info sprintf "RESELLER_AUDIT(%s) %s %s: %s\n", $who->map->path, $who->name, $action, $info; } @@ -21,21 +22,24 @@ my ($ob, $cb) = @_; my @found; + for my $i ($ob->inv) { push @found, $i if $cb->($i); push @found, find_rec $i, $cb if $i->inv; } - return @found; + @found } sub find_unpaid { my ($ob) = @_; + find_rec $ob, sub { $_[0]->flag (cf::FLAG_UNPAID) }; } sub find_traded { my ($ob) = @_; + find_rec $ob, sub { $_[0]->kv_get ('ext_reseller_seller') ne '' }; } @@ -98,7 +102,7 @@ $who->map->at ($self->{reseller_shopmat}{npc_x}, $self->{reseller_shopmat}{npc_y}); unless (@obs) { - warn "Couldn't find shop keeper in " . $who->map->path . "\n"; + cf::error "Couldn't find shop keeper in " . $who->map->path . "\n"; return cf::override; } @@ -118,8 +122,8 @@ my $value = $item->query_cost ($who, cf::F_BUY | cf::F_SHOP); - warn "Object " . $item->name . " bought by " . $who->name . " on map " - . $who->map->path . " for $value silver has no seller set\n" + cf::debug "Object ", $item->name, " bought by ", $who->name, " on map " , + $who->map->path, " for $value silver has no seller set\n" if $item->kv_get ('ext_reseller_seller') eq ''; $unpaid_items->{$item} = [$value, $item]; @@ -221,6 +225,13 @@ return cf::override; } + if ($value > 100 ** 4) { # also for overflow prevention + give_back_with_message ($who, $what, + "The shopkeeper says: You can't sell something for such a high " + . "value. Please keep it below 100 royalty."); + return cf::override; + } + if ($value < 0) { give_back_with_message ($who, $what, "The shopkeeper says: You can't sell something for a negative value: $value."); @@ -275,3 +286,4 @@ cf::override; }, ; +