Code: Select all
Index: Receive/ServerType0.pm
===================================================================
--- Receive/ServerType0.pm (revision 7061)
+++ Receive/ServerType0.pm (working copy)
@@ -6763,7 +6763,46 @@
sub mail_setattachment {
my ($self, $args) = @_;
- message TF("%s to attach %s.\n", ($args->{fail}) ? "Failed" : "Succeeded", ($args->{index}) ? "item: ".$char->inventory->getByServerIndex($args->{index}) : "zeny"), "info";
+
+ my $item = $char->inventory->getByServerIndex ($args->{index});
+ if ($item) {
+ unless ($args->{fail}) {
+ if (exists $char->{outcomingMailAttachAmount}) {
+ $item->{amount} -= $char->{outcomingMailAttachAmount};
+ message TF("You succeeded to attach item: %s (%d) x %d - %d left\n",
+ $item->{name}, $item->{invIndex}, $char->{outcomingMailAttachAmount}, $item->{amount}
+ );
+ $itemChange{$item->{name}} -= $char->{outcomingMailAttachAmount};
+ $char->inventory->remove ($item) unless $item->{amount} > 0;
+ } else {
+ message TF("You succeeded to attach item: %s\n", $item->{name});
+ error "BUG: Received mail_setattachment, but have no information about attached amount\n";
+ warning "Your inventory can now be out of sync with server\n";
+ }
+ } else {
+ message TF("You failed to attach item: %s\n", $item->{name});
+ }
+ } elsif ($args->{index} == 0) {
+ unless ($args->{fail}) {
+ message T("You succeeded to attach zeny\n");
+ if (exists $char->{outcomingMailAttachAmount}) {
+ $char->{zeny} -= $char->{outcomingMailAttachAmount};
+ } else {
+ error "BUG: Received mail_setattachment, but have no information about attached amount\n";
+ warning "Your zeny can now be out of sync with server\n";
+ }
+ } else {
+ message T("You failed to attach zeny\n");
+ }
+ } else {
+ unless ($args->{fail}) {
+ message TF("You succeeded to attach unknown item #%d\n", $args->{index});
+ } else {
+ message TF("You failed to attach unknown item #%d\n", $args->{index});
+ }
+ }
+
+ delete $char->{outcomingMailAttachAmount};
}
sub mail_delete {
Index: Send/ServerType0.pm
===================================================================
--- Send/ServerType0.pm (revision 7060)
+++ Send/ServerType0.pm (working copy)
@@ -1519,6 +1519,8 @@
my $msg = pack("v2 V", 0x0247, $index, $amount);
$self->sendToServer($msg);
debug "Sent mail set attachment.\n", "sendPacket", 2;
+
+ $char->{outcomingMailAttachAmount} = $amount;
}
sub sendMailSend {
P.S. OK that should be in mail_send, not mail_setattachment. Will fix later.