--- deliantra/server/ext/reseller.ext 2007/12/05 11:08:34 1.9 +++ deliantra/server/ext/reseller.ext 2007/12/24 16:41:55 1.10 @@ -121,7 +121,7 @@ audit_log ($who, 'removes', ob2info ($item)); $item->flag (cf::FLAG_UNPAID, 0); $item->remove; - $who->insert ($item); + give_back ($who, $item); next; } @@ -164,6 +164,18 @@ }, ; +sub give_back { + my ($who, $what) = @_; + $who->insert ($what); + $who->esrv_send_item ($what); +} + +sub give_back_with_message { + my ($who, $what, $msg) = @_; + $who->message ($msg, cf::NDI_BROWN); + give_back ($who, $what); +} + cf::object::attachment "reseller_floor", on_drop_on => sub { my ($on, $what, $who) = @_; @@ -172,14 +184,14 @@ return if $what->flag (cf::FLAG_UNPAID); if ($what->type == cf::MONEY) { - $who->message ("The shopkeeper says: Sorry, you can't sell money here.", cf::NDI_BROWN); - $who->insert ($what); + give_back_with_message ($who, $what, + "The shopkeeper says: Sorry, you can't sell money here."); return cf::override; } if (!$what->flag (cf::FLAG_IDENTIFIED) && $what->need_identify) { - $who->message ("The shopkeeper says: Sorry, you can't sell unidentified stuff here.", cf::NDI_BROWN); - $who->insert ($what); + give_back_with_message ($who, $what, + "The shopkeeper says: Sorry, you can't sell unidentified stuff here."); return cf::override; } @@ -188,8 +200,9 @@ if ($name =~ m/\S/) { unless ($name =~ m/\d+\s*\S+/) { - $who->message ("The shopkeeper says: Sorry, I don't recognize '$name' as currency. Please name your item like '10 royalty' or '10 platinum 2 silver'", cf::NDI_BROWN); - $who->insert ($what); + give_back_with_message ($who, $what, + "The shopkeeper says: Sorry, I don't recognize '$name' as currency. " + ."Please name your item like '10 royalty' or '10 platinum 2 silver'"); return cf::override; } @@ -197,33 +210,40 @@ if ($aliases{lc $2} or $unit{lc $2}) { $value += $1 * ($unit{lc $2} ? $unit{lc $2} : $unit{$aliases{lc $2}}); } else { - $who->insert ($what); - $who->message ("The shopkeeper says: I don't know the currency '$2'", cf::NDI_BROWN); + give_back_with_message ($who, $what, + "The shopkeeper says: I don't know the currency '$2', you can use one of these currencies: ".join (", ", keys %unit)." or also: ".join (", ", keys %aliases)); return cf::override; } } } else { - $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); + # commented out the following line because too many just use the + # reseller shop as dumpyard: + # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); + give_back_with_message ($who, $what, + "Sorry, you can't just sell stuff without assigning a price to it! " + ."Please name your item like '10 royalty' or '10 platinum 2 silver' " + ."and drop it again. (To rename the item use the 'rename' " + ."context menu item in the inventory)."); + return cf::override; } if ($value < 0) { - $who->insert ($what); - $who->message ("The shopkeeper says: You can't sell something for a negative value: $value", cf::NDI_BROWN); + give_back_with_message ($who, $what, + "The shopkeeper says: You can't sell something for a negative value: $value"); return cf::override; } my $fee = $value / 100; # 1% selling fee unless ($who->pay_amount ($fee)) { - $who->message ( - "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) . " to pay the 1% fee for this item", - cf::NDI_BROWN - ); - $who->insert ($what); + give_back_with_message ($who, $what, + "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) + . " to pay the 1% fee for this item"); return cf::override; } else { $who->message ( - "The shopkeeper says: Ok, got the fee of " . cf::cost_string_from_value ($fee) . " for the item", + "The shopkeeper says: Ok, got the fee of " . cf::cost_string_from_value ($fee) + . " for the item", cf::NDI_BROWN ); }